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 | 89851077da34f052819b2da026bf881f3ae0eac7 (patch) | |
tree | 50cd33fd14b91c4baaeee0658d6edb39efcf9e4c /lib/Transforms | |
parent | d2d3a16641a411006078cc25b59382635d51f925 (diff) | |
download | external_llvm-89851077da34f052819b2da026bf881f3ae0eac7.zip external_llvm-89851077da34f052819b2da026bf881f3ae0eac7.tar.gz external_llvm-89851077da34f052819b2da026bf881f3ae0eac7.tar.bz2 |
Simplify code a bit by using Module::getOrInsertFunction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2032 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Instrumentation/TraceValues.cpp | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp index 9bbf7e5..e064caa 100644 --- a/lib/Transforms/Instrumentation/TraceValues.cpp +++ b/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; } |