[GreedyRA ORE] Compute ORE stats if extra analysis is enabled
authorSerguei Katkov <serguei.katkov@azul.com>
Tue, 6 Apr 2021 14:32:02 +0000 (21:32 +0700)
committerSerguei Katkov <serguei.katkov@azul.com>
Thu, 8 Apr 2021 07:24:18 +0000 (14:24 +0700)
To save compile time, avoid computation of stats if ORE will not emit it.
The motivation is to add more stats and compute it only if it will dumped.

Reviewers: reames, MatzeB, anemet, thegameg
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D100010

llvm/lib/CodeGen/RegAllocGreedy.cpp

index 26e7a1f..d3a9aeb 100644 (file)
@@ -552,13 +552,7 @@ private:
                                     unsigned &FoldedSpills);
 
   /// Report the number of spills and reloads for each loop.
-  void reportNumberOfSplillsReloads() {
-    for (MachineLoop *L : *Loops) {
-      unsigned Reloads, FoldedReloads, Spills, FoldedSpills;
-      reportNumberOfSplillsReloads(L, Reloads, FoldedReloads, Spills,
-                                   FoldedSpills);
-    }
-  }
+  void reportNumberOfSplillsReloads();
 };
 
 } // end anonymous namespace
@@ -3183,6 +3177,16 @@ void RAGreedy::reportNumberOfSplillsReloads(MachineLoop *L, unsigned &Reloads,
   }
 }
 
+void RAGreedy::reportNumberOfSplillsReloads() {
+  if (!ORE->allowExtraAnalysis(DEBUG_TYPE))
+    return;
+  for (MachineLoop *L : *Loops) {
+    unsigned Reloads, FoldedReloads, Spills, FoldedSpills;
+    reportNumberOfSplillsReloads(L, Reloads, FoldedReloads, Spills,
+                                 FoldedSpills);
+  }
+}
+
 bool RAGreedy::runOnMachineFunction(MachineFunction &mf) {
   LLVM_DEBUG(dbgs() << "********** GREEDY REGISTER ALLOCATION **********\n"
                     << "********** Function: " << mf.getName() << '\n');