Skip to content

Commit c362179

Browse files
author
Serguei Katkov
committed
[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
1 parent 80aa9b0 commit c362179

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

llvm/lib/CodeGen/RegAllocGreedy.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include "llvm/Support/Timer.h"
7070
#include "llvm/Support/raw_ostream.h"
7171
#include "llvm/Target/TargetMachine.h"
72+
#include "llvm/IR/DebugInfoMetadata.h"
7273
#include <algorithm>
7374
#include <cassert>
7475
#include <cstdint>
@@ -3215,7 +3216,10 @@ void RAGreedy::reportNumberOfSplillsReloads() {
32153216
using namespace ore;
32163217

32173218
ORE->emit([&]() {
3218-
MachineOptimizationRemarkMissed R(DEBUG_TYPE, "SpillReload", DebugLoc(),
3219+
DebugLoc Loc;
3220+
if (auto *SP = MF->getFunction().getSubprogram())
3221+
Loc = DILocation::get(SP->getContext(), SP->getLine(), 1, SP);
3222+
MachineOptimizationRemarkMissed R(DEBUG_TYPE, "SpillReload", Loc,
32193223
&MF->front());
32203224
Stats.report(R);
32213225
R << "generated in function";

llvm/test/CodeGen/AArch64/arm64-spill-remarks.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
; (loop:)
2424
; REMARK: remark: /tmp/kk.c:1:20: 2 spills 2 reloads generated in loop{{$}}
2525
; (func:)
26-
; REMARK: remark: <unknown>:0:0: 3 spills 3 reloads generated in function{{$}}
26+
; REMARK: remark: /tmp/kk.c:1:1: 3 spills 3 reloads generated in function{{$}}
2727

2828
; (loop3:)
2929
; HOTNESS: remark: /tmp/kk.c:3:20: 1 spills 1 reloads generated in loop (hotness: 300)
@@ -79,6 +79,7 @@
7979
; YAML: --- !Missed
8080
; YAML: Pass: regalloc
8181
; YAML: Name: SpillReload
82+
; YAML: DebugLoc: { File: '/tmp/kk.c', Line: 1, Column: 1 }
8283
; YAML: Function: fpr128
8384
; YAML: Hotness: 3
8485
; YAML: Args:
@@ -104,7 +105,7 @@
104105
; THRESHOLD_YAML: - String: generated in loop
105106
; THRESHOLD_YAML: ...
106107

107-
define void @fpr128(<4 x float>* %p) nounwind ssp !prof !11 {
108+
define void @fpr128(<4 x float>* %p) nounwind ssp !prof !11 !dbg !6 {
108109
entry:
109110
br label %loop, !dbg !8
110111

0 commit comments

Comments
 (0)