Add #includes to make up for #includes pruned out of header files.
[oota-llvm.git] / lib / Transforms / Instrumentation / TraceValues.cpp
index 9bbf7e580eac39e8bb046477768d52c3b9a96aaa..7f7321dbf06dfa74b37b06f58dd2650f2618eb9b 100644 (file)
@@ -12,9 +12,9 @@
 #include "llvm/iMemory.h"
 #include "llvm/iTerminators.h"
 #include "llvm/iOther.h"
+#include "llvm/BasicBlock.h"
 #include "llvm/Function.h"
 #include "llvm/Module.h"
-#include "llvm/SymbolTable.h"
 #include "llvm/Pass.h"
 #include "llvm/Assembly/Writer.h"
 #include "Support/StringExtras.h"
@@ -67,20 +67,12 @@ Pass *createTraceValuesPassForBasicBlocks() {  // Trace BB's and methods
 // Add a prototype for printf if it is not already in the program.
 //
 bool InsertTraceCode::doInitialization(Module *M) {
-  SymbolTable *ST = M->getSymbolTable();
   const Type *SBP = PointerType::get(Type::SByteTy);
-  const MethodType *MTy =
-    MethodType::get(Type::IntTy, vector<const Type*>(1, SBP), true);
+  const FunctionType *MTy =
+    FunctionType::get(Type::IntTy, vector<const Type*>(1, SBP), true);
 
-  if (Value *Func = ST->lookup(PointerType::get(MTy), "printf")) {
-    PrintfFunc = cast<Function>(Func);
-    return false;
-  }
-
-  // Create a new method and add it to the module
-  PrintfFunc = new Function(MTy, false, "printf");
-  M->getFunctionList().push_back(PrintfFunc);
-  return true;
+  PrintfFunc = M->getOrInsertFunction("printf", MTy);
+  return false;
 }