Revert commit 122654 at the request of Chris, who reckons that instsimplify
[oota-llvm.git] / lib / Analysis / LiveValues.cpp
index 7fc97c9cda704ae0548a31a40331620fe015e96d..f7c0b20c921d680572afe61307155554940fdedd 100644 (file)
 #include "llvm/Analysis/LoopInfo.h"
 using namespace llvm;
 
-FunctionPass *llvm::createLiveValuesPass() { return new LiveValues(); }
+namespace llvm {
+  FunctionPass *createLiveValuesPass() { return new LiveValues(); }
+}
 
 char LiveValues::ID = 0;
-static RegisterPass<LiveValues>
-X("live-values", "Value Liveness Analysis", false, true);
-
-LiveValues::LiveValues() : FunctionPass(&ID) {}
+INITIALIZE_PASS_BEGIN(LiveValues, "live-values",
+                "Value Liveness Analysis", false, true)
+INITIALIZE_PASS_DEPENDENCY(DominatorTree)
+INITIALIZE_PASS_DEPENDENCY(LoopInfo)
+INITIALIZE_PASS_END(LiveValues, "live-values",
+                "Value Liveness Analysis", false, true)
+
+LiveValues::LiveValues() : FunctionPass(ID) {
+  initializeLiveValuesPass(*PassRegistry::getPassRegistry());
+}
 
 void LiveValues::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.addRequired<DominatorTree>();
@@ -123,7 +131,7 @@ LiveValues::Memo &LiveValues::compute(const Value *V) {
   bool LiveOutOfDefBB = false;
 
   // Examine each use of the value.
-  for (Value::use_const_iterator I = V->use_begin(), E = V->use_end();
+  for (Value::const_use_iterator I = V->use_begin(), E = V->use_end();
        I != E; ++I) {
     const User *U = *I;
     const BasicBlock *UseBB = cast<Instruction>(U)->getParent();
@@ -162,9 +170,7 @@ LiveValues::Memo &LiveValues::compute(const Value *V) {
     }
 
     // Climb the immediate dominator tree from the use to the definition
-    // and mark all intermediate blocks as live-through. Don't do this if
-    // the user is a PHI because such users may not be dominated by the
-    // definition.
+    // and mark all intermediate blocks as live-through.
     for (; BB != DefBB; BB = getImmediateDominator(BB, DT)) {
       if (BB != UseBB && !M.LiveThrough.insert(BB))
         break;
@@ -184,7 +190,7 @@ LiveValues::Memo &LiveValues::compute(const Value *V) {
     }
   }
 
-  // If the value was never used outside the the block in which it was
+  // If the value was never used outside the block in which it was
   // defined, it's killed in that block.
   if (!LiveOutOfDefBB)
     M.Killed.insert(DefBB);