From 034636444b77c82c420c7f6d8c4014aa559b28e2 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 31 Aug 2003 00:21:59 +0000 Subject: [PATCH] Use the new interface, simplifies code NOTE that these two files are _BUGGY_ and need to be fixed, just not by me :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8241 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Instrumentation/ProfilePaths/InstLoops.cpp | 15 ++++++--------- .../ProfilePaths/ProfilePaths.cpp | 16 +++++++--------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp b/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp index a74d5c75b1e..1c0ec3b9ae4 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp @@ -121,6 +121,12 @@ void InstLoops::findAndInstrumentBackEdges(Function &F){ removeRedundant(be); + // FIXME: THIS IS HORRIBLY BROKEN. FunctionPass's cannot do this, except in + // their initialize function!! + Function *inCountMth = + F.getParent()->getOrInsertFunction("llvm_first_trigger", + Type::VoidTy, 0); + for(std::map::iterator MI = be.begin(), ME = be.end(); MI != ME; ++MI){ BasicBlock *u = MI->first; @@ -138,15 +144,6 @@ void InstLoops::findAndInstrumentBackEdges(Function &F){ BasicBlock::InstListType < = newBB->getInstList(); - std::vector inCountArgs; - const FunctionType *cFty = FunctionType::get(Type::VoidTy, inCountArgs, - false); - Function *inCountMth = - u->getParent()->getParent()->getOrInsertFunction("llvm_first_trigger", - cFty); - - assert(inCountMth && "Initial method could not be inserted!"); - Instruction *call = new CallInst(inCountMth); lt.push_back(call); lt.push_back(new BranchInst(BB)); diff --git a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp index c8741470b38..96150142e3c 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp @@ -176,18 +176,16 @@ bool ProfilePaths::runOnFunction(Function &F){ if(fr->getParent()->getName() == "main"){ //intialize threshold - vector initialize_args; - initialize_args.push_back(PointerType::get(Type::IntTy)); - - const FunctionType *Fty = FunctionType::get(Type::VoidTy, initialize_args, - false); - Function *initialMeth = fr->getParent()->getParent()->getOrInsertFunction("reoptimizerInitialize", Fty); - assert(initialMeth && "Initialize method could not be inserted!"); + + // FIXME: THIS IS HORRIBLY BROKEN. FUNCTION PASSES CANNOT DO THIS, EXCEPT + // IN THEIR INITIALIZE METHOD!! + Function *initialize = + F.getParent()->getOrInsertFunction("reoptimizerInitialize", Type::VoidTy, + PointerType::get(Type::IntTy), 0); vector trargs; trargs.push_back(threshold); - - new CallInst(initialMeth, trargs, "", fr->begin()); + new CallInst(initialize, trargs, "", fr->begin()); } -- 2.34.1