[llvm-commits] [llvm] r160905 - in /llvm/trunk/lib/CodeGen: EarlyIfConversion.cpp MachineTraceMetrics.cpp MachineTraceMetrics.h
Jakob Stoklund Olesen
stoklund at 2pi.dk
Fri Jul 27 16:58:39 PDT 2012
Author: stoklund
Date: Fri Jul 27 18:58:38 2012
New Revision: 160905
URL: http://llvm.org/viewvc/llvm-project?rev=160905&view=rev
Log:
Add more debug output to MachineTraceMetrics.
Modified:
llvm/trunk/lib/CodeGen/EarlyIfConversion.cpp
llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp
llvm/trunk/lib/CodeGen/MachineTraceMetrics.h
Modified: llvm/trunk/lib/CodeGen/EarlyIfConversion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/EarlyIfConversion.cpp?rev=160905&r1=160904&r2=160905&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/EarlyIfConversion.cpp (original)
+++ llvm/trunk/lib/CodeGen/EarlyIfConversion.cpp Fri Jul 27 18:58:38 2012
@@ -590,6 +590,7 @@
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 @@
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;
}
Modified: llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp?rev=160905&r1=160904&r2=160905&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp Fri Jul 27 18:58:38 2012
@@ -211,7 +211,7 @@
// 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 @@
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];
Modified: llvm/trunk/lib/CodeGen/MachineTraceMetrics.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineTraceMetrics.h?rev=160905&r1=160904&r2=160905&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineTraceMetrics.h (original)
+++ llvm/trunk/lib/CodeGen/MachineTraceMetrics.h Fri Jul 27 18:58:38 2012
@@ -105,9 +105,11 @@
/// 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 @@
/// 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:
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 @@
return OS;
}
+inline raw_ostream &operator<<(raw_ostream &OS,
+ const MachineTraceMetrics::Ensemble &En) {
+ En.print(OS);
+ return OS;
+}
} // end namespace llvm
#endif
More information about the llvm-commits
mailing list