Tighten the conditions under which we do PRE, remove some unneeded code, and correct...
[oota-llvm.git] / lib / Transforms / Instrumentation / ProfilingUtils.cpp
index d94522f6c7d34e8b7c2f4f2417492ec21dadf191..48071f1156925c5853fe7b4def18ac6c87aaf2c3 100644 (file)
@@ -100,8 +100,8 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
 void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum,
                                    GlobalValue *CounterArray) {
   // Insert the increment after any alloca or PHI instructions...
-  BasicBlock::iterator InsertPos = BB->begin();
-  while (isa<AllocaInst>(InsertPos) || isa<PHINode>(InsertPos))
+  BasicBlock::iterator InsertPos = BB->getFirstNonPHI();
+  while (isa<AllocaInst>(InsertPos))
     ++InsertPos;
 
   // Create the getelementptr constant expression