Skip to content

Commit e43e8e9

Browse files
committed
[AnnotationRemarks] Use subprogram location for summary remarks.
The summary remarks are generated on a per-function basis. Using the first instruction's location is sub-optimal for 2 reasons: 1. Sometimes the first instruction is missing !dbg 2. The location of the first instruction may be mis-leading. Instead, just use the location of the function directly.
1 parent 8f80c66 commit e43e8e9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

llvm/lib/Transforms/Scalar/AnnotationRemarks.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ static void runImpl(Function &F, const TargetLibraryInfo &TLI) {
100100
}
101101
}
102102

103-
Instruction *IP = &*F.begin()->begin();
104103
for (const auto &KV : Mapping)
105-
ORE.emit(OptimizationRemarkAnalysis(REMARK_PASS, "AnnotationSummary", IP)
104+
ORE.emit(OptimizationRemarkAnalysis(REMARK_PASS, "AnnotationSummary",
105+
F.getSubprogram(), &F.front())
106106
<< "Annotated " << NV("count", KV.second) << " instructions with "
107107
<< NV("type", KV.first));
108108

llvm/test/Transforms/Util/annotation-remarks-dbg-info.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
; CHECK: --- !Analysis
1010
; CHECK-NEXT: Pass: annotation-remarks
1111
; CHECK-NEXT: Name: AnnotationSummary
12-
; CHECK-NEXT: DebugLoc: { File: test.c, Line: 400, Column: 3 }
12+
; CHECK-NEXT: DebugLoc: { File: test.c, Line: 10, Column: 0 }
1313
; CHECK-NEXT: Function: test1
1414
; CHECK-NEXT: Args:
1515
; CHECK-NEXT: - String: 'Annotated '
@@ -20,7 +20,7 @@
2020
; CHECK-NEXT: --- !Analysis
2121
; CHECK-NEXT: Pass: annotation-remarks
2222
; CHECK-NEXT: Name: AnnotationSummary
23-
; CHECK-NEXT: DebugLoc: { File: test.c, Line: 400, Column: 3 }
23+
; CHECK-NEXT: DebugLoc: { File: test.c, Line: 10, Column: 0 }
2424
; CHECK-NEXT: Function: test1
2525
; CHECK-NEXT: Args:
2626
; CHECK-NEXT: - String: 'Annotated '
@@ -31,6 +31,7 @@
3131
; CHECK-NEXT: --- !Analysis
3232
; CHECK-NEXT: Pass: annotation-remarks
3333
; CHECK-NEXT: Name: AnnotationSummary
34+
; CHECK-NEXT: DebugLoc: { File: test.c, Line: 20, Column: 0 }
3435
; CHECK-NEXT: Function: test2
3536
; CHECK-NEXT: Args:
3637
; CHECK-NEXT: - String: 'Annotated '

0 commit comments

Comments
 (0)