-
Notifications
You must be signed in to change notification settings - Fork 349
[BoundsSafety] Don't bind lvalues with temporary locations #10969
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
Conversation
This should fix a miscompilation bug found during adoption. When a base is lvalue and is wrapped in OVE, the compiler incorrectly creates a temporary and maps its address to the lvalue instead of the actual address of the lvalue. The solution is to emit lvalue directly instead of creating extra temporary. rdar://146329029
@swift-ci test llvm |
…ing in order to avoid non-determinism The execution order of arguments is unspecified in C++. Directly passing calls that emit code as arguments caused non-deterministic order in the generated instructions and test failures in different platforms.
@swift-ci test llvm |
1 similar comment
@swift-ci test llvm |
ElemBitCast); | ||
: nullptr; | ||
|
||
EmitWidePointerToDest(E->getType(), Ptr, Upper, Lower, ElemBitCast); |
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.
@patrykstefanski I suspect this was what caused the Linux code test failures where getelementptr
instructions were emitted in a different order on Linux.
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.
Nice find. After landing this we should try re-enabling the tests we disabled on Linux.
for (auto *OVE : MSE->opaquevalues()) { | ||
if (CodeGenFunction::OpaqueValueMappingData::shouldBindAsLValue(OVE)) { | ||
RValue PtrRV = EmitAnyExpr(OVE->getSourceExpr()); | ||
LValue LV = MakeAddrLValue(PtrRV.getAggregateAddress(), OVE->getType()); |
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.
Which thing is the temporary here?
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.
The EmitAnyExpr()
function creates a temporary slot for aggregates.
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.
Maybe worth explicitly mentioning that in the commit message for clarity.
@swift-ci test llvm |
Test failures seem unrelated to this change 12:53:24 ******************** |
… temporary locations (#11469) - Solution from #10969: This should fix a miscompilation bug found during adoption. When a base is lvalue and is wrapped in OVE, the compiler created a temporary and incorrectly mapped the temporary's address as the lvalue instead of the actual address of the lvalue. The solution is to emit lvalue directly instead of creating extra temporary. - Issue with the solution: The issue #10969 got originally reverted due "error: cannot compile this l-value expression yet" occurred when __terminated_by_to_indexable is wrapped in an OVE. - Fix for the new issue with __terminated_by_to_indexable: The fix is to implement "TerminatedByToIndexableExprLValue" so the codegen can also emit as if it's an lvalue. rdar://146329029
… temporary locations (#11469) - Solution from #10969: This should fix a miscompilation bug found during adoption. When a base is lvalue and is wrapped in OVE, the compiler created a temporary and incorrectly mapped the temporary's address as the lvalue instead of the actual address of the lvalue. The solution is to emit lvalue directly instead of creating extra temporary. - Issue with the solution: The issue #10969 got originally reverted due "error: cannot compile this l-value expression yet" occurred when __terminated_by_to_indexable is wrapped in an OVE. - Fix for the new issue with __terminated_by_to_indexable: The fix is to implement "TerminatedByToIndexableExprLValue" so the codegen can also emit as if it's an lvalue. rdar://146329029 (cherry picked from commit 04da1af)
… temporary locations (#11469) (#11504) - Solution from #10969: This should fix a miscompilation bug found during adoption. When a base is lvalue and is wrapped in OVE, the compiler created a temporary and incorrectly mapped the temporary's address as the lvalue instead of the actual address of the lvalue. The solution is to emit lvalue directly instead of creating extra temporary. - Issue with the solution: The issue #10969 got originally reverted due "error: cannot compile this l-value expression yet" occurred when __terminated_by_to_indexable is wrapped in an OVE. - Fix for the new issue with __terminated_by_to_indexable: The fix is to implement "TerminatedByToIndexableExprLValue" so the codegen can also emit as if it's an lvalue. rdar://146329029 (cherry picked from commit 04da1af)
This should fix a miscompilation bug found during adoption. When a base is lvalue and is wrapped in OVE, the compiler created a temporary and incorrectly mapped the temporary's address as the lvalue instead of the actual address of the lvalue.
The solution is to emit lvalue directly instead of creating extra temporary.
rdar://146329029