-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[NFC] Bridging and utilities for SwiftCompilerSources required by lifetime dependence utilities. #70485
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 |
@swift-ci test |
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.
lgtm, just a few minor comments and questions
|
||
extension InstructionRange { | ||
// TODO: Add direct support for phis or function args. This workaround will be problematic when used in a pass that mutates the block. | ||
static func getRepresentativeInstruction(for value: Value) -> Instruction { |
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.
For what should this be used?
Is there a better name for this utility? At least you should add a comment
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.
This is a terrible hack because InstructionRange
doesn't support ranges that start at block boundaries, and I just don't have time to design that right now. It's incorrect to say the a block argument begins at the first instruction. The first instruction should instead be seen as within the range and we should be able to insert instructions above it.
(Note that we also need some kind of MultiInstructionRange that supports multiple begin
values)
The key point here is that I do not want to add an initializer that takes a Value
because that would be misleading. If someone needs this hack, they should know what they're doing first.
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 converted getRepresentativeInstruction
to an initializer since we don't plan on modeling instruction ranges that start at block boundaries.
import SILBridging | ||
|
||
/// SIL function convention based on the AST function type and SIL stage. | ||
public struct FunctionConvention { |
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.
How is this different or the same as the APIs we have in Function
, e.g. Function.numArguments
, etc.?
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 need to query the conventions of a function type without knowing what SIL function will be called. The Function
interface should call down to 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.
Migrating Function and ApplySite to FunctionConventions is a separate PR: #70535
Bridge information about the AST function type that does not require a SIL function body. Support querying the function type's ResultInfo.
@swift-ci smoke test |
@swift-ci test |
This test seems to be spuriously failing on linux: |
@swift-ci smoke test linux |
Straightforward utilities needed for lifetime dependence:
Cherry-picked from Draft PR: #70460
Previously reviewed by @nate-chandler