diff options
author | Chris Lattner <sabre@nondot.org> | 2002-03-29 03:43:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-03-29 03:43:24 +0000 |
commit | c46dcca2200772cb7f451bf73d80a8bfdbc834dc (patch) | |
tree | 79bbe248c22c409d3265206b6e8ab2b082e2b2ed /llvm/lib/Transforms/Instrumentation/TraceValues.cpp | |
parent | 175f37c47b6ca93c896386f325df7c0d10c3220a (diff) | |
download | bcm5719-llvm-c46dcca2200772cb7f451bf73d80a8bfdbc834dc.tar.gz bcm5719-llvm-c46dcca2200772cb7f451bf73d80a8bfdbc834dc.zip |
Simplify code a bit by using Module::getOrInsertFunction
llvm-svn: 2032
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/TraceValues.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/TraceValues.cpp | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/TraceValues.cpp b/llvm/lib/Transforms/Instrumentation/TraceValues.cpp index 9bbf7e580ea..e064caa8176 100644 --- a/llvm/lib/Transforms/Instrumentation/TraceValues.cpp +++ b/llvm/lib/Transforms/Instrumentation/TraceValues.cpp @@ -14,7 +14,6 @@ #include "llvm/iOther.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 +66,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); - 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; } |