mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Fix PR3138: if we merge the entry block into another block, make sure to
move the other block back up into the entry position! llvm-svn: 60179
This commit is contained in:
parent
847a671436
commit
73b251b3bf
@ -165,7 +165,13 @@ bool JumpThreading::ProcessBlock(BasicBlock *BB) {
|
||||
// predecessors of our predecessor block.
|
||||
if (BasicBlock *SinglePred = BB->getSinglePredecessor())
|
||||
if (SinglePred->getTerminator()->getNumSuccessors() == 1) {
|
||||
// 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();
|
||||
MergeBasicBlockIntoOnlyPred(BB);
|
||||
|
||||
if (isEntry && BB != &BB->getParent()->getEntryBlock())
|
||||
BB->moveBefore(&BB->getParent()->getEntryBlock());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
13
test/Transforms/JumpThreading/2008-11-27-EntryMunge.ll
Normal file
13
test/Transforms/JumpThreading/2008-11-27-EntryMunge.ll
Normal file
@ -0,0 +1,13 @@
|
||||
; RUN: llvm-as < %s | opt -jump-threading -simplifycfg | llvm-dis | grep {ret i32 0}
|
||||
; PR3138
|
||||
|
||||
define i32 @jt() {
|
||||
entry:
|
||||
br i1 true, label %bb3, label %bb
|
||||
|
||||
bb: ; preds = %entry
|
||||
unreachable
|
||||
|
||||
bb3: ; preds = %entry
|
||||
ret i32 0
|
||||
}
|
Loading…
Reference in New Issue
Block a user