[NFC][OpaquePtr] Make getMemoryParamAllocType() compatible with opaque pointers
authorArthur Eubanks <aeubanks@google.com>
Fri, 11 Jun 2021 22:59:20 +0000 (15:59 -0700)
committerArthur Eubanks <aeubanks@google.com>
Fri, 11 Jun 2021 23:01:23 +0000 (16:01 -0700)
These ABI attributes now always require the type parameter.

sret was missing from the first set of checks but was covered by the
second set.

llvm/lib/IR/Function.cpp

index 29e0c64..25c59d0 100644 (file)
@@ -169,14 +169,8 @@ static Type *getMemoryParamAllocType(AttributeSet ParamAttrs, Type *ArgTy) {
     return PreAllocTy;
   if (Type *InAllocaTy = ParamAttrs.getInAllocaType())
     return InAllocaTy;
-
-  // FIXME: sret and inalloca always depends on pointee element type. It's also
-  // possible for byval to miss it.
-  if (ParamAttrs.hasAttribute(Attribute::InAlloca) ||
-      ParamAttrs.hasAttribute(Attribute::ByVal) ||
-      ParamAttrs.hasAttribute(Attribute::StructRet) ||
-      ParamAttrs.hasAttribute(Attribute::Preallocated))
-    return cast<PointerType>(ArgTy)->getElementType();
+  if (Type *SRetTy = ParamAttrs.getStructRetType())
+    return SRetTy;
 
   return nullptr;
 }