mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-09 13:21:30 +00:00
Fix Transforms/SimplifyCFG/switch-simplify-crash.ll
llvm-svn: 22158
This commit is contained in:
parent
510fbb3959
commit
b13335fff2
@ -1236,6 +1236,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
|||||||
} else if (SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
|
} else if (SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
|
||||||
for (unsigned i = 1, e = SI->getNumCases(); i != e; ++i)
|
for (unsigned i = 1, e = SI->getNumCases(); i != e; ++i)
|
||||||
if (SI->getSuccessor(i) == BB) {
|
if (SI->getSuccessor(i) == BB) {
|
||||||
|
BB->removePredecessor(SI->getParent());
|
||||||
SI->removeCase(i);
|
SI->removeCase(i);
|
||||||
--i; --e;
|
--i; --e;
|
||||||
Changed = true;
|
Changed = true;
|
||||||
@ -1263,6 +1264,12 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
|||||||
SI->setSuccessor(0, MaxBlock);
|
SI->setSuccessor(0, MaxBlock);
|
||||||
Changed = true;
|
Changed = true;
|
||||||
|
|
||||||
|
// If MaxBlock has phinodes in it, remove MaxPop-1 entries from
|
||||||
|
// it.
|
||||||
|
if (isa<PHINode>(MaxBlock->begin()))
|
||||||
|
for (unsigned i = 0; i != MaxPop-1; ++i)
|
||||||
|
MaxBlock->removePredecessor(SI->getParent());
|
||||||
|
|
||||||
for (unsigned i = 1, e = SI->getNumCases(); i != e; ++i)
|
for (unsigned i = 1, e = SI->getNumCases(); i != e; ++i)
|
||||||
if (SI->getSuccessor(i) == MaxBlock) {
|
if (SI->getSuccessor(i) == MaxBlock) {
|
||||||
SI->removeCase(i);
|
SI->removeCase(i);
|
||||||
|
Loading…
Reference in New Issue
Block a user