summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-07-27 23:58:38 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-07-27 23:58:38 +0000
commit08f6ef6a7807250d84446661b7a6ec4afa762099 (patch)
treed909f9ba592f48965801427b4a6dbd162b77c65f
parent0271a5fa29f73150fad891ca4c43a0a89a64b3bf (diff)
downloadllvm-08f6ef6a7807250d84446661b7a6ec4afa762099.tar.gz
llvm-08f6ef6a7807250d84446661b7a6ec4afa762099.tar.bz2
llvm-08f6ef6a7807250d84446661b7a6ec4afa762099.tar.xz
Add more debug output to MachineTraceMetrics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160905 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/EarlyIfConversion.cpp6
-rw-r--r--lib/CodeGen/MachineTraceMetrics.cpp33
-rw-r--r--lib/CodeGen/MachineTraceMetrics.h12
3 files changed, 48 insertions, 3 deletions
diff --git a/lib/CodeGen/EarlyIfConversion.cpp b/lib/CodeGen/EarlyIfConversion.cpp
index cfe3e9d7e1..a19e9ad66f 100644
--- a/lib/CodeGen/EarlyIfConversion.cpp
+++ b/lib/CodeGen/EarlyIfConversion.cpp
@@ -590,6 +590,7 @@ void EarlyIfConverter::invalidateTraces() {
Traces->invalidate(IfConv.Tail);
Traces->invalidate(IfConv.TBB);
Traces->invalidate(IfConv.FBB);
+ DEBUG(if (MinInstr) MinInstr->print(dbgs()));
}
/// Apply cost model and heuristics to the if-conversion in IfConv.
@@ -598,7 +599,10 @@ void EarlyIfConverter::invalidateTraces() {
bool EarlyIfConverter::shouldConvertIf() {
if (!MinInstr)
MinInstr = Traces->getEnsemble(MachineTraceMetrics::TS_MinInstrCount);
- DEBUG(dbgs() << MinInstr->getTrace(IfConv.Head));
+ DEBUG({
+ dbgs() << MinInstr->getTrace(IfConv.Head);
+ MinInstr->print(dbgs());
+ });
return true;
}
diff --git a/lib/CodeGen/MachineTraceMetrics.cpp b/lib/CodeGen/MachineTraceMetrics.cpp
index 8ae6f37030..54c886bdda 100644
--- a/lib/CodeGen/MachineTraceMetrics.cpp
+++ b/lib/CodeGen/MachineTraceMetrics.cpp
@@ -211,7 +211,7 @@ getHeightResources(const MachineBasicBlock *MBB) const {
// instructions.
namespace {
class MinInstrCountEnsemble : public MachineTraceMetrics::Ensemble {
- const char *getName() { return "MinInstr"; }
+ const char *getName() const { return "MinInstr"; }
const MachineBasicBlock *pickTracePred(const MachineBasicBlock*);
const MachineBasicBlock *pickTraceSucc(const MachineBasicBlock*);
@@ -458,6 +458,37 @@ MachineTraceMetrics::Ensemble::getTrace(const MachineBasicBlock *MBB) {
return Trace(*this, BlockInfo[MBB->getNumber()]);
}
+void MachineTraceMetrics::Ensemble::print(raw_ostream &OS) const {
+ OS << getName() << " ensemble:\n";
+ for (unsigned i = 0, e = BlockInfo.size(); i != e; ++i) {
+ OS << " BB#" << i << '\t';
+ BlockInfo[i].print(OS);
+ OS << '\n';
+ }
+}
+
+void MachineTraceMetrics::TraceBlockInfo::print(raw_ostream &OS) const {
+ if (hasValidDepth()) {
+ OS << "depth=" << InstrDepth;
+ if (Pred)
+ OS << " pred=BB#" << Pred->getNumber();
+ else
+ OS << " pred=null";
+ OS << " head=BB#" << Head;
+ } else
+ OS << "depth invalid";
+ OS << ", ";
+ if (hasValidHeight()) {
+ OS << "height=" << InstrHeight;
+ if (Succ)
+ OS << " succ=BB#" << Succ->getNumber();
+ else
+ OS << " succ=null";
+ OS << " tail=BB#" << Tail;
+ } else
+ OS << "height invalid";
+}
+
void MachineTraceMetrics::Trace::print(raw_ostream &OS) const {
unsigned MBBNum = &TBI - &TE.BlockInfo[0];
diff --git a/lib/CodeGen/MachineTraceMetrics.h b/lib/CodeGen/MachineTraceMetrics.h
index 26136fa9ee..40da272932 100644
--- a/lib/CodeGen/MachineTraceMetrics.h
+++ b/lib/CodeGen/MachineTraceMetrics.h
@@ -105,9 +105,11 @@ public:
/// block in a trace ensemble.
struct TraceBlockInfo {
/// Trace predecessor, or NULL for the first block in the trace.
+ /// Valid when hasValidDepth().
const MachineBasicBlock *Pred;
/// Trace successor, or NULL for the last block in the trace.
+ /// Valid when hasValidHeight().
const MachineBasicBlock *Succ;
/// The block number of the head of the trace. (When hasValidDepth()).
@@ -139,6 +141,8 @@ public:
/// Invalidate height resources when a block below this one has changed.
void invalidateHeight() { InstrHeight = ~0u; }
+
+ void print(raw_ostream&) const;
};
/// A trace represents a plausible sequence of executed basic blocks that
@@ -180,7 +184,8 @@ public:
public:
virtual ~Ensemble();
- virtual const char *getName() =0;
+ virtual const char *getName() const =0;
+ void print(raw_ostream&) const;
void invalidate(const MachineBasicBlock *MBB);
/// Get the trace that passes through MBB.
@@ -219,6 +224,11 @@ inline raw_ostream &operator<<(raw_ostream &OS,
return OS;
}
+inline raw_ostream &operator<<(raw_ostream &OS,
+ const MachineTraceMetrics::Ensemble &En) {
+ En.print(OS);
+ return OS;
+}
} // end namespace llvm
#endif