[llvm] [llvm-mca] Add command line option -call-latency (PR #92958)

Michael Maitland via llvm-commits llvm-commits at lists.llvm.org
Tue May 21 15:57:41 PDT 2024


================
@@ -220,17 +221,18 @@ static void initializeUsedResources(InstrDesc &ID,
 
 static void computeMaxLatency(InstrDesc &ID, const MCInstrDesc &MCDesc,
                               const MCSchedClassDesc &SCDesc,
-                              const MCSubtargetInfo &STI) {
+                              const MCSubtargetInfo &STI,
+                              unsigned CallLatency) {
   if (MCDesc.isCall()) {
     // We cannot estimate how long this call will take.
-    // Artificially set an arbitrarily high latency (100cy).
-    ID.MaxLatency = 100U;
+    // Artificially set an arbitrarily high latency (default: 100cy).
+    ID.MaxLatency = CallLatency;
     return;
   }
 
   int Latency = MCSchedModel::computeInstrLatency(STI, SCDesc);
-  // If latency is unknown, then conservatively assume a MaxLatency of 100cy.
-  ID.MaxLatency = Latency < 0 ? 100U : static_cast<unsigned>(Latency);
+  // If latency is unknown, then conservatively assume a MaxLatency set for calls (default: 100cy).
----------------
michaelmaitland wrote:

nit: I think this line may be too long according to [LLVM Coding Standards](https://llvm.org/docs/CodingStandards.html#source-code-width). Can you either format it accordingly or drop the default part since it no longer defaults to 100 inside InstrBuilder. I am content with either approach. If you end up going with the latter, please also remove the `(default: 100cy)` above on line 228.

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


More information about the llvm-commits mailing list