Skip to content

Commit

Permalink
Fixes an use-after-erase issue in sil-combine.
Browse files Browse the repository at this point in the history
Don't try to restore the insertion point of a SILBuilder, as this instruction may have been erased in the meantime.
  • Loading branch information
swiftix committed Nov 12, 2015
1 parent 0e5d37c commit 4fdec4e
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions lib/SILPasses/SILCombiner/SILCombinerMiscVisitors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,6 @@ SILInstruction *SILCombiner::visitAllocStackInst(AllocStackInst *AS) {
break;
}

// Save the original insertion point.
auto OrigInsertionPoint = Builder.getInsertionPoint();

// If the only users of the alloc_stack are alloc, destroy and
// init_existential_addr then we can promote the allocation of the init
// existential.
Expand All @@ -265,7 +262,6 @@ SILInstruction *SILCombiner::visitAllocStackInst(AllocStackInst *AS) {
Builder.createDestroyAddr(DA->getLoc(), SILValue(ConcAlloc, 1))
->setDebugScope(DA->getDebugScope());
eraseInstFromFunction(*DA);

}
if (auto *DS = dyn_cast<DeallocStackInst>(Op->getUser())) {
Builder.setInsertionPoint(DS);
Expand All @@ -276,8 +272,6 @@ SILInstruction *SILCombiner::visitAllocStackInst(AllocStackInst *AS) {
}

eraseInstFromFunction(*AS);
// Restore the insertion point.
Builder.setInsertionPoint(OrigInsertionPoint);
}

// Remove a dead live range that is only copied into.
Expand Down Expand Up @@ -317,9 +311,6 @@ SILInstruction *SILCombiner::visitAllocStackInst(AllocStackInst *AS) {
eraseInstFromFunction(*Inst);
}
eraseInstFromFunction(*AS);

// Restore the insertion point.
Builder.setInsertionPoint(OrigInsertionPoint);
}

return nullptr;
Expand Down

0 comments on commit 4fdec4e

Please sign in to comment.