From: Florian Hahn Date: Tue, 23 Mar 2021 11:59:08 +0000 (+0000) Subject: [AnnotationRemarks] Use subprogram location for summary remarks. X-Git-Tag: llvmorg-14-init~11558 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e43e8e913821f8db3684c384f5760b8e6e12e0d8;p=platform%2Fupstream%2Fllvm.git [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. --- diff --git a/llvm/lib/Transforms/Scalar/AnnotationRemarks.cpp b/llvm/lib/Transforms/Scalar/AnnotationRemarks.cpp index bb5270a..c5bdfb4 100644 --- a/llvm/lib/Transforms/Scalar/AnnotationRemarks.cpp +++ b/llvm/lib/Transforms/Scalar/AnnotationRemarks.cpp @@ -100,9 +100,9 @@ static void runImpl(Function &F, const TargetLibraryInfo &TLI) { } } - Instruction *IP = &*F.begin()->begin(); for (const auto &KV : Mapping) - ORE.emit(OptimizationRemarkAnalysis(REMARK_PASS, "AnnotationSummary", IP) + ORE.emit(OptimizationRemarkAnalysis(REMARK_PASS, "AnnotationSummary", + F.getSubprogram(), &F.front()) << "Annotated " << NV("count", KV.second) << " instructions with " << NV("type", KV.first)); diff --git a/llvm/test/Transforms/Util/annotation-remarks-dbg-info.ll b/llvm/test/Transforms/Util/annotation-remarks-dbg-info.ll index 102a435..25e5729 100644 --- a/llvm/test/Transforms/Util/annotation-remarks-dbg-info.ll +++ b/llvm/test/Transforms/Util/annotation-remarks-dbg-info.ll @@ -9,7 +9,7 @@ ; CHECK: --- !Analysis ; CHECK-NEXT: Pass: annotation-remarks ; CHECK-NEXT: Name: AnnotationSummary -; CHECK-NEXT: DebugLoc: { File: test.c, Line: 400, Column: 3 } +; CHECK-NEXT: DebugLoc: { File: test.c, Line: 10, Column: 0 } ; CHECK-NEXT: Function: test1 ; CHECK-NEXT: Args: ; CHECK-NEXT: - String: 'Annotated ' @@ -20,7 +20,7 @@ ; CHECK-NEXT: --- !Analysis ; CHECK-NEXT: Pass: annotation-remarks ; CHECK-NEXT: Name: AnnotationSummary -; CHECK-NEXT: DebugLoc: { File: test.c, Line: 400, Column: 3 } +; CHECK-NEXT: DebugLoc: { File: test.c, Line: 10, Column: 0 } ; CHECK-NEXT: Function: test1 ; CHECK-NEXT: Args: ; CHECK-NEXT: - String: 'Annotated ' @@ -31,6 +31,7 @@ ; CHECK-NEXT: --- !Analysis ; CHECK-NEXT: Pass: annotation-remarks ; CHECK-NEXT: Name: AnnotationSummary +; CHECK-NEXT: DebugLoc: { File: test.c, Line: 20, Column: 0 } ; CHECK-NEXT: Function: test2 ; CHECK-NEXT: Args: ; CHECK-NEXT: - String: 'Annotated '