Skip to content

Commit 1efbd38

Browse files
committed
Add CMake option to enable expensive line number origin tracking
1 parent 643df05 commit 1efbd38

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

llvm/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,10 @@ endif()
536536

537537
option(LLVM_ENABLE_CRASH_DUMPS "Turn on memory dumps on crashes. Currently only implemented on Windows." OFF)
538538

539+
set(LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING "DISABLED" CACHE STRING
540+
"Enhance debugify's line number coverage tracking; enabling this is abi-breaking. Can be DISABLED, COVERAGE, or COVERAGE_AND_ORIGIN.")
541+
set_property(CACHE LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING PROPERTY STRINGS DISABLED COVERAGE COVERAGE_AND_ORIGIN)
542+
539543
set(WINDOWS_PREFER_FORWARD_SLASH_DEFAULT OFF)
540544
if (MINGW)
541545
# Cygwin doesn't identify itself as Windows, and thus gets path::Style::posix

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ else()
196196
message(FATAL_ERROR "Unknown value for LLVM_ABI_BREAKING_CHECKS: \"${LLVM_ABI_BREAKING_CHECKS}\"!")
197197
endif()
198198

199+
string(TOUPPER "${LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING}" uppercase_LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING)
200+
201+
if( uppercase_LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING STREQUAL "COVERAGE" )
202+
set( ENABLE_DEBUGLOC_COVERAGE_TRACKING 1 )
203+
elseif( uppercase_LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING STREQUAL "COVERAGE_AND_ORIGIN" )
204+
message(FATAL_ERROR "\"COVERAGE_AND_ORIGIN\" setting for LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING currently unimplemented.")
205+
elseif( uppercase_LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING STREQUAL "DISABLED" OR NOT DEFINED LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING )
206+
# The DISABLED setting is default and requires no additional defines.
207+
else()
208+
message(FATAL_ERROR "Unknown value for LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING: \"${LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING}\"!")
209+
endif()
210+
199211
if( LLVM_REVERSE_ITERATION )
200212
set( LLVM_ENABLE_REVERSE_ITERATION 1 )
201213
endif()

llvm/docs/CMake.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,17 @@ enabled sub-projects. Nearly all of these variable names begin with
480480
**LLVM_ENABLE_BINDINGS**:BOOL
481481
If disabled, do not try to build the OCaml bindings.
482482

483+
**LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING**:STRING
484+
Enhances Debugify's ability to detect line number errors by storing extra
485+
information inside Instructions, removing false positives from Debugify's
486+
results at the cost of performance. Allowed values are `DISABLED` (default),
487+
`COVERAGE`, and `COVERAGE_AND_ORIGIN`. `COVERAGE` tracks whether and why a
488+
line number was intentionally dropped or not generated for an instruction,
489+
allowing Debugify to avoid reporting these as errors. `COVERAGE_AND_ORIGIN`
490+
additionally stores a stacktrace of the point where each DebugLoc is
491+
unintentionally dropped, allowing for much easier bug triaging at the cost of
492+
a ~10x performance slowdown.
493+
483494
**LLVM_ENABLE_DIA_SDK**:BOOL
484495
Enable building with MSVC DIA SDK for PDB debugging support. Available
485496
only with MSVC. Defaults to ON.

llvm/include/llvm/Config/config.h.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
/* Define to 1 to enable crash memory dumps, and to 0 otherwise. */
2020
#cmakedefine01 LLVM_ENABLE_CRASH_DUMPS
2121

22+
/* Define to 1 to enable expensive checks for debug location coverage checking,
23+
and to 0 otherwise. */
24+
#cmakedefine01 ENABLE_DEBUGLOC_COVERAGE_TRACKING
25+
2226
/* Define to 1 to prefer forward slashes on Windows, and to 0 prefer
2327
backslashes. */
2428
#cmakedefine01 LLVM_WINDOWS_PREFER_FORWARD_SLASH

0 commit comments

Comments
 (0)