aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
authorStephen Tozer <stephen.tozer@sony.com>2025-04-24 20:41:25 +0200
committerGitHub <noreply@github.com>2025-04-24 19:41:25 +0100
commita9d93ecf1f8d2cfe3f77851e0df179b386cff353 (patch)
tree726d4580bf2d4e7d8dcab17b72d441c85e004905 /llvm/lib/IR/DebugInfo.cpp
parenta7a74b349d508e0cc0de53d90a695e3675f54b6a (diff)
downloadllvm-a9d93ecf1f8d2cfe3f77851e0df179b386cff353.zip
llvm-a9d93ecf1f8d2cfe3f77851e0df179b386cff353.tar.gz
llvm-a9d93ecf1f8d2cfe3f77851e0df179b386cff353.tar.bz2
[DLCov] Implement DebugLoc coverage tracking (#107279)
This is part of a series of patches that tries to improve DILocation bug detection in Debugify; see the review for more details. This is the patch that adds the main feature, adding a set of `DebugLoc::get<Kind>` functions that can be used for instructions with intentionally empty DebugLocs to prevent Debugify from treating them as bugs, removing the currently-pervasive false positives and allowing us to use Debugify (in its original DI preservation mode) to reliably detect existing bugs and regressions. This patch does not add uses of these functions, except for once in Clang before optimizations, and in `Instruction::dropLocation()`, since that is an obvious case that immediately removes a set of false positives.
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 7a133b2..a6a88a2 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -987,8 +987,10 @@ void Instruction::updateLocationAfterHoist() { dropLocation(); }
void Instruction::dropLocation() {
const DebugLoc &DL = getDebugLoc();
- if (!DL)
+ if (!DL) {
+ setDebugLoc(DebugLoc::getDropped());
return;
+ }
// If this isn't a call, drop the location to allow a location from a
// preceding instruction to propagate.
@@ -1000,7 +1002,7 @@ void Instruction::dropLocation() {
}
if (!MayLowerToCall) {
- setDebugLoc(DebugLoc());
+ setDebugLoc(DebugLoc::getDropped());
return;
}
@@ -1019,7 +1021,7 @@ void Instruction::dropLocation() {
//
// One alternative is to set a line 0 location with the existing scope and
// inlinedAt info. The location might be sensitive to when inlining occurs.
- setDebugLoc(DebugLoc());
+ setDebugLoc(DebugLoc::getDropped());
}
//===----------------------------------------------------------------------===//