mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
Fix an issue with the MergeBasicBlockIntoOnlyPred() helper function where it did
not properly handle the case where the predecessor block was the entry block to the function. The only in-tree client of this is JumpThreading, which worked around the issue in its own code. This patch moves the solution into the helper so that JumpThreading (and other clients) do not have to replicate the same fix everywhere. llvm-svn: 212875
This commit is contained in:
parent
72f517efca
commit
c0d64d2fdb
@ -669,14 +669,9 @@ bool JumpThreading::ProcessBlock(BasicBlock *BB) {
|
||||
if (LoopHeaders.erase(SinglePred))
|
||||
LoopHeaders.insert(BB);
|
||||
|
||||
// Remember if SinglePred was the entry block of the function. If so, we
|
||||
// will need to move BB back to the entry position.
|
||||
bool isEntry = SinglePred == &SinglePred->getParent()->getEntryBlock();
|
||||
LVI->eraseBlock(SinglePred);
|
||||
MergeBasicBlockIntoOnlyPred(BB);
|
||||
|
||||
if (isEntry && BB != &BB->getParent()->getEntryBlock())
|
||||
BB->moveBefore(&BB->getParent()->getEntryBlock());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -509,6 +509,11 @@ void llvm::MergeBasicBlockIntoOnlyPred(BasicBlock *DestBB, Pass *P) {
|
||||
PredBB->getTerminator()->eraseFromParent();
|
||||
DestBB->getInstList().splice(DestBB->begin(), PredBB->getInstList());
|
||||
|
||||
// If the PredBB is the entry block of the function, move DestBB up to
|
||||
// become the entry block after we erase PredBB.
|
||||
if (PredBB == &DestBB->getParent()->getEntryBlock())
|
||||
DestBB->moveAfter(PredBB);
|
||||
|
||||
if (P) {
|
||||
if (DominatorTreeWrapperPass *DTWP =
|
||||
P->getAnalysisIfAvailable<DominatorTreeWrapperPass>()) {
|
||||
|
Loading…
Reference in New Issue
Block a user