[clang] [clang][CodeGen] `sret` args should always point to the `alloca` AS, so use that (PR #114062)
Alex Voicu via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 22 16:43:35 PST 2024
================
@@ -296,18 +296,25 @@ void AggExprEmitter::withReturnValueSlot(
(RequiresDestruction && Dest.isIgnored());
Address RetAddr = Address::invalid();
- RawAddress RetAllocaAddr = RawAddress::invalid();
EHScopeStack::stable_iterator LifetimeEndBlock;
llvm::Value *LifetimeSizePtr = nullptr;
llvm::IntrinsicInst *LifetimeStartInst = nullptr;
if (!UseTemp) {
- RetAddr = Dest.getAddress();
+ // It is possible for the existing slot we are using directly to have been
+ // allocated in the correct AS for an indirect return, and then cast to
+ // the default AS (this is the behaviour of CreateMemTemp), however we know
+ // that the return address is expected to point to the uncasted AS, hence we
+ // strip possible pointer casts here.
----------------
AlexVlx wrote:
Yes, Dest could have been allocated via simple `CreateMemTemp`, which would then cast from the AllocaAS to the DefaultAS. As the code is currently structured I didn't see a way to disambiguate between allocating for a return vs allocating for a "normal" aggregate, so handling it here seemed like the only way to do it tidily.
https://github.com/llvm/llvm-project/pull/114062
More information about the cfe-commits
mailing list