-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Comment on why we can't replace copy_addr instructions with moves in arc-inert blocks #5138
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
@gottesmm Can you please review? |
@swift-ci Please smoke test |
Why does it have to be ARC-inert? It should always be possible to break a |
@jckarter That is not what is happening here. What is happening here is that we are changing copy_addr in blocks that we know are leaking to just be moves. |
The transformation here is always valid; |
@shajrawi Sorry for the delay. I am reviewing this now. |
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 we can make this even more aggressive. Given that we are always going to leak in these blocks, we can also ignore:
copy_addr [take] %0 to %1
!isa<ReleaseValueInst>(I) && !isa<DestroyAddrInst>(I)) | ||
if (!isa<StrongReleaseInst>(I) && !isa<UnownedReleaseInst>(I) && | ||
!isa<ReleaseValueInst>(I) && !isa<DestroyAddrInst>(I) && | ||
!isa<CopyAddrInst>(I)) |
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.
Maybe refactor this query into a helper function?
} | ||
|
||
// Add moves for every copy_addr | ||
for (auto I : InstsToReplace) { |
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.
May be good to make it clear that this is a pointer by making it an auto *
// Add moves for every copy_addr | ||
for (auto I : InstsToReplace) { | ||
SILBuilderWithScope Builder(I); | ||
auto CAI = cast<CopyAddrInst>(I); |
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 you also make this an auto *.
auto CAI = cast<CopyAddrInst>(I); | ||
assert(CAI && "Expected CopyAddrInst in InstsToReplace set"); | ||
auto Loc = CAI->getLoc(); | ||
auto LI = Builder.createLoad(Loc, CAI->getSrc()); |
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.
Also this please make an auto * ; ).
The reason why we do not want to eliminate retains is we want to make sure that we fail at the actual program termination point, not before. There is a possibility where we could by removing the retain change a balanced retain count to be unbalanced resulting in us touching a deallocated object. In contrast, removing a release just makes us leak even more, which we are fine with. |
Changing Again, |
0e26196
to
b3740ad
Compare
@swift-ci Please smoke test |
Linux smoke test failed for no fault of this PR: will re-run |
@swift-ci Please smoke test |
Joe, can we talk about this tomorrow in person? |
@jckarter I mean ; ) |
…es in ARC-inert BBs
b3740ad
to
13b7bd5
Compare
@swift-ci Please smoke test |
radar rdar://problem/24011383
This concludes this radar by adding a comment on why copy_addr instructions can't be turned into moves in simplifyProgramTerminationBlock()