aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-11-27 23:25:44 +0000
committerChris Lattner <sabre@nondot.org>2008-11-27 23:25:44 +0000
commit98991c21ad2df20b92dc13366a3688decc0e6768 (patch)
tree09e3642dfbe94330b501a7c0df94d95add22bacb /lib/Transforms
parent878836b45159c14c6bb5a23b0605474988912b0a (diff)
downloadexternal_llvm-98991c21ad2df20b92dc13366a3688decc0e6768.zip
external_llvm-98991c21ad2df20b92dc13366a3688decc0e6768.tar.gz
external_llvm-98991c21ad2df20b92dc13366a3688decc0e6768.tar.bz2
delete ErasePossiblyDeadInstructionTree, replacing uses of it with
RecursivelyDeleteTriviallyDeadInstructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60196 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp50
1 files changed, 9 insertions, 41 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 5c2f514..9ba7550 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -494,40 +494,8 @@ static bool GatherValueComparisons(Instruction *Cond, Value *&CompVal,
return false;
}
-/// ErasePossiblyDeadInstructionTree - If the specified instruction is dead and
-/// has no side effects, nuke it. If it uses any instructions that become dead
-/// because the instruction is now gone, nuke them too.
-static void ErasePossiblyDeadInstructionTree(Instruction *I) {
- if (!isInstructionTriviallyDead(I)) return;
-
- SmallVector<Instruction*, 16> InstrsToInspect;
- InstrsToInspect.push_back(I);
-
- while (!InstrsToInspect.empty()) {
- I = InstrsToInspect.back();
- InstrsToInspect.pop_back();
-
- if (!isInstructionTriviallyDead(I)) continue;
-
- // If I is in the work list multiple times, remove previous instances.
- for (unsigned i = 0, e = InstrsToInspect.size(); i != e; ++i)
- if (InstrsToInspect[i] == I) {
- InstrsToInspect.erase(InstrsToInspect.begin()+i);
- --i, --e;
- }
-
- // Add operands of dead instruction to worklist.
- for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i)
- if (Instruction *OpI = dyn_cast<Instruction>(*i))
- InstrsToInspect.push_back(OpI);
-
- // Remove dead instruction.
- I->eraseFromParent();
- }
-}
-
-// isValueEqualityComparison - Return true if the specified terminator checks to
-// see if a value is equal to constant integer value.
+/// isValueEqualityComparison - Return true if the specified terminator checks
+/// to see if a value is equal to constant integer value.
static Value *isValueEqualityComparison(TerminatorInst *TI) {
if (SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
// Do not permit merging of large switch instructions into their
@@ -548,8 +516,8 @@ static Value *isValueEqualityComparison(TerminatorInst *TI) {
return 0;
}
-// Given a value comparison instruction, decode all of the 'cases' that it
-// represents and return the 'default' block.
+/// Given a value comparison instruction, decode all of the 'cases' that it
+/// represents and return the 'default' block.
static BasicBlock *
GetValueEqualityComparisonCases(TerminatorInst *TI,
std::vector<std::pair<ConstantInt*,
@@ -666,7 +634,7 @@ static bool SimplifyEqualityComparisonWithOnlyPredecessor(TerminatorInst *TI,
TI->eraseFromParent(); // Nuke the old one.
// If condition is now dead, nuke it.
if (Instruction *CondI = dyn_cast<Instruction>(Cond))
- ErasePossiblyDeadInstructionTree(CondI);
+ RecursivelyDeleteTriviallyDeadInstructions(CondI);
return true;
} else {
@@ -734,7 +702,7 @@ static bool SimplifyEqualityComparisonWithOnlyPredecessor(TerminatorInst *TI,
Cond = dyn_cast<Instruction>(BI->getCondition());
TI->eraseFromParent(); // Nuke the old one.
- if (Cond) ErasePossiblyDeadInstructionTree(Cond);
+ if (Cond) RecursivelyDeleteTriviallyDeadInstructions(Cond);
return true;
}
return false;
@@ -850,7 +818,7 @@ static bool FoldValueComparisonIntoPredecessors(TerminatorInst *TI) {
Pred->getInstList().erase(PTI);
// If the condition is dead now, remove the instruction tree.
- if (DeadCond) ErasePossiblyDeadInstructionTree(DeadCond);
+ if (DeadCond) RecursivelyDeleteTriviallyDeadInstructions(DeadCond);
// Okay, last check. If BB is still a successor of PSI, then we must
// have an infinite loop case. If so, add an infinitely looping block
@@ -1425,7 +1393,7 @@ static bool SimplifyCondBranchToTwoReturns(BranchInst *BI) {
BI->eraseFromParent();
if (Instruction *BrCondI = dyn_cast<Instruction>(BrCond))
- ErasePossiblyDeadInstructionTree(BrCondI);
+ RecursivelyDeleteTriviallyDeadInstructions(BrCondI);
return true;
}
@@ -2146,7 +2114,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
// Erase the potentially condition tree that was used to computed the
// branch condition.
- ErasePossiblyDeadInstructionTree(Cond);
+ RecursivelyDeleteTriviallyDeadInstructions(Cond);
return true;
}
}