-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[sil] Add SILBuilder helpers for updating passes to handle both ossa … #21824
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
[sil] Add SILBuilder helpers for updating passes to handle both ossa … #21824
Conversation
@swift-ci smoke test |
include/swift/SIL/SILBuilder.h
Outdated
if (!hasOwnership()) | ||
return v; | ||
if (v.getOwnershipKind().isCompatibleWith(ValueOwnershipKind::Guaranteed)) | ||
return SILValue(); |
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 is this not returning v?
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 is in the PR description I think but should be commented in the code - much easier than doing git blame: "if the value is already guaranteed, return an empty SILValue(). This
is useful since when writing a recursive function it enables one to tell if
one needs to insert an end_borrow or not."
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.
Hmmm... I was looking at this and I discovered that this was actually a thinko in my code that I fixed in a subsequent commit locally. Let me fix this up.
include/swift/SIL/SILBuilder.h
Outdated
/// This allows for recursive code that deals with borrows to only borrow the | ||
/// first time the function is called. It also by returning v when ownership | ||
/// is disabled makes it easy to write code that works on ossa and on non-ossa | ||
/// SIL. |
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 PR / commit message has great documentation that I think should be in the code, easier to grok than just reading this comment, I would incorporate some of that here.
I am going to rip out the begin borrow part of this. I don't need it. I need the rest though. |
…and non-ossa code. Specifically we add a groups of APIs for destructure operations. The destructure helpers are a family of functions built around emitDestructureValueOperation. These in ossa produce destructures and pass the results off to the caller in some manner that hides the internal destructure instruction. In non-ossa, the appropriate projections are created and passed off to the caller.
c100d29
to
3551c43
Compare
@swift-ci smoke test and merge |
3 similar comments
@swift-ci smoke test and merge |
@swift-ci smoke test and merge |
@swift-ci smoke test and merge |
…and non-ossa code.
Specifically we add two groups of APIs: ones for borrows and ones for
destructure.
The borrow helper (emitBeginBorrowOperation) makes it easier to update passes
by:
is useful since when writing a recursive function it enables one to tell if
one needs to insert an end_borrow or not.
The destructure helpers are a family of functions built around
emitDestructureValueOperation. These in ossa produce destructures and pass the
results off to the caller in some manner that hides the internal destructure
instruction. In non-ossa, the appropriate projections are created and passed off
to the caller.