'Pass' should now not be derived from by clients. Instead, they should derive
[oota-llvm.git] / lib / Transforms / Instrumentation / EmitFunctions.cpp
index 9c395a9c1f65401845834332948d7c1c30c19569..92abffb8ead090183c7ee907abb1a8260090643c 100644 (file)
@@ -7,7 +7,9 @@
 // 
 //===----------------------------------------------------------------------===//
 //
-// This inserts a global constant table with function pointers all along
+// This inserts a global constant table with function pointers all along.
+//
+// NOTE: This pass is used by the reoptimizer only.
 //
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Module.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/CFG.h"
-
-enum Color{
-  WHITE,
-  GREY,
-  BLACK
-};
+using namespace llvm;
 
 namespace {
-  struct EmitFunctionTable : public Pass {
-    bool run(Module &M);
+  enum Color{
+    WHITE,
+    GREY,
+    BLACK
+  };
+  
+  struct EmitFunctionTable : public ModulePass {
+    bool runOnModule(Module &M);
   };
   
-  RegisterOpt<EmitFunctionTable> X("emitfuncs", "Emit a Function Table");
+  RegisterOpt<EmitFunctionTable>
+  X("emitfuncs", "Emit a function table for the reoptimizer");
 }
 
-char doDFS(BasicBlock * node,std::map<BasicBlock *, Color > &color){
+static char doDFS(BasicBlock * node,std::map<BasicBlock *, Color > &color){
   color[node] = GREY;
 
   for(succ_iterator vl = succ_begin(node), ve = succ_end(node); vl != ve; ++vl){
@@ -54,13 +58,13 @@ char doDFS(BasicBlock * node,std::map<BasicBlock *, Color > &color){
   return 1;
 }
 
-char hasBackEdge(Function *F){
+static char hasBackEdge(Function *F){
   std::map<BasicBlock *, Color > color;
   return doDFS(F->begin(), color);
 }
 
 // Per Module pass for inserting function table
-bool EmitFunctionTable::run(Module &M){
+bool EmitFunctionTable::runOnModule(Module &M){
   std::vector<const Type*> vType;
  
   std::vector<Constant *> vConsts;
@@ -73,21 +77,21 @@ bool EmitFunctionTable::run(Module &M){
     
       //std::cerr<<MI;
 
-      vConsts.push_back(ConstantPointerRef::get(MI));
+      vConsts.push_back(MI);
       sBCons.push_back(ConstantInt::get(Type::SByteTy, hasBackEdge(MI)));
       
       counter++;
     }
   
   StructType *sttype = StructType::get(vType);
-  ConstantStruct *cstruct = ConstantStruct::get(sttype, vConsts);
+  Constant *cstruct = ConstantStruct::get(sttype, vConsts);
 
   GlobalVariable *gb = new GlobalVariable(cstruct->getType(), true,
                                           GlobalValue::ExternalLinkage, 
                                           cstruct, "llvmFunctionTable");
   M.getGlobalList().push_back(gb);
 
-  ConstantArray *constArray = ConstantArray::get(ArrayType::get(Type::SByteTy, 
+  Constant *constArray = ConstantArray::get(ArrayType::get(Type::SByteTy, 
                                                                sBCons.size()),
                                                 sBCons);