summaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-04-17 17:51:03 +0000
committerChris Lattner <sabre@nondot.org>2007-04-17 17:51:03 +0000
commita0e1b0e98da65db930dcd40af662e49f0257a269 (patch)
tree61e7c2680970aa8116dc076a7380da58014b1b56 /lib/Transforms
parentdecb0ca18b0fc7ea071b67b005f639fd4c4404d9 (diff)
downloadllvm-a0e1b0e98da65db930dcd40af662e49f0257a269.tar.gz
llvm-a0e1b0e98da65db930dcd40af662e49f0257a269.tar.bz2
llvm-a0e1b0e98da65db930dcd40af662e49f0257a269.tar.xz
eliminate use of Instruction::getNext()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36200 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Instrumentation/RSProfiling.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp
index 7e34786edf..680347ebeb 100644
--- a/lib/Transforms/Instrumentation/RSProfiling.cpp
+++ b/lib/Transforms/Instrumentation/RSProfiling.cpp
@@ -230,9 +230,10 @@ GlobalRandomCounterOpt::~GlobalRandomCounterOpt() {}
void GlobalRandomCounterOpt::PrepFunction(Function* F) {
//make a local temporary to cache the global
BasicBlock& bb = F->getEntryBlock();
- AI = new AllocaInst(T, 0, "localcounter", bb.begin());
- LoadInst* l = new LoadInst(Counter, "counterload", AI->getNext());
- new StoreInst(l, AI, l->getNext());
+ BasicBlock::iterator InsertPt = bb.begin();
+ AI = new AllocaInst(T, 0, "localcounter", InsertPt);
+ LoadInst* l = new LoadInst(Counter, "counterload", InsertPt);
+ new StoreInst(l, AI, InsertPt);
//modify all functions and return values to restore the local variable to/from
//the global variable
@@ -240,25 +241,26 @@ void GlobalRandomCounterOpt::PrepFunction(Function* F) {
fib != fie; ++fib)
for(BasicBlock::iterator bib = fib->begin(), bie = fib->end();
bib != bie; ++bib)
- if (isa<CallInst>(&*bib)) {
+ if (isa<CallInst>(bib)) {
LoadInst* l = new LoadInst(AI, "counter", bib);
new StoreInst(l, Counter, bib);
- l = new LoadInst(Counter, "counter", bib->getNext());
- new StoreInst(l, AI, l->getNext());
- } else if (isa<InvokeInst>(&*bib)) {
+ l = new LoadInst(Counter, "counter", ++bib);
+ new StoreInst(l, AI, bib--);
+ } else if (isa<InvokeInst>(bib)) {
LoadInst* l = new LoadInst(AI, "counter", bib);
new StoreInst(l, Counter, bib);
- BasicBlock* bb = cast<InvokeInst>(&*bib)->getNormalDest();
- Instruction* i = bb->begin();
- while (isa<PHINode>(i)) i = i->getNext();
+ BasicBlock* bb = cast<InvokeInst>(bib)->getNormalDest();
+ BasicBlock::iterator i = bb->begin();
+ while (isa<PHINode>(i))
+ ++i;
l = new LoadInst(Counter, "counter", i);
- bb = cast<InvokeInst>(&*bib)->getUnwindDest();
+ bb = cast<InvokeInst>(bib)->getUnwindDest();
i = bb->begin();
- while (isa<PHINode>(i)) i = i->getNext();
+ while (isa<PHINode>(i)) ++i;
l = new LoadInst(Counter, "counter", i);
- new StoreInst(l, AI, l->getNext());
+ new StoreInst(l, AI, i);
} else if (isa<UnwindInst>(&*bib) || isa<ReturnInst>(&*bib)) {
LoadInst* l = new LoadInst(AI, "counter", bib);
new StoreInst(l, Counter, bib);