-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Improve @guaranteed args handling in ARCSequenceOpts #33267
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 benchmark |
Performance: -O
Code size: -OPerformance: -Osize
Code size: -OsizePerformance: -Onone
Code size: -swiftlibsHow to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
@swift-ci test |
Build failed |
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.
Thanks!!! Just some comment clarification feedback because this code is really hard to makes sense of.
if (!mayDecrementRefCount(PotentialGuaranteedUser, getRCRoot(), AA)) { | ||
return false; | ||
} | ||
|
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 it would be more clear if the comment explained that by returning, we allow handlePotentialUser
to treat this like a normal use and transition to MightBeUsed
It's really too bad that we need to check handlePotentialDecrement
again after this, because it's expensive (and confusing). But these helpers are really contorted and I don't know how to fix it.
if (!mayDecrementRefCount(PotentialGuaranteedUser, getRCRoot(), AA)) { | ||
return false; | ||
} | ||
|
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.
Same feedback on the comment applies here.
e38e6ec
to
de0cc6f
Compare
@swift-ci test |
@guaranteed args are treated conservatively in ARCSequenceOpts. A function call with a @guaranteed arg is assumed to decrement refcount of the @guaranteed arg. With this change, use swift::mayDecrementRefCount which uses EscapeAnalysis to determine if we need to transition conservatively at the instruction being visited.
Build failed |
de0cc6f
to
d172129
Compare
Build failed |
@swift-ci test linux platform |
Build failed |
@guaranteed args are treated conservatively in ARCSequenceOpts. A function call with a @guaranteed arg is assumed to decrement refcount of the @guaranteed arg.
handleGuaranteedUser
transitions conservatively from aDecrement
refcount state toMightBeDecremented
refcount state on a guaranteed use. Since an apply with a guaranteed arg that does not escape cannot decrement the refcount. This conservative transition is unnecessary. For such cases where the instruction being visited cannot decrement the refcount we should fallback tohandleUser
which correctly transitions fromDecrement
refcount state toMightBeUsed
for uses where refcount cannot be decremented.With this change, use
swift::mayDecrementRefCount
which uses EscapeAnalysis to determine if we need to transition conservatively at the instruction being visited.