aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Instrumentation/PathProfiling.cpp
diff options
context:
space:
mode:
authorJay Foad <jay.foad@gmail.com>2011-03-30 11:19:20 +0000
committerJay Foad <jay.foad@gmail.com>2011-03-30 11:19:20 +0000
commite0938d8a87a6c8b12f68fbe784a270dd2d552331 (patch)
tree98d4fbcf8ebe8ec03e205e22d98469b177234a95 /llvm/lib/Transforms/Instrumentation/PathProfiling.cpp
parent27e20c3c586da61e5fe9218aa9fe5733e34c18c2 (diff)
downloadllvm-e0938d8a87a6c8b12f68fbe784a270dd2d552331.zip
llvm-e0938d8a87a6c8b12f68fbe784a270dd2d552331.tar.gz
llvm-e0938d8a87a6c8b12f68fbe784a270dd2d552331.tar.bz2
(Almost) always call reserveOperandSpace() on newly created PHINodes.
llvm-svn: 128535
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/PathProfiling.cpp')
-rw-r--r--llvm/lib/Transforms/Instrumentation/PathProfiling.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/PathProfiling.cpp b/llvm/lib/Transforms/Instrumentation/PathProfiling.cpp
index 6449b39..ca2c6fb 100644
--- a/llvm/lib/Transforms/Instrumentation/PathProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PathProfiling.cpp
@@ -929,14 +929,16 @@ BasicBlock::iterator PathProfiler::getInsertionPoint(BasicBlock* block, Value*
void PathProfiler::preparePHI(BLInstrumentationNode* node) {
BasicBlock* block = node->getBlock();
BasicBlock::iterator insertPoint = block->getFirstNonPHI();
+ pred_iterator PB = pred_begin(node->getBlock()),
+ PE = pred_end(node->getBlock());
PHINode* phi = PHINode::Create(Type::getInt32Ty(*Context), "pathNumber",
insertPoint );
+ phi->reserveOperandSpace(std::distance(PB, PE));
node->setPathPHI(phi);
node->setStartingPathNumber(phi);
node->setEndingPathNumber(phi);
- for(pred_iterator predIt = pred_begin(node->getBlock()),
- end = pred_end(node->getBlock()); predIt != end; predIt++) {
+ for(pred_iterator predIt = PB; predIt != PE; predIt++) {
BasicBlock* pred = (*predIt);
if(pred != NULL)