remove the RemoveDeadAddressingInstructions helper, in favor of

the more fully featured "recursivelyDeleteTriviallyDeadInstructions".


Swift SVN r10724
This commit is contained in:
Chris Lattner
2013-12-02 01:47:53 +00:00
parent f7c89703ce
commit 8640266bf7
2 changed files with 6 additions and 34 deletions

View File

@@ -115,21 +115,6 @@ static void InsertCFGDiamond(SILValue Cond, SILLocation Loc, SILBuilder &B,
}
/// Remove dead tuple_element_addr and struct_element_addr chains - only.
static void RemoveDeadAddressingInstructions(SILValue Pointer) {
if (!Pointer.use_empty()) return;
SILInstruction *I = dyn_cast<SILInstruction>(Pointer);
if (I == 0 ||
!(isa<TupleElementAddrInst>(Pointer) ||
isa<StructElementAddrInst>(Pointer)))
return;
Pointer = I->getOperand(0);
I->eraseFromParent();
RemoveDeadAddressingInstructions(Pointer);
}
//===----------------------------------------------------------------------===//
// Per-Element Promotion Logic
//===----------------------------------------------------------------------===//
@@ -729,7 +714,8 @@ void LifetimeChecker::processNonTrivialRelease(unsigned ReleaseID) {
if (Availability.isAllNo()) {
SILValue Addr = Release->getOperand(0);
Release->eraseFromParent();
RemoveDeadAddressingInstructions(Addr);
if (auto *AddrI = dyn_cast<SILInstruction>(Addr))
recursivelyDeleteTriviallyDeadInstructions(AddrI);
Releases[ReleaseID] = nullptr;
return;
}
@@ -1052,7 +1038,8 @@ handleConditionalDestroys(SILValue ControlVariableAddr) {
// Finally, now that the destroy_addr is handled, remove the original
// destroy.
DAI->eraseFromParent();
RemoveDeadAddressingInstructions(Addr);
if (auto *AddrI = dyn_cast<SILInstruction>(Addr))
recursivelyDeleteTriviallyDeadInstructions(AddrI);
}
}