diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-28 22:42:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-28 22:42:24 +0000 |
commit | c0204e0b730c8aea661d6ff0fd504f45959e51e2 (patch) | |
tree | cb27487fc3a800629bfbd7723cec7dc28266ada4 /lib | |
parent | 4963dcf584b9bfe097aed271309b81d089b291e1 (diff) | |
download | external_llvm-c0204e0b730c8aea661d6ff0fd504f45959e51e2.zip external_llvm-c0204e0b730c8aea661d6ff0fd504f45959e51e2.tar.gz external_llvm-c0204e0b730c8aea661d6ff0fd504f45959e51e2.tar.bz2 |
Pass in argc & argv
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9563 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Instrumentation/BlockProfiling.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/Transforms/Instrumentation/BlockProfiling.cpp b/lib/Transforms/Instrumentation/BlockProfiling.cpp index 5986ed9..4b80d18 100644 --- a/lib/Transforms/Instrumentation/BlockProfiling.cpp +++ b/lib/Transforms/Instrumentation/BlockProfiling.cpp @@ -101,11 +101,30 @@ void FunctionProfiler::insertInitializationCall(Function *MainFn, Args[0] = Constant::getNullValue(Type::IntTy); Args[1] = Constant::getNullValue(ArgVTy); - /* FIXME: We should pass in the command line arguments here! */ + // Skip over any allocas in the entry block. + BasicBlock *Entry = MainFn->begin(); + BasicBlock::iterator InsertPos = Entry->begin(); + while (isa<AllocaInst>(InsertPos)) ++InsertPos; + + Function::aiterator AI; switch (MainFn->asize()) { default: case 2: + AI = MainFn->abegin(); ++AI; + if (AI->getType() != ArgVTy) { + Args[1] = new CastInst(AI, ArgVTy, "argv.cast", InsertPos); + } else { + Args[1] = AI; + } + case 1: + AI = MainFn->abegin(); + if (AI->getType() != Type::IntTy) { + Args[0] = new CastInst(AI, Type::IntTy, "argc.cast", InsertPos); + } else { + Args[0] = AI; + } + case 0: break; } @@ -118,10 +137,5 @@ void FunctionProfiler::insertInitializationCall(Function *MainFn, cast<ArrayType>(Array->getType()->getElementType())->getNumElements(); Args[3] = ConstantUInt::get(Type::UIntTy, NumElements); - // Skip over any allocas in the entry block. - BasicBlock *Entry = MainFn->begin(); - BasicBlock::iterator InsertPos = Entry->begin(); - while (isa<AllocaInst>(InsertPos)) ++InsertPos; - new CallInst(InitFn, Args, "", InsertPos); } |