[llvm-commits] [llvm] r160904 - in /llvm/trunk/lib/CodeGen: MachineTraceMetrics.cpp MachineTraceMetrics.h

Jakob Stoklund Olesen stoklund at 2pi.dk
Fri Jul 27 16:58:36 PDT 2012


Author: stoklund
Date: Fri Jul 27 18:58:36 2012
New Revision: 160904

URL: http://llvm.org/viewvc/llvm-project?rev=160904&view=rev
Log:
Keep track of the head and tail of the trace through each block.

This makes it possible to quickly detect blocks that are outside the
trace.

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

Modified: llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp?rev=160904&r1=160903&r2=160904&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp Fri Jul 27 18:58:36 2012
@@ -142,6 +142,7 @@
   // Compute resources from trace above. The top block is simple.
   if (!TBI->Pred) {
     TBI->InstrDepth = 0;
+    TBI->Head = MBB->getNumber();
     return;
   }
 
@@ -151,6 +152,7 @@
   assert(PredTBI->hasValidDepth() && "Trace above has not been computed yet");
   const FixedBlockInfo *PredFBI = CT.getResources(TBI->Pred);
   TBI->InstrDepth = PredTBI->InstrDepth + PredFBI->InstrCount;
+  TBI->Head = PredTBI->Head;
 }
 
 // Update resource-related information in the TraceBlockInfo for MBB.
@@ -163,14 +165,17 @@
   TBI->InstrHeight = CT.getResources(MBB)->InstrCount;
 
   // The trace tail is done.
-  if (!TBI->Succ)
+  if (!TBI->Succ) {
+    TBI->Tail = MBB->getNumber();
     return;
+  }
 
   // Compute from the block below. A post-order traversal ensures the
   // predecessor is always computed first.
   TraceBlockInfo *SuccTBI = &BlockInfo[TBI->Succ->getNumber()];
   assert(SuccTBI->hasValidHeight() && "Trace below has not been computed yet");
   TBI->InstrHeight += SuccTBI->InstrHeight;
+  TBI->Tail = SuccTBI->Tail;
 }
 
 // Check if depth resources for MBB are valid and return the TBI.
@@ -454,12 +459,15 @@
 }
 
 void MachineTraceMetrics::Trace::print(raw_ostream &OS) const {
-  OS << TE.getName() << " trace:";
+  unsigned MBBNum = &TBI - &TE.BlockInfo[0];
+
+  OS << TE.getName() << " trace BB#" << TBI.Head << " --> BB#" << MBBNum
+     << " --> BB#" << TBI.Tail << ':';
   if (TBI.hasValidHeight() && TBI.hasValidDepth())
     OS << ' ' << getInstrCount() << " instrs.";
 
   const MachineTraceMetrics::TraceBlockInfo *Block = &TBI;
-  OS << "\n *";
+  OS << "\nBB#" << MBBNum;
   while (Block->hasValidDepth() && Block->Pred) {
     unsigned Num = Block->Pred->getNumber();
     OS << " <- BB#" << Num;
@@ -467,7 +475,7 @@
   }
 
   Block = &TBI;
-  OS << "\n *";
+  OS << "\n    ";
   while (Block->hasValidHeight() && Block->Succ) {
     unsigned Num = Block->Succ->getNumber();
     OS << " -> BB#" << Num;

Modified: llvm/trunk/lib/CodeGen/MachineTraceMetrics.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineTraceMetrics.h?rev=160904&r1=160903&r2=160904&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineTraceMetrics.h (original)
+++ llvm/trunk/lib/CodeGen/MachineTraceMetrics.h Fri Jul 27 18:58:36 2012
@@ -110,6 +110,12 @@
     /// Trace successor, or NULL for the last block in the trace.
     const MachineBasicBlock *Succ;
 
+    /// The block number of the head of the trace. (When hasValidDepth()).
+    unsigned Head;
+
+    /// The block number of the tail of the trace. (When hasValidHeight()).
+    unsigned Tail;
+
     /// Accumulated number of instructions in the trace above this block.
     /// Does not include instructions in this block.
     unsigned InstrDepth;





More information about the llvm-commits mailing list