-
Notifications
You must be signed in to change notification settings - Fork 10.5k
LifetimeDependenceScopeFixup: _read accessor: extend temporaries #80848
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 |
|
||
extension InstructionRange { | ||
enum PathOverlap { | ||
case containsPath |
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.
It would be nice to add some comments, e.g.
// range: ---
// | pathBegin
// | |
// | pathEnd
// ---
case containsPath
// range: ---
// | pathBegin
// --- |
// pathEnd
//
case containsBegin
} | ||
if block == pathBegin.parentBlock { | ||
let endInBlock = block == pathEnd.parentBlock ? pathEnd : block.terminator | ||
for inst in ReverseInstructionList(first: endInBlock) { |
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.
you could use the Instruction.dominatesInSameBlock
utility for this.
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.
I restructured the code slightly and added comments and test cases explaining why this isn't as simple as a dominance check (the loop implemented here is actually simpler and more efficient than using multiple dominance checks)
return .disjoint | ||
} | ||
} | ||
// fallthru: pathBegin was not reached |
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.
Can this fall-through really happen? Shouldn't the loop always find the pathBegin
instruction?
If so, maybe change this to a fatalError
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.
restructured and commented to make it clear how this case can happen.
SwiftCompilerSources/Sources/Optimizer/Utilities/LocalVariableUtils.swift
Outdated
Show resolved
Hide resolved
Fixes rdar://148540048 (Assigning span value to `_` results in an incorrect escape diagnostic)
Refactor VariableIntroducerUseDefWalker into a general LifetimeDependenceUseDefWalker for use with LifetimeDependenceScopeFixup.
We sometimes use LocalVariableUtils to analyze temporary storage in which the store_borrow is not already enclosed by an access scope.
Add support for extending owned temporary values in addition to access scopes and borrow scopes. Required for _read accessors in which the coroutine depends on an owned value.
Fixes rdar://149226564 (Compiler crash with non-escapable storing another non-escapable and having a deinit)
@swift-ci smoke test |
1 similar comment
@swift-ci smoke test |
macOS timed out when setting up the repos |
@swift-ci smoke test macOS |
Add support for extending owned temporary values in addition to access scopes and borrow scopes. Required for _read accessors in which the coroutine depends on an owned value.
Fix unidentified LifetimeDependence.Scope initialization.
Fixes rdar://148540048 (Assigning span value to
_
results in an incorrect escape diagnostic)Fixes rdar://149226564 (Compiler crash with non-escapable storing another
non-escapable and having a deinit)