[llvm] r332361 - [llvm-mca] Strip leading tabs and spaces from instruction strings before printing. NFC
Andrea Di Biagio via llvm-commits
llvm-commits at lists.llvm.org
Tue May 15 08:18:05 PDT 2018
Author: adibiagio
Date: Tue May 15 08:18:05 2018
New Revision: 332361
URL: http://llvm.org/viewvc/llvm-project?rev=332361&view=rev
Log:
[llvm-mca] Strip leading tabs and spaces from instruction strings before printing. NFC
Modified:
llvm/trunk/tools/llvm-mca/InstructionInfoView.cpp
llvm/trunk/tools/llvm-mca/ResourcePressureView.cpp
llvm/trunk/tools/llvm-mca/TimelineView.cpp
Modified: llvm/trunk/tools/llvm-mca/InstructionInfoView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/InstructionInfoView.cpp?rev=332361&r1=332360&r2=332361&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/InstructionInfoView.cpp (original)
+++ llvm/trunk/tools/llvm-mca/InstructionInfoView.cpp Tue May 15 08:18:05 2018
@@ -25,11 +25,14 @@ void InstructionInfoView::printView(raw_
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 @@ void InstructionInfoView::printView(raw_
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();
Modified: llvm/trunk/tools/llvm-mca/ResourcePressureView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/ResourcePressureView.cpp?rev=332361&r1=332360&r2=332361&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/ResourcePressureView.cpp (original)
+++ llvm/trunk/tools/llvm-mca/ResourcePressureView.cpp Tue May 15 08:18:05 2018
@@ -144,7 +144,10 @@ void ResourcePressureView::printResource
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 @@ void ResourcePressureView::printResource
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 = "";
Modified: llvm/trunk/tools/llvm-mca/TimelineView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/TimelineView.cpp?rev=332361&r1=332360&r2=332361&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/TimelineView.cpp (original)
+++ llvm/trunk/tools/llvm-mca/TimelineView.cpp Tue May 15 08:18:05 2018
@@ -98,7 +98,7 @@ void TimelineView::printWaitTimeEntry(ra
OS << ' ';
if (Entry.Executions == 0) {
- OS << " - - - - ";
+ OS << " - - - - ";
} else {
double AverageTime1, AverageTime2, AverageTime3;
unsigned Executions = Entry.Executions;
@@ -133,13 +133,25 @@ void TimelineView::printAverageWaitTimes
<< "[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 @@ void TimelineView::printTimeline(raw_ost
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 @@ void TimelineView::printTimeline(raw_ost
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;
}
}
More information about the llvm-commits
mailing list