-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Ownership support for LICM #84045
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
Ownership support for LICM #84045
Conversation
865d153
to
9706745
Compare
@swift-ci Please smoke test |
@swift-ci apple silicon benchmark |
@swift-ci Please smoke test |
@swift-ci apple silicon benchmark |
@swift-ci Please test |
@swift-ci Please Test Source Compatibility Release |
@swift-ci Please smoke test |
@swift-ci apple silicon benchmark |
@swift-ci Please smoke test |
@swift-ci apple silicon benchmark |
@swift-ci Please Test Source Compatibility Release |
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!
for exitBlock in loop.exitBlocks { | ||
assert(exitBlock.hasSinglePredecessor, "Exiting edge should not be critical.") | ||
|
||
if let createdEndBorrow { |
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.
Looks like a few more lines to clone instead of createEndBorrow
for every exitBlock
. Out of curiosity, why clone?
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 wanted to handle multiple loop exit blocks similarly as in sink
, where move
is followed by copy
on remaining exit blocks. Though here, I think you’re right, it’s better to just use createEndBorrow
. I changed it.
_ context: FunctionPassContext | ||
) -> Bool { | ||
guard endInstructions.allSatisfy({ loop.contains(block: $0.parentBlock)}) else { | ||
guard endInstructions.allSatisfy({ loop.contains(block: $0.parentBlock) && !($0 is TermInst) }) else { |
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.
What's an example of a TermInst
that is a scope ending instruction? Do unreachable
s and other terminators along the availability boundary show up as scope ending users?
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 problem here is with branching instructions with phi parameters. They can be considered as scope ending instructions, but it’s not possible to hoist them.
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.
Ah, right. Thanks.
let exitBlocks = loop.exitBlocks | ||
var changed = false | ||
|
||
for exitBlock in exitBlocks { |
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.
Why not sink instructions into dead-end blocks? Once value lifetimes are "complete", scope-ending instructions will be required in such dead-ends. If sinking them into dead-ends is causing a problem, though, ensuring such values' lifetimes are complete can be addressed later on.
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.
We’ve encountered quite a few bugs when trying to sink instructions into dead-ends, which I believe were primarily caused by other lifetimes not being ended properly there. I think it should be an easy fix in the future though, just removing this check.
@swift-ci Please smoke test |
@swift-ci Please test |
84a24a8
to
0b75a81
Compare
@swift-ci Please smoke test |
@swift-ci Please test |
@swift-ci Please test macOS Platform |
@swift-ci Please test Apple Silicon |
@swift-ci Please smoke test |
@swift-ci Please test |
Hello, this PR appears to have regressed the bootstrapping bots resulting in a compiler SIL verification failure:
|
Thanks. I've opened a reversion PR here: #84348 |
Revert "Merge pull request #84045 from MAJKFL/new-sil-licm-pass-copy-…
…pass-copy-ownership" This reverts commit d2cd281.
This PR enables the new LICM pass to properly handle values with ownership. It adds support for the following instructions:
load_borrow
store [init]
load [take]
load [copy]
begin_borrow
store_borrow
begin_apply
store [assign]