-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Enable ArrayElementValuePropagation on ownership SIL #34549
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 |
Build failed |
return std::next(cast<SingleValueInstruction>(val)->getIterator()); | ||
} | ||
if (isa<SILArgument>(val)) { | ||
return cast<SILArgument>(val)->getParentBlock()->begin(); |
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 just a quick drive by, but there is an API that already supports this: getDefiningInsertionPt.
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 see why this is a little different.
// Because we are creating copy_value in ossa, and the source may have been | ||
// taken previously. So our insert point for copy_value is immediately after | ||
// V, where we can be sure it is live. | ||
auto InsertPt = V->getFunction()->hasOwnership() |
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 this to always do this? Then we have one implementation? I haven't thought through it maybe there is a reason not to.
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 could, but the retain would be much earlier than when we need, and I was thinking it may effect arc optimizations.
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!
I just have 2 minor comments.
@@ -105,7 +105,6 @@ struct SemanticARCOpts : SILFunctionTransform { | |||
if (!f.getModule().getOptions().EnableOSSAOptimizations || | |||
!f.hasOwnership()) | |||
return; | |||
|
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.
Is this deleted empty line intention?
SILValue CopiedVal = | ||
SILBuilderWithScope(InsertPt.getValue()) | ||
.emitCopyValueOperation(SemanticsCall->getLoc(), V); | ||
SemanticsCall->replaceAllUsesWith(CopiedVal); | ||
} else { | ||
auto Dest = SemanticsCall->getArgument(0); |
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 remove this else-branch completely. It stems from a time where the specializations of getElement did return an indirect result, even for loadable types. This should not be the case anymore. You can just bail if !hasGetElementDirectResult().
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.
Fixed this.
a24b232
to
483321c
Compare
@swift-ci smoke test and merge |
No description provided.