Utils/LoopUnroll.cpp: Tweak (StringRef)OldName to be valid until it is used, since r194601.

eraseFromParent() invalidates OldName.

llvm-svn: 194970
This commit is contained in:
NAKAMURA Takumi 2013-11-17 18:05:34 +00:00
parent b90f560303
commit f9c8339a4e
1 changed files with 3 additions and 1 deletions

View File

@ -90,6 +90,7 @@ static BasicBlock *FoldBlockIntoPredecessor(BasicBlock *BB, LoopInfo* LI,
// Move all definitions in the successor to the predecessor...
OnlyPred->getInstList().splice(OnlyPred->end(), BB->getInstList());
// OldName will be valid until erased.
StringRef OldName = BB->getName();
// Erase basic block from the function...
@ -102,12 +103,13 @@ static BasicBlock *FoldBlockIntoPredecessor(BasicBlock *BB, LoopInfo* LI,
}
}
LI->removeBlock(BB);
BB->eraseFromParent();
// Inherit predecessor's name if it exists...
if (!OldName.empty() && !OnlyPred->hasName())
OnlyPred->setName(OldName);
BB->eraseFromParent();
return OnlyPred;
}