SelectionDAG: add a -filter-view-dags option to llc
[oota-llvm.git] / lib / CodeGen / RegisterCoalescer.cpp
index bce469c23220097e52455f9f21791f6a8a71f432..c4a95e6dfb60863ef9e50496f1d61116db6e7fd1 100644 (file)
@@ -706,12 +706,12 @@ bool RegisterCoalescer::removeCopyByCommutingDef(const CoalescerPair &CP,
   // Update uses of IntA of the specific Val# with IntB.
   for (MachineRegisterInfo::use_iterator UI = MRI->use_begin(IntA.reg),
                                          UE = MRI->use_end();
-       UI != UE;) {
+       UI != UE; /* ++UI is below because of possible MI removal */) {
     MachineOperand &UseMO = *UI;
+    ++UI;
     if (UseMO.isUndef())
       continue;
     MachineInstr *UseMI = UseMO.getParent();
-    ++UI;
     if (UseMI->isDebugValue()) {
       // FIXME These don't have an instruction index.  Not clear we have enough
       // info to decide whether to do this replacement or not.  For now do it.