diff options
author | Chris Lattner <sabre@nondot.org> | 2002-05-07 18:10:55 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-05-07 18:10:55 +0000 |
commit | 560da70f8c9ebc0bef1b633ca93f1b176a6f41a2 (patch) | |
tree | cbc49f8767292bbee38e8f0795aebe16d70e2af7 /llvm/lib/Transforms/Scalar/DCE.cpp | |
parent | 6a515851555bb7328209a21abf0f7ad2b3841aea (diff) | |
download | bcm5719-llvm-560da70f8c9ebc0bef1b633ca93f1b176a6f41a2.tar.gz bcm5719-llvm-560da70f8c9ebc0bef1b633ca93f1b176a6f41a2.zip |
Factor code out to the TransformUtils library
llvm-svn: 2516
Diffstat (limited to 'llvm/lib/Transforms/Scalar/DCE.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/DCE.cpp | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/llvm/lib/Transforms/Scalar/DCE.cpp b/llvm/lib/Transforms/Scalar/DCE.cpp index 5983910c182..ec9a387c18f 100644 --- a/llvm/lib/Transforms/Scalar/DCE.cpp +++ b/llvm/lib/Transforms/Scalar/DCE.cpp @@ -10,31 +10,12 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Scalar/DCE.h" +#include "llvm/Transforms/Utils/Local.h" +#include "llvm/Instruction.h" #include "llvm/Pass.h" -#include "llvm/InstrTypes.h" -#include "llvm/Function.h" #include "llvm/Support/InstIterator.h" #include <set> -static inline bool isInstDead(Instruction *I) { - return I->use_empty() && !I->hasSideEffects() && !isa<TerminatorInst>(I); -} - -// dceInstruction - Inspect the instruction at *BBI and figure out if it's -// [trivially] dead. If so, remove the instruction and update the iterator -// to point to the instruction that immediately succeeded the original -// instruction. -// -bool dceInstruction(BasicBlock::InstListType &BBIL, - BasicBlock::iterator &BBI) { - // Look for un"used" definitions... - if (isInstDead(*BBI)) { - delete BBIL.remove(BBI); // Bye bye - return true; - } - return false; -} - //===----------------------------------------------------------------------===// // DeadInstElimination pass implementation // @@ -95,7 +76,7 @@ bool DCE::runOnFunction(Function *F) { Instruction *I = WorkList.back(); WorkList.pop_back(); - if (isInstDead(I)) { // If the instruction is dead... + if (isInstructionTriviallyDead(I)) { // If the instruction is dead... // Loop over all of the values that the instruction uses, if there are // instructions being used, add them to the worklist, because they might // go dead after this one is removed. |