[llvm-mca] Strip leading tabs and spaces from instruction strings before printing. NFC
llvm-svn: 332361
diff --git a/llvm/tools/llvm-mca/InstructionInfoView.cpp b/llvm/tools/llvm-mca/InstructionInfoView.cpp
index 289ca03..76d63d2 100644
--- a/llvm/tools/llvm-mca/InstructionInfoView.cpp
+++ b/llvm/tools/llvm-mca/InstructionInfoView.cpp
@@ -25,11 +25,14 @@
const MCSchedModel &SM = STI.getSchedModel();
unsigned Instructions = Source.size();
+ std::string Instruction;
+ raw_string_ostream InstrStream(Instruction);
+
TempStream << "\n\nInstruction Info:\n";
TempStream << "[1]: #uOps\n[2]: Latency\n[3]: RThroughput\n"
<< "[4]: MayLoad\n[5]: MayStore\n[6]: HasSideEffects\n\n";
- TempStream << "[1] [2] [3] [4] [5] [6]\tInstructions:\n";
+ TempStream << "[1] [2] [3] [4] [5] [6] Instructions:\n";
for (unsigned I = 0, E = Instructions; I < E; ++I) {
const MCInst &Inst = Source.getMCInstFromIndex(I);
const MCInstrDesc &MCDesc = MCII.get(Inst.getOpcode());
@@ -65,8 +68,15 @@
TempStream << (MCDesc.mayLoad() ? " * " : " ");
TempStream << (MCDesc.mayStore() ? " * " : " ");
TempStream << (MCDesc.hasUnmodeledSideEffects() ? " * " : " ");
- MCIP.printInst(&Inst, TempStream, "", STI);
- TempStream << '\n';
+
+ MCIP.printInst(&Inst, InstrStream, "", STI);
+ InstrStream.flush();
+
+ // Consume any tabs or spaces at the beginning of the string.
+ StringRef Str(Instruction);
+ Str = Str.ltrim();
+ TempStream << " " << Str << '\n';
+ Instruction = "";
}
TempStream.flush();
diff --git a/llvm/tools/llvm-mca/ResourcePressureView.cpp b/llvm/tools/llvm-mca/ResourcePressureView.cpp
index 6fd23cc..874aa6d 100644
--- a/llvm/tools/llvm-mca/ResourcePressureView.cpp
+++ b/llvm/tools/llvm-mca/ResourcePressureView.cpp
@@ -144,7 +144,10 @@
TempStream << "\n\nResource pressure by instruction:\n";
printColumnNames(TempStream, STI.getSchedModel());
- TempStream << "\tInstructions:\n";
+ TempStream << "Instructions:\n";
+
+ std::string Instruction;
+ raw_string_ostream InstrStream(Instruction);
for (unsigned I = 0, E = Source.size(); I < E; ++I) {
for (unsigned J = 0; J < NumResourceUnits; ++J) {
@@ -152,8 +155,16 @@
printResourcePressure(TempStream, Usage / Executions);
}
- MCIP.printInst(&Source.getMCInstFromIndex(I), TempStream, "", STI);
- TempStream << '\n';
+ MCIP.printInst(&Source.getMCInstFromIndex(I), InstrStream, "", STI);
+ InstrStream.flush();
+ StringRef Str(Instruction);
+
+ // Remove any tabs or spaces at the beginning of the instruction.
+ Str = Str.ltrim();
+
+ TempStream << Str << '\n';
+ Instruction = "";
+
TempStream.flush();
OS << Buffer;
Buffer = "";
diff --git a/llvm/tools/llvm-mca/TimelineView.cpp b/llvm/tools/llvm-mca/TimelineView.cpp
index 952b5bd..71ebb44 100644
--- a/llvm/tools/llvm-mca/TimelineView.cpp
+++ b/llvm/tools/llvm-mca/TimelineView.cpp
@@ -98,7 +98,7 @@
OS << ' ';
if (Entry.Executions == 0) {
- OS << " - - - - ";
+ OS << " - - - - ";
} else {
double AverageTime1, AverageTime2, AverageTime3;
unsigned Executions = Entry.Executions;
@@ -133,13 +133,25 @@
<< "[3]: Average time elapsed from WB until retire stage\n\n";
TempStream << " [0] [1] [2] [3]\n";
+ // Use a different string stream for the instruction.
+ std::string Instruction;
+ raw_string_ostream InstrStream(Instruction);
+
for (unsigned I = 0, E = WaitTime.size(); I < E; ++I) {
printWaitTimeEntry(TempStream, WaitTime[I], I);
// Append the instruction info at the end of the line.
const MCInst &Inst = AsmSequence.getMCInstFromIndex(I);
- MCIP.printInst(&Inst, TempStream, "", STI);
- TempStream << '\n';
+
+ MCIP.printInst(&Inst, InstrStream, "", STI);
+ InstrStream.flush();
+
+ // Consume any tabs or spaces at the beginning of the string.
+ StringRef Str(Instruction);
+ Str = Str.ltrim();
+ TempStream << " " << Str << '\n';
TempStream.flush();
+ Instruction = "";
+
OS << Buffer;
Buffer = "";
}
@@ -210,6 +222,10 @@
TempStream.flush();
OS << Buffer;
+ // Use a different string stream for the instruction.
+ std::string Instruction;
+ raw_string_ostream InstrStream(Instruction);
+
for (unsigned I = 0, E = Timeline.size(); I < E; ++I) {
Buffer = "";
const TimelineViewEntry &Entry = Timeline[I];
@@ -221,9 +237,15 @@
printTimelineViewEntry(TempStream, Entry, Iteration, SourceIndex);
// Append the instruction info at the end of the line.
const MCInst &Inst = AsmSequence.getMCInstFromIndex(I);
- MCIP.printInst(&Inst, TempStream, "", STI);
- TempStream << '\n';
+ MCIP.printInst(&Inst, InstrStream, "", STI);
+ InstrStream.flush();
+
+ // Consume any tabs or spaces at the beginning of the string.
+ StringRef Str(Instruction);
+ Str = Str.ltrim();
+ TempStream << " " << Str << '\n';
TempStream.flush();
+ Instruction = "";
OS << Buffer;
}
}