[llvm] [MCA] New option -scheduling-info (PR #130574)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 10 03:29:28 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 24f0901f7ef5f4f8e8ae6a2138b18e434b1b941f aa94f415f613f54b56a3ed6cce8e234ecf1e2c9c --extensions cpp,h -- llvm/include/llvm/MC/MCSchedule.h llvm/lib/MC/MCSchedule.cpp llvm/tools/llvm-mca/Views/InstructionInfoView.cpp llvm/tools/llvm-mca/Views/InstructionInfoView.h llvm/tools/llvm-mca/llvm-mca.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/tools/llvm-mca/Views/InstructionInfoView.cpp b/llvm/tools/llvm-mca/Views/InstructionInfoView.cpp
index 1b0b4c18c8..489d766ac6 100644
--- a/llvm/tools/llvm-mca/Views/InstructionInfoView.cpp
+++ b/llvm/tools/llvm-mca/Views/InstructionInfoView.cpp
@@ -20,7 +20,7 @@ namespace llvm {
 namespace mca {
 
 void InstructionInfoView::getComment(const MCInst &MCI,
-                                    std::string &CommentString) const {
+                                     std::string &CommentString) const {
   StringRef s = MCI.getLoc().getPointer();
   std::string InstrStr;
   size_t pos = 0, pos_cmt = 0;
@@ -143,11 +143,11 @@ void InstructionInfoView::printView(raw_ostream &OS) const {
 
   if (PrintSchedulingInfo) {
     if (PrintEncodings)
-	  WithColor::warning()
-	      << "No encodings printed when -scheduling-info option enabled.\n";
+      WithColor::warning()
+          << "No encodings printed when -scheduling-info option enabled.\n";
     if (PrintBarriers)
-          WithColor::warning()
-	      << "No barrier printed when -scheduling-info option enabled.\n";
+      WithColor::warning()
+          << "No barrier printed when -scheduling-info option enabled.\n";
 
     printSchedulingInfoView(OS);
     return;
@@ -269,27 +269,28 @@ void InstructionInfoView::collectData(
     if (PrintSchedulingInfo) {
       // Get latency with bypass
       IIVDEntry.Bypass =
-        IIVDEntry.Latency - MCSchedModel::getBypassDelayCycles(STI, SCDesc);
+          IIVDEntry.Latency - MCSchedModel::getBypassDelayCycles(STI, SCDesc);
       IIVDEntry.OpcodeName = (std::string)MCII.getName(Inst.getOpcode());
       raw_string_ostream TempStream(IIVDEntry.Resources);
       const MCWriteProcResEntry *Index = STI.getWriteProcResBegin(&SCDesc);
       const MCWriteProcResEntry *Last = STI.getWriteProcResEnd(&SCDesc);
       auto sep = "";
       for (; Index != Last; ++Index) {
-	if (!Index->ReleaseAtCycle)
-	  continue;
-	const MCProcResourceDesc *MCProc =
-          SM.getProcResource(Index->ProcResourceIdx);
-	if (Index->ReleaseAtCycle > 1) {
-	  // Output ReleaseAtCycle between [] if not 1 (default)
-	  // This is to be able to evaluate throughput.
-	  // See getReciprocalThroughput in MCSchedule.cpp
-	  // TODO: report AcquireAtCycle to check this scheduling info.
-	  TempStream << sep << format("%s[%d]", MCProc->Name, Index->ReleaseAtCycle);
-	} else {
-	  TempStream << sep << format("%s", MCProc->Name);
-	}
-	sep = ",";
+        if (!Index->ReleaseAtCycle)
+          continue;
+        const MCProcResourceDesc *MCProc =
+            SM.getProcResource(Index->ProcResourceIdx);
+        if (Index->ReleaseAtCycle > 1) {
+          // Output ReleaseAtCycle between [] if not 1 (default)
+          // This is to be able to evaluate throughput.
+          // See getReciprocalThroughput in MCSchedule.cpp
+          // TODO: report AcquireAtCycle to check this scheduling info.
+          TempStream << sep
+                     << format("%s[%d]", MCProc->Name, Index->ReleaseAtCycle);
+        } else {
+          TempStream << sep << format("%s", MCProc->Name);
+        }
+        sep = ",";
       }
       TempStream.flush();
     }
diff --git a/llvm/tools/llvm-mca/Views/InstructionInfoView.h b/llvm/tools/llvm-mca/Views/InstructionInfoView.h
index 2ead2a6cee..4bdcc4283f 100644
--- a/llvm/tools/llvm-mca/Views/InstructionInfoView.h
+++ b/llvm/tools/llvm-mca/Views/InstructionInfoView.h
@@ -95,14 +95,14 @@ public:
                       llvm::MCInstPrinter &IP,
                       ArrayRef<UniqueInst> LoweredInsts,
                       bool ShouldPrintBarriers, bool ShouldPrintSchedulingInfo,
-		      const InstrumentManager &IM,
-		      const InstToInstrumentsT &InstToInstruments)
+                      const InstrumentManager &IM,
+                      const InstToInstrumentsT &InstToInstruments)
       : InstructionView(ST, IP, S), MCII(II), CE(C),
         PrintEncodings(ShouldPrintEncodings),
         PrintBarriers(ShouldPrintBarriers),
-	PrintSchedulingInfo(ShouldPrintSchedulingInfo),
-	LoweredInsts(LoweredInsts), IM(IM),
-	InstToInstruments(InstToInstruments) {}
+        PrintSchedulingInfo(ShouldPrintSchedulingInfo),
+        LoweredInsts(LoweredInsts), IM(IM),
+        InstToInstruments(InstToInstruments) {}
 
   void printView(llvm::raw_ostream &OS) const override;
   StringRef getNameAsString() const override { return "InstructionInfoView"; }
diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp
index a9680032a9..b07a8ecb1f 100644
--- a/llvm/tools/llvm-mca/llvm-mca.cpp
+++ b/llvm/tools/llvm-mca/llvm-mca.cpp
@@ -259,10 +259,11 @@ static cl::opt<bool> ShowBarriers(
     cl::desc("Print memory barrier information in the instruction info view"),
     cl::cat(ViewOptions), cl::init(false));
 
-static cl::opt<bool> ShowSchedulingInfo(
-    "scheduling-info",
-    cl::desc("Print the instruction scheduling information in the instruction info view"),
-    cl::cat(ViewOptions), cl::init(false));
+static cl::opt<bool>
+    ShowSchedulingInfo("scheduling-info",
+                       cl::desc("Print the instruction scheduling information "
+                                "in the instruction info view"),
+                       cl::cat(ViewOptions), cl::init(false));
 
 static cl::opt<bool> DisableCustomBehaviour(
     "disable-cb",
@@ -683,13 +684,13 @@ int main(int argc, char **argv) {
 
       // Create the views for this pipeline, execute, and emit a report.
       if (PrintInstructionInfoView) {
-	Printer.addView(std::make_unique<mca::InstructionInfoView>(
-              *STI, *MCII, CE, ShowEncoding, Insts, *IP, LoweredSequence,
-              ShowBarriers, ShowSchedulingInfo, *IM, InstToInstruments));
+        Printer.addView(std::make_unique<mca::InstructionInfoView>(
+            *STI, *MCII, CE, ShowEncoding, Insts, *IP, LoweredSequence,
+            ShowBarriers, ShowSchedulingInfo, *IM, InstToInstruments));
       }
 
       Printer.addView(
-	   std::make_unique<mca::ResourcePressureView>(*STI, *IP, Insts));
+          std::make_unique<mca::ResourcePressureView>(*STI, *IP, Insts));
 
       if (!runPipeline(*P))
         return 1;

``````````

</details>


https://github.com/llvm/llvm-project/pull/130574


More information about the llvm-commits mailing list