diff options
author | Chris Lattner <sabre@nondot.org> | 2002-06-25 16:13:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-06-25 16:13:21 +0000 |
commit | 0b12b5f50ec77a8bd01b92d287c52d748619bb4b (patch) | |
tree | 5764db59facb124b023f1de96f0e45d37657c82e /lib/Transforms/Instrumentation/ProfilePaths | |
parent | 18961504fc2b299578dba817900a0696cf3ccc4d (diff) | |
download | external_llvm-0b12b5f50ec77a8bd01b92d287c52d748619bb4b.tar.gz external_llvm-0b12b5f50ec77a8bd01b92d287c52d748619bb4b.tar.bz2 external_llvm-0b12b5f50ec77a8bd01b92d287c52d748619bb4b.zip |
MEGAPATCH checkin.
For details, See: docs/2002-06-25-MegaPatchInfo.txt
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2778 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Instrumentation/ProfilePaths')
-rw-r--r-- | lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp | 65 | ||||
-rw-r--r-- | lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp | 24 |
2 files changed, 43 insertions, 46 deletions
diff --git a/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp b/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp index f8d761627e..1c0970537a 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp @@ -34,7 +34,7 @@ void getEdgeCode::getCode(Instruction *rInst, case 1:{ Value *val=ConstantSInt::get(Type::IntTy,inc); Instruction *stInst=new StoreInst(val, rInst); - here=instList.insert(here,stInst)+1; + here=++instList.insert(here,stInst); break; } @@ -42,7 +42,7 @@ void getEdgeCode::getCode(Instruction *rInst, case 2:{ Value *val=ConstantSInt::get(Type::IntTy,0); Instruction *stInst=new StoreInst(val, rInst); - here=instList.insert(here,stInst)+1; + here=++instList.insert(here,stInst); break; } @@ -54,9 +54,9 @@ void getEdgeCode::getCode(Instruction *rInst, create(Instruction::Add, ldInst, val,"ti2"); Instruction *stInst=new StoreInst(addIn, rInst); - here=instList.insert(here,ldInst)+1; - here=instList.insert(here,addIn)+1; - here=instList.insert(here,stInst)+1; + here=++instList.insert(here,ldInst); + here=++instList.insert(here,addIn); + here=++instList.insert(here,stInst); break; } @@ -74,9 +74,9 @@ void getEdgeCode::getCode(Instruction *rInst, StoreInst(addIn, countInst, vector<Value *> (1, ConstantUInt::get(Type::UIntTy,inc))); - here=instList.insert(here,ldInst)+1; - here=instList.insert(here,addIn)+1; - here=instList.insert(here,stInst)+1; + here=++instList.insert(here,ldInst); + here=++instList.insert(here,addIn); + here=++instList.insert(here,stInst); break; } @@ -102,12 +102,12 @@ void getEdgeCode::getCode(Instruction *rInst, StoreInst(addIn, countInst, vector<Value *>(1,castInst)); - here=instList.insert(here,ldIndex)+1; - here=instList.insert(here,addIndex)+1; - here=instList.insert(here,castInst)+1; - here=instList.insert(here,ldInst)+1; - here=instList.insert(here,addIn)+1; - here=instList.insert(here,stInst)+1; + here=++instList.insert(here,ldIndex); + here=++instList.insert(here,addIndex); + here=++instList.insert(here,castInst); + here=++instList.insert(here,ldInst); + here=++instList.insert(here,addIn); + here=++instList.insert(here,stInst); break; } @@ -129,11 +129,11 @@ void getEdgeCode::getCode(Instruction *rInst, Instruction *stInst=new StoreInst(addIn, countInst, vector<Value *>(1,castInst2)); - here=instList.insert(here,ldIndex)+1; - here=instList.insert(here,castInst2)+1; - here=instList.insert(here,ldInst)+1; - here=instList.insert(here,addIn)+1; - here=instList.insert(here,stInst)+1; + here=++instList.insert(here,ldIndex); + here=++instList.insert(here,castInst2); + here=++instList.insert(here,ldInst); + here=++instList.insert(here,addIn); + here=++instList.insert(here,stInst); break; } @@ -175,8 +175,8 @@ void insertInTopBB(BasicBlock *front, //now push all instructions in front of the BB BasicBlock::InstListType& instList=front->getInstList(); BasicBlock::iterator here=instList.begin(); - here=front->getInstList().insert(here, rVar)+1; - here=front->getInstList().insert(here,countVar)+1; + here=++front->getInstList().insert(here, rVar); + here=++front->getInstList().insert(here,countVar); //Initialize Count[...] with 0 for(int i=0;i<k; i++){ @@ -184,10 +184,10 @@ void insertInTopBB(BasicBlock *front, StoreInst(ConstantInt::get(Type::IntTy, 0), countVar, std::vector<Value *> (1,ConstantUInt::get(Type::UIntTy, i))); - here=front->getInstList().insert(here,stInstrC)+1; + here=++front->getInstList().insert(here,stInstrC); } - here=front->getInstList().insert(here,stInstr)+1; + here=++front->getInstList().insert(here,stInstr); } @@ -226,27 +226,24 @@ void insertBB(Edge ed, Value *cond=BI->getCondition(); BasicBlock *fB, *tB; - if(BI->getSuccessor(0)==BB2){ + if (BI->getSuccessor(0) == BB2){ tB=newBB; fB=BI->getSuccessor(1); - } - else{ + } else { fB=newBB; tB=BI->getSuccessor(0); } - delete BB1->getInstList().pop_back(); - Instruction *newBI=new BranchInst(tB,fB,cond); - Instruction *newBI2=new BranchInst(BB2); - BB1->getInstList().push_back(newBI); - newBB->getInstList().push_back(newBI2); + BB1->getInstList().pop_back(); + BB1->getInstList().push_back(new BranchInst(tB,fB,cond)); + newBB->getInstList().push_back(new BranchInst(BB2)); } //now iterate over BB2, and set its Phi nodes right - for(BasicBlock::iterator BB2Inst=BB2->begin(), BBend=BB2->end(); - BB2Inst!=BBend; ++BB2Inst){ + for(BasicBlock::iterator BB2Inst = BB2->begin(), BBend = BB2->end(); + BB2Inst != BBend; ++BB2Inst){ - if(PHINode *phiInst=dyn_cast<PHINode>(*BB2Inst)){ + if(PHINode *phiInst=dyn_cast<PHINode>(&*BB2Inst)){ DEBUG(cerr<<"YYYYYYYYYYYYYYYYY\n"); int bbIndex=phiInst->getBasicBlockIndex(BB1); diff --git a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp index dcab136800..42ef33cb0d 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp @@ -37,7 +37,7 @@ using std::vector; struct ProfilePaths : public FunctionPass { const char *getPassName() const { return "ProfilePaths"; } - bool runOnFunction(Function *F); + bool runOnFunction(Function &F); // Before this pass, make sure that there is only one // entry and only one exit node for the function in the CFG of the function @@ -64,7 +64,7 @@ static Node *findBB(std::set<Node *> &st, BasicBlock *BB){ } //Per function pass for inserting counters and trigger code -bool ProfilePaths::runOnFunction(Function *M){ +bool ProfilePaths::runOnFunction(Function &F){ // Transform the cfg s.t. we have just one exit node BasicBlock *ExitNode = getAnalysis<UnifyFunctionExitNodes>().getExitNode(); @@ -78,20 +78,20 @@ bool ProfilePaths::runOnFunction(Function *M){ // That is, no two nodes must hav same BB* // First enter just nodes: later enter edges - for (Function::iterator BB = M->begin(), BE=M->end(); BB != BE; ++BB){ - Node *nd=new Node(*BB); + for (Function::iterator BB = F.begin(), BE = F.end(); BB != BE; ++BB) { + Node *nd=new Node(BB); nodes.insert(nd); - if(*BB==ExitNode) + if(&*BB == ExitNode) exitNode=nd; - if(*BB==M->front()) + if(&*BB==F.begin()) startNode=nd; } // now do it againto insert edges - for (Function::iterator BB = M->begin(), BE=M->end(); BB != BE; ++BB){ - Node *nd=findBB(nodes, *BB); + for (Function::iterator BB = F.begin(), BE = F.end(); BB != BE; ++BB){ + Node *nd=findBB(nodes, BB); assert(nd && "No node for this edge!"); - for(BasicBlock::succ_iterator s=succ_begin(*BB), se=succ_end(*BB); + for(BasicBlock::succ_iterator s=succ_begin(BB), se=succ_end(BB); s!=se; ++s){ Node *nd2=findBB(nodes,*s); assert(nd2 && "No node for this edge!"); @@ -104,10 +104,10 @@ bool ProfilePaths::runOnFunction(Function *M){ DEBUG(printGraph(g)); - BasicBlock *fr=M->front(); + BasicBlock *fr=&F.front(); // If only one BB, don't instrument - if (M->getBasicBlocks().size() == 1) { + if (++F.begin() == F.end()) { // The graph is made acyclic: this is done // by removing back edges for now, and adding them later on vector<Edge> be; @@ -148,7 +148,7 @@ bool ProfilePaths::runOnFunction(Function *M){ // insert initialization code in first (entry) BB // this includes initializing r and count - insertInTopBB(M->getEntryNode(),numPaths, rVar, countVar); + insertInTopBB(&F.getEntryNode(),numPaths, rVar, countVar); // now process the graph: get path numbers, // get increments along different paths, |