-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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: Verify invariants of async_continuation instructions. #34210
Conversation
jckarter
commented
Oct 6, 2020
- Enforce types of continuations and resume/error BBargs for await
- Can't access the continuation again or exit the function mid-suspend
@swift-ci Please test |
Build failed |
Build failed |
lib/SIL/Verifier/SILVerifier.cpp
Outdated
isAddressForm = false; | ||
throws = gaci->throws(); | ||
loweredResumeTy = gaci->getLoweredResumeType(); | ||
} else if (auto gacia = dyn_cast<GetAsyncContinuationAddrInst>(cont)) { |
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 we make a base class between these?
lib/SIL/Verifier/SILVerifier.cpp
Outdated
// Map of all the get_async_continuation[_addr] instructions in async | ||
// functions, for checking suspendable contexts. | ||
llvm::DenseMap<SILFunction *, SmallVector<SingleValueInstruction *, 2>> | ||
AsyncContinuationSources; |
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 think you can just do this analysis in checkFlowSensitiveRules
, and then you won't need to kindof reinvent it.
4f872bf
to
9d44102
Compare
@swift-ci Please test |
@rjmccall @theblixguy Thanks for the feedback! How's this look now? |
Thanks for applying the |
Build failed |
@swift-ci Please test OS X |
lib/SIL/IR/SILInstruction.cpp
Outdated
@@ -1519,6 +1519,21 @@ MultipleValueInstruction *MultipleValueInstructionResult::getParent() { | |||
return reinterpret_cast<MultipleValueInstruction *>(value); | |||
} | |||
|
|||
/// Returns true if evaluation of this node may cause suspension of an | |||
/// async task. | |||
bool SILNode::maySuspend() const { |
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.
Should this just be on SILInstruction
? Not sure there's any situation where it makes sense to ask this of a 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.
Well, it doesn't seem harmful to put it on SILNode either, to save a cast if all you do have is a 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.
I guess my question is whether it ever makes sense to just ask this of a SILValue. It's never a property of a value, just of an instruction that can produce a value. If you're asking a SILValue you're almost certainly doing it wrong.
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.
Alright, I'll move it to SILInstruction.
9d44102
to
5b1ddf6
Compare
Thanks for checking my work. I fixed the logic issues; how's this look now? |
@swift-ci Please test |
Build failed |
Restarting doomed Linux tests. @swift-ci please test Linux platform |
Logic fixes look good, thanks. |
- Enforce types of continuations and resume/error BBargs for await - Can't access the continuation again or exit the function mid-suspend
@swift-ci Please test |
Build failed |
5b1ddf6
to
3364c51
Compare
@swift-ci Please test OS X |
Build failed |
@swift-ci Please test OS X |