Skip to content

Commit 13b7bd5

Browse files
author
Joe Shajrawi
committed
Add a discussion that sums-up why we can’t replace copy_addr with moves in ARC-inert BBs
1 parent 9af74fe commit 13b7bd5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/SILOptimizer/Transforms/SimplifyCFG.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3419,6 +3419,16 @@ bool SimplifyCFG::simplifyProgramTerminationBlock(SILBasicBlock *BB) {
34193419
bool Changed = false;
34203420
llvm::SmallPtrSet<SILInstruction *, 4> InstsToRemove;
34213421
for (auto &I : *BB) {
3422+
// We can only remove the instructions below from the ARC-inert BB
3423+
// We *can't* replace copy_addr with move instructions:
3424+
// If the copy_addr was [take] [initialization]:
3425+
// * previous passes would have replaced it with moves
3426+
// If the copy_addr contains [initialization]:
3427+
// * nothing we can do - the target address is invalid
3428+
// Else, i.e. the copy_addr was [take] assignment, it is not always safe:
3429+
// The type being operated on might contain weak references,
3430+
// or other side references - We'll corrupt the weak reference table
3431+
// if we fail to release the old value.
34223432
if (!isa<StrongReleaseInst>(I) && !isa<UnownedReleaseInst>(I) &&
34233433
!isa<ReleaseValueInst>(I) && !isa<DestroyAddrInst>(I))
34243434
continue;

0 commit comments

Comments
 (0)