diff options
author | Chris Lattner <sabre@nondot.org> | 2006-02-18 00:33:17 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-02-18 00:33:17 +0000 |
commit | 299520de7c5358a30dd7786cf9fe9f9a6ce37d94 (patch) | |
tree | 2eee512234c9fd59eb1ac1d3e9d97f1a528f8d86 | |
parent | 6a9f57c7ef62f81f014166dc6a49aa9d2202d0e1 (diff) | |
download | external_llvm-299520de7c5358a30dd7786cf9fe9f9a6ce37d94.zip external_llvm-299520de7c5358a30dd7786cf9fe9f9a6ce37d94.tar.gz external_llvm-299520de7c5358a30dd7786cf9fe9f9a6ce37d94.tar.bz2 |
Fix Transforms/SimplifyCFG/2006-02-17-InfiniteUnroll.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26275 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 1159cd3..3c6c02f 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1426,8 +1426,8 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { PBI->setSuccessor(1, OldTrue); } - if (PBI->getSuccessor(0) == TrueDest || - PBI->getSuccessor(1) == FalseDest) { + if ((PBI->getSuccessor(0) == TrueDest && FalseDest != BB) || + (PBI->getSuccessor(1) == FalseDest && TrueDest != BB)) { // Clone Cond into the predecessor basic block, and or/and the // two conditions together. Instruction *New = Cond->clone(); @@ -1512,6 +1512,12 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { PBIOp = BIOp = -1; } + // Check to make sure that the other destination of this branch + // isn't BB itself. If so, this is an infinite loop that will + // 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); |