A brief survey of priority_queue usage in the tree turned this up
[oota-llvm.git] / lib / Analysis / ValueNumbering.cpp
index b91286bc7a654789ba05dbe9a48cf0d417a4bcf1..55323eaa9ed1be7b86aceb5246aa5d4d92756b21 100644 (file)
@@ -2,14 +2,18 @@
 //
 //                     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.
 //
 //===----------------------------------------------------------------------===//
 //
 // This file implements the non-abstract Value Numbering methods as well as a
 // default implementation for the analysis group.
 //
+// The ValueNumbering analysis pass is mostly deprecated. It is only used by the
+// Global Common Subexpression Elimination pass, which is deprecated by the
+// Global Value Numbering pass (which does its value numbering on its own).
+//
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Analysis/Passes.h"
@@ -22,9 +26,9 @@
 #include "llvm/Support/Compiler.h"
 using namespace llvm;
 
-const char ValueNumbering::ID = 0;
+char ValueNumbering::ID = 0;
 // Register the ValueNumbering interface, providing a nice name to refer to.
-static RegisterAnalysisGroup<ValueNumbering> X("Value Numbering");
+static RegisterAnalysisGroup<ValueNumbering> V("Value Numbering");
 
 /// ValueNumbering destructor: DO NOT move this to the header file for
 /// ValueNumbering or else clients of the ValueNumbering class may not depend on
@@ -52,7 +56,7 @@ namespace {
   ///
   struct VISIBILITY_HIDDEN BasicVN 
       : public ImmutablePass, public ValueNumbering {
-    static const char ID; // Class identification, replacement for typeinfo
+    static char ID; // Class identification, replacement for typeinfo
     BasicVN() : ImmutablePass((intptr_t)&ID) {}
 
     /// getEqualNumberNodes - Return nodes with the same value number as the
@@ -64,21 +68,23 @@ namespace {
     virtual void getEqualNumberNodes(Value *V1,
                                      std::vector<Value*> &RetVals) const;
   };
+}
 
-  const char BasicVN::ID = 0;
-  // Register this pass...
-  RegisterPass<BasicVN>
-  X("basicvn", "Basic Value Numbering (default GVN impl)");
+char BasicVN::ID = 0;
+// Register this pass...
+static RegisterPass<BasicVN>
+X("basicvn", "Basic Value Numbering (default GVN impl)", false, true);
 
-  // Declare that we implement the ValueNumbering interface
-  RegisterAnalysisGroup<ValueNumbering, true> Y(X);
+// Declare that we implement the ValueNumbering interface
+static RegisterAnalysisGroup<ValueNumbering, true> Y(X);
 
+namespace {
   /// BVNImpl - Implement BasicVN in terms of a visitor class that
   /// handles the different types of instructions as appropriate.
   ///
   struct VISIBILITY_HIDDEN BVNImpl : public InstVisitor<BVNImpl> {
     std::vector<Value*> &RetVals;
-    BVNImpl(std::vector<Value*> &RV) : RetVals(RV) {}
+    explicit BVNImpl(std::vector<Value*> &RV) : RetVals(RV) {}
 
     void visitCastInst(CastInst &I);
     void visitGetElementPtrInst(GetElementPtrInst &I);
@@ -242,9 +248,9 @@ void BVNImpl::visitGetElementPtrInst(GetElementPtrInst &I) {
 
   // Try to pick a local operand if possible instead of a constant or a global
   // that might have a lot of uses.
-  for (unsigned i = 1, e = I.getNumOperands(); i != e; ++i)
-    if (isa<Instruction>(I.getOperand(i)) || isa<Argument>(I.getOperand(i))) {
-      Op = I.getOperand(i);
+  for (User::op_iterator i = I.op_begin() + 1, e = I.op_end(); i != e; ++i)
+    if (isa<Instruction>(*i) || isa<Argument>(*i)) {
+      Op = *i;
       break;
     }