[llvm] e43e8e9 - [AnnotationRemarks] Use subprogram location for summary remarks.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 23 05:06:03 PDT 2021


Author: Florian Hahn
Date: 2021-03-23T12:05:41Z
New Revision: e43e8e913821f8db3684c384f5760b8e6e12e0d8

URL: https://github.com/llvm/llvm-project/commit/e43e8e913821f8db3684c384f5760b8e6e12e0d8
DIFF: https://github.com/llvm/llvm-project/commit/e43e8e913821f8db3684c384f5760b8e6e12e0d8.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/AnnotationRemarks.cpp
    llvm/test/Transforms/Util/annotation-remarks-dbg-info.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/AnnotationRemarks.cpp b/llvm/lib/Transforms/Scalar/AnnotationRemarks.cpp
index bb5270af7f231..c5bdfb4d8f6ad 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 102a435f7e4d6..25e5729dd70d5 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 '


        


More information about the llvm-commits mailing list