From c362179b0a125c164cd7f256977d95fc15ba5edf Mon Sep 17 00:00:00 2001 From: Serguei Katkov Date: Fri, 9 Apr 2021 15:39:55 +0700 Subject: [PATCH] [GreedyRA ORE] Add debug location for function level report Reviewers: reames, MatzeB, anemet, thegameg Reviewed By: thegameg Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D100168 --- llvm/lib/CodeGen/RegAllocGreedy.cpp | 6 +++++- llvm/test/CodeGen/AArch64/arm64-spill-remarks.ll | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp index 295483fe4627..7941d827b0bd 100644 --- a/llvm/lib/CodeGen/RegAllocGreedy.cpp +++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp @@ -69,6 +69,7 @@ #include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/IR/DebugInfoMetadata.h" #include #include #include @@ -3215,7 +3216,10 @@ void RAGreedy::reportNumberOfSplillsReloads() { using namespace ore; ORE->emit([&]() { - MachineOptimizationRemarkMissed R(DEBUG_TYPE, "SpillReload", DebugLoc(), + DebugLoc Loc; + if (auto *SP = MF->getFunction().getSubprogram()) + Loc = DILocation::get(SP->getContext(), SP->getLine(), 1, SP); + MachineOptimizationRemarkMissed R(DEBUG_TYPE, "SpillReload", Loc, &MF->front()); Stats.report(R); R << "generated in function"; diff --git a/llvm/test/CodeGen/AArch64/arm64-spill-remarks.ll b/llvm/test/CodeGen/AArch64/arm64-spill-remarks.ll index 53a2a784cd53..e7c8408a7629 100644 --- a/llvm/test/CodeGen/AArch64/arm64-spill-remarks.ll +++ b/llvm/test/CodeGen/AArch64/arm64-spill-remarks.ll @@ -23,7 +23,7 @@ ; (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{{$}} +; REMARK: remark: /tmp/kk.c:1:1: 3 spills 3 reloads generated in function{{$}} ; (loop3:) ; HOTNESS: remark: /tmp/kk.c:3:20: 1 spills 1 reloads generated in loop (hotness: 300) @@ -79,6 +79,7 @@ ; YAML: --- !Missed ; YAML: Pass: regalloc ; YAML: Name: SpillReload +; YAML: DebugLoc: { File: '/tmp/kk.c', Line: 1, Column: 1 } ; YAML: Function: fpr128 ; YAML: Hotness: 3 ; YAML: Args: @@ -104,7 +105,7 @@ ; THRESHOLD_YAML: - String: generated in loop ; THRESHOLD_YAML: ... -define void @fpr128(<4 x float>* %p) nounwind ssp !prof !11 { +define void @fpr128(<4 x float>* %p) nounwind ssp !prof !11 !dbg !6 { entry: br label %loop, !dbg !8