-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AddressLowering] Storage root inherits lexical. #61747
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
[AddressLowering] Storage root inherits lexical. #61747
Conversation
Make it clear that it's not a missed case. It changes representation.
The switch_enum_addr consumes its operand so a copy is needed.
@swift-ci please smoke test macOS platform |
a966c1c
to
4ddc754
Compare
@swift-ci please test |
@swift-ci please test macOS platform |
1 similar comment
@swift-ci please test macOS platform |
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.
Can you add the test case in which the payload is a tuple that the pattern match logic needs to destructure?
Should we also have a .sil test case for struct_extract
?
@@ -2884,6 +2884,9 @@ ReturnInst::ReturnInst(SILFunction &func, SILDebugLocation debugLoc, | |||
|
|||
bool OwnershipForwardingMixin::hasSameRepresentation(SILInstruction *inst) { | |||
switch (inst->getKind()) { | |||
// Explicitly list instructions which definitely involve a representation | |||
// change. | |||
case SILInstructionKind::SwitchEnumInst: |
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 practice. Too bad we don't do it elsewhere.
@@ -2776,6 +2776,13 @@ void UseRewriter::visitBeginBorrowInst(BeginBorrowInst *borrow) { | |||
allocStack->setIsLexical(); | |||
return; | |||
} | |||
auto storage = AccessStorageWithBase::compute(address); |
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.
If you're not interested in AccessStorage, you should be able to use getAccessBase
or AccessBase::compute
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.
Oh, perfect! Changed to getAccessBase
and checked propagated the lexical flag to it if its an alloc_stack
and allowed it if it was a function argument. Added a struct extract test case for both an opaque value that needed an alloc_stack and one that was passed in.
When a `begin_borrow [lexical]` is lowered, the lifetime that it describes can't be shortened (or eliminated) when lowering. In some cases, though, there will not be an alloc_stack corresponding directly to the value being borrowed. In these cases, mark the whole aggregate lexical.
4ddc754
to
c766956
Compare
@swift-ci please test |
When a
begin_borrow [lexical]
is lowered, the lifetime that it describes can't be shortened (or eliminated) when lowering. In some cases, though, there will not be an alloc_stack corresponding directly to the value being borrowed.In these cases, mark the whole aggregate lexical.