-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang][CodeGen] sret
args should always point to the alloca
AS, so use that
#114062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d2d2d3d
693253d
b5a7df0
f6cff66
2de33d4
6d9cb89
b209d67
ac6367b
c8f03e7
24d8edb
5ccd554
9ff1d0d
1c3e67c
c9288fc
99e03a2
013790c
c4bdeab
5afb40e
d07d63d
eeb54e4
6c0ef88
abab201
6e78db1
7d45638
f16d1d9
0277516
056c9ec
207a2ae
d8bd7ab
f6c8e01
0f724f8
7158b8d
8f472f3
2bdb085
99101fb
86093c2
4b47cd7
d103255
e325239
27ef889
260e96d
5227aef
94b51d5
53d8462
4d2b9f7
d9595fc
3acc4ff
69b7937
ddaccb8
f442024
939af07
05f0701
3e10da3
0867735
553ac57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
Comment on lines
+304
to
+308
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this still true in this version? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, Dest could have been allocated via simple |
||
if (Dest.getAddress().isValid()) | ||
RetAddr = Dest.getAddress().withPointer( | ||
Dest.getAddress().getBasePointer()->stripPointerCasts(), | ||
Dest.getAddress().isKnownNonNull()); | ||
} else { | ||
RetAddr = CGF.CreateMemTemp(RetTy, "tmp", &RetAllocaAddr); | ||
RetAddr = CGF.CreateMemTempWithoutCast(RetTy, "tmp"); | ||
llvm::TypeSize Size = | ||
CGF.CGM.getDataLayout().getTypeAllocSize(CGF.ConvertTypeForMem(RetTy)); | ||
LifetimeSizePtr = CGF.EmitLifetimeStart(Size, RetAllocaAddr.getPointer()); | ||
LifetimeSizePtr = CGF.EmitLifetimeStart(Size, RetAddr.getBasePointer()); | ||
if (LifetimeSizePtr) { | ||
LifetimeStartInst = | ||
cast<llvm::IntrinsicInst>(std::prev(Builder.GetInsertPoint())); | ||
|
@@ -316,7 +323,7 @@ void AggExprEmitter::withReturnValueSlot( | |
"Last insertion wasn't a lifetime.start?"); | ||
|
||
CGF.pushFullExprCleanup<CodeGenFunction::CallLifetimeEnd>( | ||
NormalEHLifetimeMarker, RetAllocaAddr, LifetimeSizePtr); | ||
NormalEHLifetimeMarker, RetAddr, LifetimeSizePtr); | ||
LifetimeEndBlock = CGF.EHStack.stable_begin(); | ||
} | ||
} | ||
|
@@ -337,7 +344,7 @@ void AggExprEmitter::withReturnValueSlot( | |
// Since we're not guaranteed to be in an ExprWithCleanups, clean up | ||
// eagerly. | ||
CGF.DeactivateCleanupBlock(LifetimeEndBlock, LifetimeStartInst); | ||
CGF.EmitLifetimeEnd(LifetimeSizePtr, RetAllocaAddr.getPointer()); | ||
CGF.EmitLifetimeEnd(LifetimeSizePtr, RetAddr.getBasePointer()); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why a target hook is needed to just insert an addrspacecast, but this seems to be prior art