use valid bits to avoid unnecessary machine trace metric recomputations
authorSanjay Patel <spatel@rotateright.com>
Sat, 4 Jul 2015 15:00:28 +0000 (15:00 +0000)
committerSanjay Patel <spatel@rotateright.com>
Sat, 4 Jul 2015 15:00:28 +0000 (15:00 +0000)
Although this does cut the number of traces recomputed by ~10% for the
test case mentioned in http://reviews.llvm.org/D10460, it doesn't
make a dent in the overall performance. That example needs to be more
selective when invalidating traces.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241393 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineTraceMetrics.cpp

index f9adba0b35c45537f292cf5f03a22f45a29ad58c..10a984cbef62749f90ad8d055ab98b4837a33c08 100644 (file)
@@ -1131,11 +1131,16 @@ computeInstrHeights(const MachineBasicBlock *MBB) {
 
 MachineTraceMetrics::Trace
 MachineTraceMetrics::Ensemble::getTrace(const MachineBasicBlock *MBB) {
-  // FIXME: Check cache tags, recompute as needed.
-  computeTrace(MBB);
-  computeInstrDepths(MBB);
-  computeInstrHeights(MBB);
-  return Trace(*this, BlockInfo[MBB->getNumber()]);
+  TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
+
+  if (!TBI.hasValidDepth() || !TBI.hasValidHeight())
+    computeTrace(MBB);
+  if (!TBI.HasValidInstrDepths)
+    computeInstrDepths(MBB);
+  if (!TBI.HasValidInstrHeights)
+    computeInstrHeights(MBB);
+  
+  return Trace(*this, TBI);
 }
 
 unsigned