-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[region-based-isolation] Stack of smaller fixes before a larger fix #69342
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
[region-based-isolation] Stack of smaller fixes before a larger fix #69342
Conversation
Just a helper that calls getASTType()->isActorType(). I also updated the two places in SNS that we use this.
This is the correct thing to do since the header is in SILOptimizer. That being said the reason why I am doing this is that I want to add a command line flag to PartitionUtils.h to allow for more verbose debug output and the flag's definition will be in the SILOptimizer library. So this is just a little cleanup that follows from that.
One needs to pass in the explicit flag to enable this as well as -debug-flag=send-non-sendable. This makes it easier to debug the affect of applying specific partition ops.
We can just pass in an ArrayRef here. I missed this inefficiency when I was going through the pass earlier.
If we consume a value in a block and then reinitialize it before the end of the block, this assert will always fail.
SILValues always have a SILType... so just use getType().isAddress().
…rather than passing in callbacks. This indirection is premature abstraction since the only two places we actually use these callbacks is to print the accumulated output and to emit our errors. With this change, I was able to simplify how print works and inline in the actual diagnostic emission making it easier to understand the code. Additionally, in a subsequent commit I am going to need to ensure that we do not emit an error here if the source cause of our error is due to an actor. To implement that I would need to change tryDiagnoseAsCallsite to signal to the machinery that it needs to not emit requires and then fail further up as well. Given that there really wasn't a need for this abstraction in the first place and the amount of munging needed to express this, I decided to just make this change and make it easier. If we truly need this flexibility, we can always add it back later.
…me -> Transfer. I just missed these.
@swift-ci smoke test |
|
||
bool containsOp(const PartitionOp& op) { | ||
for (auto [_, vec] : consumeOps) | ||
for (auto [_, vec] : transferOps) |
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 this and isValid()
could be further simplified to use llvm::any_of
and llvm::is_contained
as a follow-up.
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.
@xedin TBH, I really dislike containsOp. It would be much better to just have a separate set like thing. So we can do quick PartitionOp checks. But I am going to leave it in for now since this only runs when we emit error diagnostics and fail.
class ConsumedReason { | ||
std::map<unsigned, std::vector<PartitionOp>> consumeOps; | ||
class TransferredReason { | ||
std::map<unsigned, std::vector<PartitionOp>> transferOps; |
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.
A good use for std::multimap
auto isolationCrossing = apply->getIsolationCrossing(); | ||
if (!isolationCrossing) { | ||
assert(false && "ApplyExprs should be transferring only if" | ||
" they are isolation crossing"); |
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 just
assert(isolationCrossing && "ApplyExprs should be transferring only if"
" they are isolation crossing");
auto argExpr = transferOp.getSourceExpr(); | ||
if (!argExpr) | ||
assert(false && | ||
"sourceExpr should be populated for ApplyExpr consumptions"); |
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 this should be assert(argExpr && ...)
instead.
@xedin I am going to make these changes in a follow on commit. Thanks! |
@@ -878,6 +878,8 @@ class SILType { | |||
|
|||
bool isMarkedAsImmortal() const; | |||
|
|||
bool isActor() const { return getASTType()->isActorType(); } |
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 name it isActorType() for consistency with the CanType method?
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.
My thought was that we already know it is a type, so no point in adding that redundant text.
// transferred. Additionally, a list of "nonconsumable" indices can be passed | ||
// in along with a handleConsumeNonConsumable closure. In the event that a | ||
// region containing one of the nonconsumable indices is transferred, the | ||
// closure will be called with the offending Consume. |
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.
with the offending Transfer?
@@ -246,7 +246,7 @@ struct PartitionOpBuilder { | |||
|
|||
void addTransfer(SILValue value, Expr *sourceExpr = nullptr) { | |||
assert(valueHasID(value) && | |||
"consumed value should already have been encountered"); | |||
"transfered value should already have been encountered"); |
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.
Typo: transferred
…d87d1532aff686 [region-isolation] Follow up changes to #69342
This PR contains a small set of fixes that are chopped off a larger PR. Most are NFC or small performance fixes. I am chopping it off to make reviewing the other PR easier.
The specific PRs are: