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) { 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: :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