Move ConstantFP construction back to the 2.5-ish API.
[oota-llvm.git] / lib / Transforms / Scalar / ADCE.cpp
index aef16f7f1cea9dea904228736025ae99624000ff..9c55f664ebbd0e723c1b9f71d982b6b62a1605eb 100644 (file)
@@ -18,6 +18,7 @@
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Instructions.h"
+#include "llvm/IntrinsicInst.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/CFG.h"
 #include "llvm/Support/Compiler.h"
@@ -27,7 +28,6 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Statistic.h"
 
-
 using namespace llvm;
 
 STATISTIC(NumRemoved, "Number of instructions removed");
@@ -35,7 +35,7 @@ STATISTIC(NumRemoved, "Number of instructions removed");
 namespace {
   struct VISIBILITY_HIDDEN ADCE : public FunctionPass {
     static char ID; // Pass identification, replacement for typeid
-    ADCE() : FunctionPass((intptr_t)&ID) {}
+    ADCE() : FunctionPass(&ID) {}
     
     virtual bool runOnFunction(Function& F);
     
@@ -56,7 +56,8 @@ bool ADCE::runOnFunction(Function& F) {
   // Collect the set of "root" instructions that are known live.
   for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I)
     if (isa<TerminatorInst>(I.getInstructionIterator()) ||
-        I->mayWriteToMemory()) {
+        isa<DbgInfoIntrinsic>(I.getInstructionIterator()) ||
+        I->mayHaveSideEffects()) {
       alive.insert(I.getInstructionIterator());
       worklist.push_back(I.getInstructionIterator());
     }
@@ -88,7 +89,7 @@ bool ADCE::runOnFunction(Function& F) {
     NumRemoved++;
     (*I)->eraseFromParent();
   }
-    
+
   return !worklist.empty();
 }