summaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineTraceMetrics.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-07-27 23:58:36 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-07-27 23:58:36 +0000
commit0271a5fa29f73150fad891ca4c43a0a89a64b3bf (patch)
tree2ca8dedaf9361eb6bb393befaf5743eb368c599b /lib/CodeGen/MachineTraceMetrics.cpp
parentc23b933d5f8be9b51a1d22e717c0311f65f87dcd (diff)
downloadllvm-0271a5fa29f73150fad891ca4c43a0a89a64b3bf.tar.gz
llvm-0271a5fa29f73150fad891ca4c43a0a89a64b3bf.tar.bz2
llvm-0271a5fa29f73150fad891ca4c43a0a89a64b3bf.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160904 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineTraceMetrics.cpp')
-rw-r--r--lib/CodeGen/MachineTraceMetrics.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/CodeGen/MachineTraceMetrics.cpp b/lib/CodeGen/MachineTraceMetrics.cpp
index 557d47314e..8ae6f37030 100644
--- a/lib/CodeGen/MachineTraceMetrics.cpp
+++ b/lib/CodeGen/MachineTraceMetrics.cpp
@@ -142,6 +142,7 @@ computeDepthResources(const MachineBasicBlock *MBB) {
// 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 @@ computeDepthResources(const MachineBasicBlock *MBB) {
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 @@ computeHeightResources(const MachineBasicBlock *MBB) {
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 @@ MachineTraceMetrics::Ensemble::getTrace(const MachineBasicBlock *MBB) {
}
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 @@ void MachineTraceMetrics::Trace::print(raw_ostream &OS) const {
}
Block = &TBI;
- OS << "\n *";
+ OS << "\n ";
while (Block->hasValidHeight() && Block->Succ) {
unsigned Num = Block->Succ->getNumber();
OS << " -> BB#" << Num;