aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/DCE.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-09-07 16:42:08 +0000
committerChris Lattner <sabre@nondot.org>2001-09-07 16:42:08 +0000
commit2f11a9ded395c8aded6300cbd12602d33e697259 (patch)
tree2a9ec8299da9caa7d5c5790a970fc75969b79b80 /lib/Transforms/Scalar/DCE.cpp
parent9b644cc62781d23d206f536f2656c235ab6d84aa (diff)
downloadexternal_llvm-2f11a9ded395c8aded6300cbd12602d33e697259.zip
external_llvm-2f11a9ded395c8aded6300cbd12602d33e697259.tar.gz
external_llvm-2f11a9ded395c8aded6300cbd12602d33e697259.tar.bz2
* Eliminate constant pool dependancies:
* Eliminate DoRemoveUnusedConstants git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@453 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/DCE.cpp')
-rw-r--r--lib/Transforms/Scalar/DCE.cpp35
1 files changed, 6 insertions, 29 deletions
diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp
index 53b00e1..119f92b 100644
--- a/lib/Transforms/Scalar/DCE.cpp
+++ b/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;
}