[llvm] r175383 - Fix a conversion from a forward iterator to a reverse iterator in

Cameron Zwarich zwarich at apple.com
Sat Feb 16 17:45:04 PST 2013


Author: zwarich
Date: Sat Feb 16 19:45:04 2013
New Revision: 175383

URL: http://llvm.org/viewvc/llvm-project?rev=175383&view=rev
Log:
Fix a conversion from a forward iterator to a reverse iterator in
MachineBasicBlock::SplitCriticalEdge. Since this is an iterator rather than
an instr_iterator, the isBundled() check only passes if getFirstTerminator()
returned end() and the garbage memory happens to lean that way.

Multiple successors can be present without any terminator instructions in the
case of exception handling with a fallthrough.

Modified:
    llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp

Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=175383&r1=175382&r2=175383&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Sat Feb 16 19:45:04 2013
@@ -852,12 +852,13 @@ MachineBasicBlock::SplitCriticalEdge(Mac
     // Update all intervals for registers whose uses may have been modified by
     // updateTerminator().
     iterator FirstTerminator = getFirstTerminator();
-    MachineInstr *FirstTerminatorMI = FirstTerminator;
-    if (FirstTerminatorMI->isBundled())
-      FirstTerminatorMI = getBundleStart(FirstTerminatorMI);
-    reverse_iterator PreTerminators =
-      (FirstTerminator == begin()) ? rend()
-                                   : reverse_iterator(FirstTerminatorMI);
+    reverse_iterator PreTerminators;
+    if (FirstTerminator == begin())
+      PreTerminators = rend();
+    else if (FirstTerminator == end())
+      PreTerminators = rbegin();
+    else
+      PreTerminators = reverse_iterator(FirstTerminator);
     LIS->repairIntervalsInRange(this, rbegin(), PreTerminators, UsedRegs);
   }
 





More information about the llvm-commits mailing list