summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-11-01 05:55:29 +0000
committerChris Lattner <sabre@nondot.org>2001-11-01 05:55:29 +0000
commit04648a4cc6cd1a98ba51670389e51979f82c154e (patch)
tree2ec9a7891e00c081b5d6b8889a9b912d893feaa4 /llvm/lib/Transforms
parent977f0044fc2715a7b7d37ee250e9a408c350367f (diff)
downloadbcm5719-llvm-04648a4cc6cd1a98ba51670389e51979f82c154e.tar.gz
bcm5719-llvm-04648a4cc6cd1a98ba51670389e51979f82c154e.zip
Simplify DCE code a lot
llvm-svn: 1079
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/DCE.cpp31
1 files changed, 5 insertions, 26 deletions
diff --git a/llvm/lib/Transforms/Scalar/DCE.cpp b/llvm/lib/Transforms/Scalar/DCE.cpp
index e089525eca4..71a7f5ae26b 100644
--- a/llvm/lib/Transforms/Scalar/DCE.cpp
+++ b/llvm/lib/Transforms/Scalar/DCE.cpp
@@ -34,33 +34,12 @@
#include "llvm/Assembly/Writer.h"
#include <algorithm>
-struct ConstPoolDCE {
- enum { EndOffs = 0 };
- static bool isDCEable(const ConstPoolVal *CPV) {
- // TODO: The bytecode writer requires that all used types are in the
- // constant pool for the current method. This is messy and is really
- // irritating. FIXME
- return CPV->getType() != Type::TypeTy; // Don't DCE Type plane constants!
- }
-};
-
-struct BasicBlockDCE {
- enum { EndOffs = 1 };
- static bool isDCEable(const Instruction *I) {
- return !I->hasSideEffects();
- }
-};
-
-
-template<class Container, class DCEController>
-static bool RemoveUnusedDefs(Container &Vals, DCEController DCEControl) {
+static bool RemoveUnusedDefs(BasicBlock::InstListType &Vals) {
bool Changed = false;
- int Offset = DCEController::EndOffs;
-
- for (typename Container::iterator DI = Vals.begin();
- DI != Vals.end()-Offset; ) {
+ for (BasicBlock::InstListType::iterator DI = Vals.begin();
+ DI != Vals.end()-1; ) {
// Look for un"used" definitions...
- if ((*DI)->use_empty() && DCEController::isDCEable(*DI)) {
+ if ((*DI)->use_empty() && !(*DI)->hasSideEffects()) {
// Bye bye
//cerr << "Removing: " << *DI;
delete Vals.remove(DI);
@@ -272,7 +251,7 @@ static bool DoDCEPass(Method *M) {
// Loop through now and remove instructions that have no uses...
for (BBIt = M->begin(); BBIt != BBEnd; ++BBIt) {
- Changed |= RemoveUnusedDefs((*BBIt)->getInstList(), BasicBlockDCE());
+ Changed |= RemoveUnusedDefs((*BBIt)->getInstList());
Changed |= RemoveSingularPHIs(*BBIt);
}
OpenPOWER on IntegriCloud