diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-06-12 20:18:01 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-06-12 20:18:01 +0000 |
| commit | b5c9d7a0afbe1e2f4f08469888022ce518e81d50 (patch) | |
| tree | b6ad1d1e629bde82a99e1c7426b3abc2e8585b85 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
| parent | 9c4ddf8314a1c2c59f5939511e9ffb072cd2bdf7 (diff) | |
| download | bcm5719-llvm-b5c9d7a0afbe1e2f4f08469888022ce518e81d50.tar.gz bcm5719-llvm-b5c9d7a0afbe1e2f4f08469888022ce518e81d50.zip | |
Fix an infinite loop on Transforms/SimplifyCFG/2006-06-12-InfLoop.ll
llvm-svn: 28758
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index ecd1471b4e3..8f7a154cf48 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1515,12 +1515,21 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { // keep getting unwound. if (PBIOp != -1 && PBI->getSuccessor(PBIOp) == BB) PBIOp = BIOp = -1; - + // Finally, if everything is ok, fold the branches to logical ops. if (PBIOp != -1) { BasicBlock *CommonDest = PBI->getSuccessor(PBIOp); BasicBlock *OtherDest = BI->getSuccessor(BIOp ^ 1); + // If OtherDest *is* BB, then this is a basic block with just + // a conditional branch in it, where one edge (OtherDesg) goes + // back to the block. We know that the program doesn't get + // stuck in the infinite loop, so the condition must be such + // that OtherDest isn't branched through. Forward to CommonDest, + // and avoid an infinite loop at optimizer time. + if (OtherDest == BB) + OtherDest = CommonDest; + DEBUG(std::cerr << "FOLDING BRs:" << *PBI->getParent() << "AND: " << *BI->getParent()); |

