A brief survey of priority_queue usage in the tree turned this up
[oota-llvm.git] / lib / Analysis / LoadValueNumbering.cpp
index 67d4dd22bbac1d8b467bc17634e3e37dd177000c..2414d33863dd1d303c5cf28fb6bed3f2d64b2bff 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -82,14 +82,15 @@ namespace {
     void getCallEqualNumberNodes(CallInst *CI,
                                  std::vector<Value*> &RetVals) const;
   };
+}
 
-  char LoadVN::ID = 0;
-  // Register this pass...
-  RegisterPass<LoadVN> X("load-vn", "Load Value Numbering");
+char LoadVN::ID = 0;
+// Register this pass...
+static RegisterPass<LoadVN>
+X("load-vn", "Load Value Numbering", false, true);
 
-  // Declare that we implement the ValueNumbering interface
-  RegisterAnalysisGroup<ValueNumbering> Y(X);
-}
+// Declare that we implement the ValueNumbering interface
+static RegisterAnalysisGroup<ValueNumbering> Y(X);
 
 FunctionPass *llvm::createLoadValueNumberingPass() { return new LoadVN(); }
 
@@ -157,10 +158,10 @@ void LoadVN::getCallEqualNumberNodes(CallInst *CI,
   // global.  In particular, we would prefer to have an argument or instruction
   // operand to chase the def-use chains of.
   Value *Op = CF;
-  for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i)
-    if (isa<Argument>(CI->getOperand(i)) ||
-        isa<Instruction>(CI->getOperand(i))) {
-      Op = CI->getOperand(i);
+  for (User::op_iterator i = CI->op_begin() + 1, e = CI->op_end(); i != e; ++i)
+    if (isa<Argument>(*i) ||
+        isa<Instruction>(*i)) {
+      Op = *i;
       break;
     }
 
@@ -175,8 +176,9 @@ void LoadVN::getCallEqualNumberNodes(CallInst *CI,
           C->getOperand(0) == CI->getOperand(0) &&
           C->getParent()->getParent() == CIFunc && C != CI) {
         bool AllOperandsEqual = true;
-        for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i)
-          if (C->getOperand(i) != CI->getOperand(i)) {
+        for (User::op_iterator i = CI->op_begin() + 1, j = C->op_begin() + 1,
+             e = CI->op_end(); i != e; ++i, ++j)
+          if (*j != *i) {
             AllOperandsEqual = false;
             break;
           }