-
Notifications
You must be signed in to change notification settings - Fork 349
[BoundsSafety] Reland the miscompilation fix for lvalues binding with temporary locations #11469
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
@swift-ci test llvm |
CI seems to be blocked on rdar://161075623 ([BlueDragon] Build failed, AssertionError: {'CXCursor_LastExpr', 'CXCursor_ForgePtrExpr'} variants are missing.) |
@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.
Is there any behavioral change 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.
@hnrklssn No behavioral change here. This is just to avoid execution order of arguments, which is an unspecified behavior, triggering non-determinism for codegen, and CI failures on other platforms.
clang/lib/CodeGen/CGExpr.cpp
Outdated
|
||
LValue CodeGenFunction::EmitTerminatedByToIndexableExprLValue(const TerminatedByToIndexableExpr *E) { | ||
if (!E->getType()->isPointerTypeWithBounds()) | ||
return EmitUnsupportedLValue(E, "l-value expression"); |
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.
Does Sema guard against this occurring, or is this something that can actually happen in real code?
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.
@hnrklssn Thanks for calling this out. This is not supposed to happen here.
I'll remove it. The assertion from EmitAggExprToLValue
should be sufficient.
These are failing in next (b9b0b72) and unrelated to this change. 10:58:32 ******************** |
95c5ed9
to
250f73c
Compare
@swift-ci test llvm |
@hnrklssn Do you have any other comments? |
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.
nope, LGTM!
… 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)
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 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