[llvm] [DLCov 1/5] Add CMake option to enable enhanced line number coverage tracking (PR #107278)
Stephen Tozer via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 27 05:43:19 PDT 2024
https://github.com/SLTozer updated https://github.com/llvm/llvm-project/pull/107278
>From e45d7e68a371a09ea766c4accf8edc6c030fd7fd Mon Sep 17 00:00:00 2001
From: Stephen Tozer <stephen.tozer at sony.com>
Date: Wed, 4 Sep 2024 12:09:50 +0100
Subject: [PATCH 1/3] Add CMake option to enable expensive line number origin
tracking
---
llvm/CMakeLists.txt | 4 ++++
llvm/cmake/modules/HandleLLVMOptions.cmake | 12 ++++++++++++
llvm/docs/CMake.rst | 11 +++++++++++
llvm/include/llvm/Config/config.h.cmake | 4 ++++
4 files changed, 31 insertions(+)
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 12618966c4adfd..3e2e90f5adad2e 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -524,6 +524,10 @@ endif()
option(LLVM_ENABLE_CRASH_DUMPS "Turn on memory dumps on crashes. Currently only implemented on Windows." OFF)
+set(LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING "DISABLED" CACHE STRING
+ "Enhance debugify's line number coverage tracking; enabling this is abi-breaking. Can be DISABLED, COVERAGE, or COVERAGE_AND_ORIGIN.")
+set_property(CACHE LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING PROPERTY STRINGS DISABLED COVERAGE COVERAGE_AND_ORIGIN)
+
set(WINDOWS_PREFER_FORWARD_SLASH_DEFAULT OFF)
if (MINGW)
# Cygwin doesn't identify itself as Windows, and thus gets path::Style::posix
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 5ca580fbb59c59..a4b11c149da9de 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -196,6 +196,18 @@ else()
message(FATAL_ERROR "Unknown value for LLVM_ABI_BREAKING_CHECKS: \"${LLVM_ABI_BREAKING_CHECKS}\"!")
endif()
+string(TOUPPER "${LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING}" uppercase_LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING)
+
+if( uppercase_LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING STREQUAL "COVERAGE" )
+ set( ENABLE_DEBUGLOC_COVERAGE_TRACKING 1 )
+elseif( uppercase_LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING STREQUAL "COVERAGE_AND_ORIGIN" )
+ message(FATAL_ERROR "\"COVERAGE_AND_ORIGIN\" setting for LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING currently unimplemented.")
+elseif( uppercase_LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING STREQUAL "DISABLED" OR NOT DEFINED LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING )
+ # The DISABLED setting is default and requires no additional defines.
+else()
+ message(FATAL_ERROR "Unknown value for LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING: \"${LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING}\"!")
+endif()
+
if( LLVM_REVERSE_ITERATION )
set( LLVM_ENABLE_REVERSE_ITERATION 1 )
endif()
diff --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst
index 2a80813999ea1e..304e22759770d9 100644
--- a/llvm/docs/CMake.rst
+++ b/llvm/docs/CMake.rst
@@ -475,6 +475,17 @@ enabled sub-projects. Nearly all of these variable names begin with
**LLVM_ENABLE_BINDINGS**:BOOL
If disabled, do not try to build the OCaml bindings.
+**LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING**:STRING
+ Enhances Debugify's ability to detect line number errors by storing extra
+ information inside Instructions, removing false positives from Debugify's
+ results at the cost of performance. Allowed values are `DISABLED` (default),
+ `COVERAGE`, and `COVERAGE_AND_ORIGIN`. `COVERAGE` tracks whether and why a
+ line number was intentionally dropped or not generated for an instruction,
+ allowing Debugify to avoid reporting these as errors. `COVERAGE_AND_ORIGIN`
+ additionally stores a stacktrace of the point where each DebugLoc is
+ unintentionally dropped, allowing for much easier bug triaging at the cost of
+ a ~10x performance slowdown.
+
**LLVM_ENABLE_DIA_SDK**:BOOL
Enable building with MSVC DIA SDK for PDB debugging support. Available
only with MSVC. Defaults to ON.
diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake
index ff30741c8f360a..388ce1e8f74e3e 100644
--- a/llvm/include/llvm/Config/config.h.cmake
+++ b/llvm/include/llvm/Config/config.h.cmake
@@ -19,6 +19,10 @@
/* Define to 1 to enable crash memory dumps, and to 0 otherwise. */
#cmakedefine01 LLVM_ENABLE_CRASH_DUMPS
+/* Define to 1 to enable expensive checks for debug location coverage checking,
+ and to 0 otherwise. */
+#cmakedefine01 ENABLE_DEBUGLOC_COVERAGE_TRACKING
+
/* Define to 1 to prefer forward slashes on Windows, and to 0 prefer
backslashes. */
#cmakedefine01 LLVM_WINDOWS_PREFER_FORWARD_SLASH
>From 2a731bc5ab79fb59ceb7af9e495a05047787c87f Mon Sep 17 00:00:00 2001
From: Stephen Tozer <stephen.tozer at sony.com>
Date: Thu, 26 Sep 2024 13:54:53 +0100
Subject: [PATCH 2/3] Update comments
---
llvm/CMakeLists.txt | 2 +-
llvm/docs/CMake.rst | 4 +-
llvm/test/Transforms/InstCombine/reduced.ll | 69 +++++++++++++++++++++
3 files changed, 72 insertions(+), 3 deletions(-)
create mode 100644 llvm/test/Transforms/InstCombine/reduced.ll
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 3e2e90f5adad2e..f7a2ad2b0cb3ae 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -525,7 +525,7 @@ endif()
option(LLVM_ENABLE_CRASH_DUMPS "Turn on memory dumps on crashes. Currently only implemented on Windows." OFF)
set(LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING "DISABLED" CACHE STRING
- "Enhance debugify's line number coverage tracking; enabling this is abi-breaking. Can be DISABLED, COVERAGE, or COVERAGE_AND_ORIGIN.")
+ "Enhance Debugify's line number coverage tracking; enabling this is ABI-breaking. Can be DISABLED, COVERAGE, or COVERAGE_AND_ORIGIN.")
set_property(CACHE LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING PROPERTY STRINGS DISABLED COVERAGE COVERAGE_AND_ORIGIN)
set(WINDOWS_PREFER_FORWARD_SLASH_DEFAULT OFF)
diff --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst
index 304e22759770d9..849b06640672b9 100644
--- a/llvm/docs/CMake.rst
+++ b/llvm/docs/CMake.rst
@@ -482,9 +482,9 @@ enabled sub-projects. Nearly all of these variable names begin with
`COVERAGE`, and `COVERAGE_AND_ORIGIN`. `COVERAGE` tracks whether and why a
line number was intentionally dropped or not generated for an instruction,
allowing Debugify to avoid reporting these as errors. `COVERAGE_AND_ORIGIN`
- additionally stores a stacktrace of the point where each DebugLoc is
+ additionally stores a stack trace of the point where each DebugLoc is
unintentionally dropped, allowing for much easier bug triaging at the cost of
- a ~10x performance slowdown.
+ a ~10x performance slowdown. ABI-breaking.
**LLVM_ENABLE_DIA_SDK**:BOOL
Enable building with MSVC DIA SDK for PDB debugging support. Available
diff --git a/llvm/test/Transforms/InstCombine/reduced.ll b/llvm/test/Transforms/InstCombine/reduced.ll
new file mode 100644
index 00000000000000..779fa85a415cc7
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/reduced.ll
@@ -0,0 +1,69 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+;; Tests that we do not always overwrite
+; RUN: opt < %s -passes=instcombine -S | FileCheck %s
+
+define void @test(ptr %xfA, ptr %xfB, i1 %cmp5) {
+; CHECK-LABEL: define void @test(
+; CHECK-SAME: ptr [[XFA:%.*]], ptr [[XFB:%.*]], i1 [[CMP5:%.*]]) {
+; CHECK-NEXT: [[ENTRY:.*:]]
+; CHECK-NEXT: br i1 [[CMP5]], label %[[IF_ELSE:.*]], label %[[IF_THEN6:.*]]
+; CHECK: [[IF_THEN6]]:
+; CHECK-NEXT: br label %[[IF_END11:.*]]
+; CHECK: [[IF_ELSE]]:
+; CHECK-NEXT: br label %[[IF_END11]]
+; CHECK: [[IF_END11]]:
+; CHECK-NEXT: [[XFA_PN:%.*]] = phi ptr [ [[XFA]], %[[IF_ELSE]] ], [ [[XFB]], %[[IF_THEN6]] ]
+; CHECK-NEXT: [[XF1_SROA_8_0_IN:%.*]] = getelementptr i8, ptr [[XFA_PN]], i64 4, !dbg [[DBG3:![0-9]+]]
+; CHECK-NEXT: [[XF1_SROA_8_0:%.*]] = load float, ptr [[XF1_SROA_8_0_IN]], align 4
+; CHECK-NEXT: [[CMP_I:%.*]] = fcmp ugt float [[XF1_SROA_8_0]], 0.000000e+00
+; CHECK-NEXT: br i1 [[CMP_I]], label %[[IF_END_I:.*]], label %[[IF_THEN_I:.*]]
+; CHECK: [[IF_THEN_I]]:
+; CHECK-NEXT: br label %[[IF_END_I]]
+; CHECK: [[IF_END_I]]:
+; CHECK-NEXT: ret void
+;
+entry:
+ br i1 %cmp5, label %if.else, label %if.then6
+
+if.then6: ; preds = %entry
+ %xf1.sroa.8.0.xfB.sroa_idx = getelementptr i8, ptr %xfB, i64 4
+ %xf1.sroa.8.0.copyload = load float, ptr %xf1.sroa.8.0.xfB.sroa_idx, align 4, !dbg !3
+ br label %if.end11
+
+if.else: ; preds = %entry
+ %xf1.sroa.8.0.xfA.sroa_idx = getelementptr i8, ptr %xfA, i64 4
+ %xf1.sroa.8.0.copyload494 = load float, ptr %xf1.sroa.8.0.xfA.sroa_idx, align 4, !dbg !7
+ br label %if.end11
+
+if.end11: ; preds = %if.else, %if.then6
+ %xf1.sroa.8.0 = phi float [ %xf1.sroa.8.0.copyload494, %if.else ], [ %xf1.sroa.8.0.copyload, %if.then6 ], !annotation !8
+ %cmp.i = fcmp ugt float %xf1.sroa.8.0, 0.000000e+00
+ br i1 %cmp.i, label %if.end.i, label %if.then.i
+
+if.then.i: ; preds = %if.end11
+ br label %if.end.i
+
+if.end.i: ; preds = %if.then.i, %if.end11
+ ret void
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 20.0.0git", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
+!1 = !DIFile(filename: "test.cpp", directory: "/tmp")
+!2 = !{i32 2, !"Debug Info Version", i32 3}
+!3 = !DILocation(line: 63, column: 12, scope: !4)
+!4 = distinct !DISubprogram(name: "operator=", linkageName: "_ZN11btMatrix3x3aSERKS_", scope: null, file: !1, line: 61, type: !5, scopeLine: 62, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !6)
+!5 = distinct !DISubroutineType(types: !6)
+!6 = !{}
+!7 = !DILocation(line: 63, column: 15, scope: !4)
+!8 = !{!"irrelevant metadata"}
+;.
+; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
+; CHECK: [[META1]] = !DIFile(filename: "test.cpp", directory: {{.*}})
+; CHECK: [[DBG3]] = !DILocation(line: 63, scope: [[META4:![0-9]+]])
+; CHECK: [[META4]] = distinct !DISubprogram(name: "operator=", linkageName: "_ZN11btMatrix3x3aSERKS_", scope: null, file: [[META1]], line: 61, type: [[META5:![0-9]+]], scopeLine: 62, spFlags: DISPFlagDefinition, unit: [[META0]], retainedNodes: [[META6:![0-9]+]])
+; CHECK: [[META5]] = distinct !DISubroutineType(types: [[META6]])
+; CHECK: [[META6]] = !{}
+;.
>From 2928f48dcb45265703c9933c51378d43326f88c0 Mon Sep 17 00:00:00 2001
From: Stephen Tozer <stephen.tozer at sony.com>
Date: Fri, 27 Sep 2024 13:43:02 +0100
Subject: [PATCH 3/3] Expand comment, remove unwanted test
---
llvm/docs/CMake.rst | 9 +--
llvm/test/Transforms/InstCombine/reduced.ll | 69 ---------------------
2 files changed, 5 insertions(+), 73 deletions(-)
delete mode 100644 llvm/test/Transforms/InstCombine/reduced.ll
diff --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst
index 849b06640672b9..4cfaf8594278a7 100644
--- a/llvm/docs/CMake.rst
+++ b/llvm/docs/CMake.rst
@@ -481,10 +481,11 @@ enabled sub-projects. Nearly all of these variable names begin with
results at the cost of performance. Allowed values are `DISABLED` (default),
`COVERAGE`, and `COVERAGE_AND_ORIGIN`. `COVERAGE` tracks whether and why a
line number was intentionally dropped or not generated for an instruction,
- allowing Debugify to avoid reporting these as errors. `COVERAGE_AND_ORIGIN`
- additionally stores a stack trace of the point where each DebugLoc is
- unintentionally dropped, allowing for much easier bug triaging at the cost of
- a ~10x performance slowdown. ABI-breaking.
+ allowing Debugify to avoid reporting these as errors; this comes with a small
+ performance cost of ~0.1%. `COVERAGE_AND_ORIGIN` additionally stores a stack
+ trace of the point where each DebugLoc is unintentionally dropped, allowing
+ for much easier bug triaging at the cost of a ~10x performance slowdown.
+ `COVERAGE` and `COVERAGE_AND_ORIGIN` are both ABI-breaking options.
**LLVM_ENABLE_DIA_SDK**:BOOL
Enable building with MSVC DIA SDK for PDB debugging support. Available
diff --git a/llvm/test/Transforms/InstCombine/reduced.ll b/llvm/test/Transforms/InstCombine/reduced.ll
deleted file mode 100644
index 779fa85a415cc7..00000000000000
--- a/llvm/test/Transforms/InstCombine/reduced.ll
+++ /dev/null
@@ -1,69 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-;; Tests that we do not always overwrite
-; RUN: opt < %s -passes=instcombine -S | FileCheck %s
-
-define void @test(ptr %xfA, ptr %xfB, i1 %cmp5) {
-; CHECK-LABEL: define void @test(
-; CHECK-SAME: ptr [[XFA:%.*]], ptr [[XFB:%.*]], i1 [[CMP5:%.*]]) {
-; CHECK-NEXT: [[ENTRY:.*:]]
-; CHECK-NEXT: br i1 [[CMP5]], label %[[IF_ELSE:.*]], label %[[IF_THEN6:.*]]
-; CHECK: [[IF_THEN6]]:
-; CHECK-NEXT: br label %[[IF_END11:.*]]
-; CHECK: [[IF_ELSE]]:
-; CHECK-NEXT: br label %[[IF_END11]]
-; CHECK: [[IF_END11]]:
-; CHECK-NEXT: [[XFA_PN:%.*]] = phi ptr [ [[XFA]], %[[IF_ELSE]] ], [ [[XFB]], %[[IF_THEN6]] ]
-; CHECK-NEXT: [[XF1_SROA_8_0_IN:%.*]] = getelementptr i8, ptr [[XFA_PN]], i64 4, !dbg [[DBG3:![0-9]+]]
-; CHECK-NEXT: [[XF1_SROA_8_0:%.*]] = load float, ptr [[XF1_SROA_8_0_IN]], align 4
-; CHECK-NEXT: [[CMP_I:%.*]] = fcmp ugt float [[XF1_SROA_8_0]], 0.000000e+00
-; CHECK-NEXT: br i1 [[CMP_I]], label %[[IF_END_I:.*]], label %[[IF_THEN_I:.*]]
-; CHECK: [[IF_THEN_I]]:
-; CHECK-NEXT: br label %[[IF_END_I]]
-; CHECK: [[IF_END_I]]:
-; CHECK-NEXT: ret void
-;
-entry:
- br i1 %cmp5, label %if.else, label %if.then6
-
-if.then6: ; preds = %entry
- %xf1.sroa.8.0.xfB.sroa_idx = getelementptr i8, ptr %xfB, i64 4
- %xf1.sroa.8.0.copyload = load float, ptr %xf1.sroa.8.0.xfB.sroa_idx, align 4, !dbg !3
- br label %if.end11
-
-if.else: ; preds = %entry
- %xf1.sroa.8.0.xfA.sroa_idx = getelementptr i8, ptr %xfA, i64 4
- %xf1.sroa.8.0.copyload494 = load float, ptr %xf1.sroa.8.0.xfA.sroa_idx, align 4, !dbg !7
- br label %if.end11
-
-if.end11: ; preds = %if.else, %if.then6
- %xf1.sroa.8.0 = phi float [ %xf1.sroa.8.0.copyload494, %if.else ], [ %xf1.sroa.8.0.copyload, %if.then6 ], !annotation !8
- %cmp.i = fcmp ugt float %xf1.sroa.8.0, 0.000000e+00
- br i1 %cmp.i, label %if.end.i, label %if.then.i
-
-if.then.i: ; preds = %if.end11
- br label %if.end.i
-
-if.end.i: ; preds = %if.then.i, %if.end11
- ret void
-}
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!2}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 20.0.0git", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
-!1 = !DIFile(filename: "test.cpp", directory: "/tmp")
-!2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = !DILocation(line: 63, column: 12, scope: !4)
-!4 = distinct !DISubprogram(name: "operator=", linkageName: "_ZN11btMatrix3x3aSERKS_", scope: null, file: !1, line: 61, type: !5, scopeLine: 62, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !6)
-!5 = distinct !DISubroutineType(types: !6)
-!6 = !{}
-!7 = !DILocation(line: 63, column: 15, scope: !4)
-!8 = !{!"irrelevant metadata"}
-;.
-; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
-; CHECK: [[META1]] = !DIFile(filename: "test.cpp", directory: {{.*}})
-; CHECK: [[DBG3]] = !DILocation(line: 63, scope: [[META4:![0-9]+]])
-; CHECK: [[META4]] = distinct !DISubprogram(name: "operator=", linkageName: "_ZN11btMatrix3x3aSERKS_", scope: null, file: [[META1]], line: 61, type: [[META5:![0-9]+]], scopeLine: 62, spFlags: DISPFlagDefinition, unit: [[META0]], retainedNodes: [[META6:![0-9]+]])
-; CHECK: [[META5]] = distinct !DISubroutineType(types: [[META6]])
-; CHECK: [[META6]] = !{}
-;.
More information about the llvm-commits
mailing list