From 02dea8b39f3acad5de1df36273444d149145e7fc Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 23 May 2008 21:05:58 +0000 Subject: Tidy up BasicBlock::getFirstNonPHI, and change a bunch of places to use it instead of duplicating its functionality. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51499 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/RSProfiling.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'lib/Transforms/Instrumentation/RSProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp index a9406c89d4..5bd62c8197 100644 --- a/lib/Transforms/Instrumentation/RSProfiling.cpp +++ b/lib/Transforms/Instrumentation/RSProfiling.cpp @@ -265,14 +265,11 @@ void GlobalRandomCounterOpt::PrepFunction(Function* F) { new StoreInst(l, Counter, bib); BasicBlock* bb = cast(bib)->getNormalDest(); - BasicBlock::iterator i = bb->begin(); - while (isa(i)) - ++i; + BasicBlock::iterator i = bb->getFirstNonPHI(); l = new LoadInst(Counter, "counter", i); bb = cast(bib)->getUnwindDest(); - i = bb->begin(); - while (isa(i)) ++i; + i = bb->getFirstNonPHI(); l = new LoadInst(Counter, "counter", i); new StoreInst(l, AI, i); } else if (isa(&*bib) || isa(&*bib)) { @@ -343,8 +340,8 @@ bool RSProfilers_std::isProfiling(Value* v) { void RSProfilers_std::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum, GlobalValue *CounterArray) { // Insert the increment after any alloca or PHI instructions... - BasicBlock::iterator InsertPos = BB->begin(); - while (isa(InsertPos) || isa(InsertPos)) + BasicBlock::iterator InsertPos = BB->getFirstNonPHI(); + while (isa(InsertPos)) ++InsertPos; // Create the getelementptr constant expression -- cgit v1.2.3-18-g5258