================
@@ -274,73 +274,114 @@ bool AggExprEmitter::TypeRequiresGCollection(QualType T)
{
return Record->hasObjectMember();
}
+static bool mightABIExpectAllocaAndNotAlloca(const Address RetAddr,
+ QualType RetTy,
+ const llvm::DataLayout &DL) {
+ const CXXRecordDecl *RD = RetTy->getAsCXXRecordDecl();
+ // ABIInfo might be permitted to make this return indirect. If it does, and
+ // RetTy doesn't specify an address space, it is also permitted (but not
+ // required) to change the ABI addrspace to alloca (adding an addrspacecase).
+ // We don't yet know what it will decide (awkwardly this query runs just
+ // before ABIInfo decides how to pass this sret parameter), so this may need
+ // to make a copy here, which maybe the optimizer could remove later, if it
+ // can still prove it unnecessary.
+ if (!RetAddr.isValid())
+ return false;
+ if (RetTy.hasAddressSpace())
+ return false;
+ if (RD && !RD->canPassInRegisters())
+ return false;
+ unsigned AllocaAS = DL.getAllocaAddrSpace();
+ // This will require a copy to ensure it is in the alloca (ABIInfo's
+ // indirect) addrspace unless we can find that the underlying object was
+ // already in alloca addrspace.
+ llvm::Value *DestV = RetAddr.getBasePointer();
+ if (DestV->getType()->getPointerAddressSpace() == AllocaAS)
+ return false;
+ DestV = DestV->stripPointerCasts();
+ if (DestV->getType()->getPointerAddressSpace() == AllocaAS)
+ return false;
+ return true;
+}
+
+static bool EmitLifetimeStartOnAlloca(CodeGenFunction &CGF, llvm::Value *Ptr) {
+ // Lifetime start is only valid on alloca
+ Ptr = Ptr->stripPointerCasts();
+ if (isa<llvm::AllocaInst>(Ptr))
----------------
arsenm wrote:
I'd expect this to be known based on the context it's being emitted and not
need checking what it emitted?
https://github.com/llvm/llvm-project/pull/181256
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits