diff options
author | Owen Anderson <resistor@mac.com> | 2014-07-12 07:12:47 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2014-07-12 07:12:47 +0000 |
commit | a8d1c3e74ed11bbef77a15daabf011909dd9de31 (patch) | |
tree | cd28db0330fd2cfbce72739bd1bf44909cf13e9b /llvm/lib/Transforms/Utils | |
parent | d8442b1b21e381e4892bae953313bdc6d70497b6 (diff) | |
download | bcm5719-llvm-a8d1c3e74ed11bbef77a15daabf011909dd9de31.tar.gz bcm5719-llvm-a8d1c3e74ed11bbef77a15daabf011909dd9de31.zip |
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
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index aedd787ecf8..a5e443fcf46 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -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>()) { |