[llvm-commits] [llvm] r160969 - /llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Mon Jul 30 10:36:49 PDT 2012


Author: stoklund
Date: Mon Jul 30 12:36:49 2012
New Revision: 160969

URL: http://llvm.org/viewvc/llvm-project?rev=160969&view=rev
Log:
Verify that the CFG hasn't changed during invalidate().

The MachineTraceMetrics analysis must be invalidated before modifying
the CFG. This will catch some of the violations of that rule.

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

Modified: llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp?rev=160969&r1=160968&r2=160969&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp Mon Jul 30 12:36:49 2012
@@ -420,10 +420,15 @@
       for (MachineBasicBlock::const_pred_iterator
            I = MBB->pred_begin(), E = MBB->pred_end(); I != E; ++I) {
         TraceBlockInfo &TBI = BlockInfo[(*I)->getNumber()];
-        if (TBI.hasValidHeight() && TBI.Succ == MBB) {
+        if (!TBI.hasValidHeight())
+          continue;
+        if (TBI.Succ == MBB) {
           TBI.invalidateHeight();
           WorkList.push_back(*I);
+          continue;
         }
+        // Verify that TBI.Succ is actually a *I successor.
+        assert((!TBI.Succ || (*I)->isSuccessor(TBI.Succ)) && "CFG changed");
       }
     } while (!WorkList.empty());
   }
@@ -441,10 +446,15 @@
       for (MachineBasicBlock::const_succ_iterator
            I = MBB->succ_begin(), E = MBB->succ_end(); I != E; ++I) {
         TraceBlockInfo &TBI = BlockInfo[(*I)->getNumber()];
-        if (TBI.hasValidDepth() && TBI.Pred == MBB) {
+        if (!TBI.hasValidDepth())
+          continue;
+        if (TBI.Pred == MBB) {
           TBI.invalidateDepth();
           WorkList.push_back(*I);
+          continue;
         }
+        // Verify that TBI.Pred is actually a *I predecessor.
+        assert((!TBI.Pred || (*I)->isPredecessor(TBI.Pred)) && "CFG changed");
       }
     } while (!WorkList.empty());
   }





More information about the llvm-commits mailing list