[PATCH] D100014: [GreedyRA ORE] Add function level spill/reloads stats

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 8 02:56:11 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa0e8738d4527: [GreedyRA ORE] Add function level spill/reloads stats (authored by skatkov).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100014/new/

https://reviews.llvm.org/D100014

Files:
  llvm/lib/CodeGen/RegAllocGreedy.cpp
  llvm/test/CodeGen/AArch64/arm64-spill-remarks.ll


Index: llvm/test/CodeGen/AArch64/arm64-spill-remarks.ll
===================================================================
--- llvm/test/CodeGen/AArch64/arm64-spill-remarks.ll
+++ llvm/test/CodeGen/AArch64/arm64-spill-remarks.ll
@@ -22,6 +22,8 @@
 ; REMARK: remark: /tmp/kk.c:2:20: 1 spills 1 reloads generated in loop{{$}}
 ; (loop:)
 ; REMARK: remark: /tmp/kk.c:1:20: 2 spills 2 reloads generated in loop{{$}}
+; (func:)
+; REMARK: remark: <unknown>:0:0: 3 spills 3 reloads generated in function{{$}}
 
 ; (loop3:)
 ; HOTNESS: remark: /tmp/kk.c:3:20: 1 spills 1 reloads generated in loop (hotness: 300)
@@ -74,6 +76,18 @@
 ; YAML:   - String:          ' reloads '
 ; YAML:   - String:          generated in loop
 ; YAML: ...
+; YAML: --- !Missed
+; YAML: Pass:            regalloc
+; YAML: Name:            SpillReload
+; YAML: Function:        fpr128
+; YAML: Hotness:         3
+; YAML: Args:
+; YAML:   - NumSpills:       '3'
+; YAML:   - String:          ' spills '
+; YAML:   - NumReloads:      '3'
+; YAML:   - String:          ' reloads '
+; YAML:   - String:          generated in function
+; YAML: ...
 
 ; THRESHOLD_YAML-NOT: Hotness:         300{{$}}
 ; THRESHOLD_YAML: --- !Missed
Index: llvm/lib/CodeGen/RegAllocGreedy.cpp
===================================================================
--- llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -3196,8 +3196,24 @@
 void RAGreedy::reportNumberOfSplillsReloads() {
   if (!ORE->allowExtraAnalysis(DEBUG_TYPE))
     return;
+  RAGreedyStats Stats;
   for (MachineLoop *L : *Loops)
-    reportNumberOfSplillsReloads(L);
+    Stats.add(reportNumberOfSplillsReloads(L));
+  // Process non-loop blocks.
+  for (MachineBasicBlock &MBB : *MF)
+    if (!Loops->getLoopFor(&MBB))
+      Stats.add(computeNumberOfSplillsReloads(MBB));
+  if (!Stats.isEmpty()) {
+    using namespace ore;
+
+    ORE->emit([&]() {
+      MachineOptimizationRemarkMissed R(DEBUG_TYPE, "SpillReload", DebugLoc(),
+                                        &MF->front());
+      Stats.report(R);
+      R << "generated in function";
+      return R;
+    });
+  }
 }
 
 bool RAGreedy::runOnMachineFunction(MachineFunction &mf) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100014.336044.patch
Type: text/x-patch
Size: 2190 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210408/e7521678/attachment.bin>


More information about the llvm-commits mailing list