[llvm-commits] CVS: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Jun 12 13:18:13 PDT 2006
Changes in directory llvm/lib/Transforms/Utils:
SimplifyCFG.cpp updated: 1.97 -> 1.98
---
Log message:
Fix an infinite loop on Transforms/SimplifyCFG/2006-06-12-InfLoop.ll
---
Diffs of the changes: (+10 -1)
SimplifyCFG.cpp | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletion(-)
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.97 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.98
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.97 Sun May 14 13:45:44 2006
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Mon Jun 12 15:18:01 2006
@@ -1515,12 +1515,21 @@
// 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());
More information about the llvm-commits
mailing list