diff options
| author | Chris Lattner <sabre@nondot.org> | 2001-09-07 16:42:08 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2001-09-07 16:42:08 +0000 |
| commit | 07e158de3c7399d041debe66244a93801d248896 (patch) | |
| tree | bc7eba3a033382363f7db751f4c736d1af4256ea /llvm/lib/Transforms | |
| parent | 030772df99ed1ac06258fe26cc8eb029558ebfda (diff) | |
| download | bcm5719-llvm-07e158de3c7399d041debe66244a93801d248896.tar.gz bcm5719-llvm-07e158de3c7399d041debe66244a93801d248896.zip | |
* Eliminate constant pool dependancies:
* Eliminate DoRemoveUnusedConstants
llvm-svn: 453
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/DCE.cpp | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/llvm/lib/Transforms/Scalar/DCE.cpp b/llvm/lib/Transforms/Scalar/DCE.cpp index 53b00e1649d..119f92bae4b 100644 --- a/llvm/lib/Transforms/Scalar/DCE.cpp +++ b/llvm/lib/Transforms/Scalar/DCE.cpp @@ -108,31 +108,8 @@ static bool RemoveSingularPHIs(BasicBlock *BB) { return true; // Yes, we nuked at least one phi node } -bool opt::DoRemoveUnusedConstants(SymTabValue *S) { - bool Changed = false; - ConstantPool &CP = S->getConstantPool(); - for (ConstantPool::plane_iterator PI = CP.begin(); PI != CP.end(); ++PI) - Changed |= RemoveUnusedDefs(**PI, ConstPoolDCE()); - return Changed; -} - static void ReplaceUsesWithConstant(Instruction *I) { - // Get the method level constant pool - ConstantPool &CP = I->getParent()->getParent()->getConstantPool(); - - ConstPoolVal *CPV = 0; - ConstantPool::PlaneType *P; - if (!CP.getPlane(I->getType(), P)) { // Does plane exist? - // Yes, is it empty? - if (!P->empty()) CPV = P->front(); - } - - if (CPV == 0) { // We don't have an existing constant to reuse. Just add one. - CPV = ConstPoolVal::getNullConstant(I->getType()); // Create a new constant - - // Add the new value to the constant pool... - CP.insert(CPV); - } + ConstPoolVal *CPV = ConstPoolVal::getNullConstant(I->getType()); // Make all users of this instruction reference the constant instead I->replaceAllUsesWith(CPV); @@ -180,12 +157,14 @@ static void PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) { // WARNING: The entry node of a method may not be simplified. // bool opt::SimplifyCFG(Method::iterator &BBIt) { - assert(*BBIt && (*BBIt)->getParent() && "Block not embedded in method!"); BasicBlock *BB = *BBIt; Method *M = BB->getParent(); + + assert(BB && BB->getParent() && "Block not embedded in method!"); assert(BB->getTerminator() && "Degenerate basic block encountered!"); assert(BB->getParent()->front() != BB && "Can't Simplify entry block!"); + // Remove basic blocks that have no predecessors... which are unreachable. if (pred_begin(BB) == pred_end(BB) && !BB->hasConstantPoolReferences()) { @@ -210,7 +189,7 @@ bool opt::SimplifyCFG(Method::iterator &BBIt) { } delete M->getBasicBlocks().remove(BBIt); return true; - } + } // Check to see if this block has no instructions and only a single // successor. If so, replace block references with successor. @@ -310,8 +289,7 @@ static bool DoDCEPass(Method *M) { } } - // Remove unused constants - return Changed | opt::DoRemoveUnusedConstants(M); + return Changed; } @@ -341,6 +319,5 @@ bool opt::DoDeadCodeElimination(Module *Mod) { } } - while (DoRemoveUnusedConstants(Mod)) Changed = true; return Changed; } |

