aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-07-30 17:36:49 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-07-30 17:36:49 +0000
commitee31ae12e8a7b843e97285b321cb1f485cd77248 (patch)
tree9b5548e631212c592f2c32a6d48765d8670a28ca /lib/CodeGen
parentf192b507a33b2ab2e2f6271bb1ea6ed4fbda69e7 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160969 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/MachineTraceMetrics.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/CodeGen/MachineTraceMetrics.cpp b/lib/CodeGen/MachineTraceMetrics.cpp
index 54c886bdda..d5ff128bf2 100644
--- a/lib/CodeGen/MachineTraceMetrics.cpp
+++ b/lib/CodeGen/MachineTraceMetrics.cpp
@@ -420,10 +420,15 @@ MachineTraceMetrics::Ensemble::invalidate(const MachineBasicBlock *BadMBB) {
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 @@ MachineTraceMetrics::Ensemble::invalidate(const MachineBasicBlock *BadMBB) {
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());
}