Add Loop contains utility methods for testing whether a loop
[oota-llvm.git] / lib / Transforms / Utils / Mem2Reg.cpp
index 33fcd8c486074792b3ff8d036c9702c75a0ae182..99203b662120eaa697ee6a243d2b76122d810010 100644 (file)
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/PromoteMemToReg.h"
 #include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
-#include "llvm/IntrinsicInst.h"
 #include "llvm/Analysis/Dominators.h"
 #include "llvm/Instructions.h"
 #include "llvm/Function.h"
 #include "llvm/ADT/Statistic.h"
-#include "llvm/Support/Compiler.h"
 using namespace llvm;
 
 STATISTIC(NumPromoted, "Number of alloca's promoted");
 
 namespace {
-  struct VISIBILITY_HIDDEN PromotePass : public FunctionPass {
+  struct PromotePass : public FunctionPass {
     static char ID; // Pass identification, replacement for typeid
     PromotePass() : FunctionPass(&ID) {}
 
@@ -46,7 +44,6 @@ namespace {
       AU.addPreserved<UnifyFunctionExitNodes>();
       AU.addPreservedID(LowerSwitchID);
       AU.addPreservedID(LowerInvokePassID);
-      AU.addPreservedID(LowerAllocationsID);
     }
   };
 }  // end of anonymous namespace
@@ -54,30 +51,6 @@ namespace {
 char PromotePass::ID = 0;
 static RegisterPass<PromotePass> X("mem2reg", "Promote Memory to Register");
 
-/// Remove the invalid or redundant debug information.
-static void CleanDbgInfo(Function& F) {
-  std::vector<Instruction*> DeadDbgs;
-  for (Function::iterator BBI = F.begin(), BBE = F.end(); BBI != BBE; ++BBI) {
-    if (BBI->size() <= 1)
-      continue;
-    for (BasicBlock::iterator I = BBI->begin(), E = BBI->getTerminator(); 
-         I != E; ++I) {
-      BasicBlock::iterator NextI = I;
-      ++NextI;
-      if (isa<DbgStopPointInst>(I) && isa<DbgStopPointInst>(NextI))
-        DeadDbgs.push_back(I);
-      else if (isa<DbgStopPointInst>(I) && isa<BranchInst>(NextI))
-        DeadDbgs.push_back(I);
-    }
-  }
-
-  while (!DeadDbgs.empty()) {
-    Instruction *Inst = DeadDbgs.back();
-    DeadDbgs.pop_back();
-    Inst->eraseFromParent();
-  }
-}
-
 bool PromotePass::runOnFunction(Function &F) {
   std::vector<AllocaInst*> Allocas;
 
@@ -101,7 +74,6 @@ bool PromotePass::runOnFunction(Function &F) {
     if (Allocas.empty()) break;
 
     PromoteMemToReg(Allocas, DT, DF);
-    CleanDbgInfo(F);
     NumPromoted += Allocas.size();
     Changed = true;
   }