diff options
author | Stephen Tozer <stephen.tozer@sony.com> | 2025-06-12 15:06:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-12 14:06:27 +0100 |
commit | a08a831515919bcc384b453799f33bc97860c73b (patch) | |
tree | 43c8fe486bd0c15ffa073d7fee8eebea06bb6362 /llvm/lib/CodeGen/MachineBasicBlock.cpp | |
parent | 36ac72f4e3e4752f85c16363d630f4cfbd682e48 (diff) | |
download | llvm-a08a831515919bcc384b453799f33bc97860c73b.zip llvm-a08a831515919bcc384b453799f33bc97860c73b.tar.gz llvm-a08a831515919bcc384b453799f33bc97860c73b.tar.bz2 |
[DLCov][NFC] Propagate annotated DebugLocs through transformations (#138047)
Part of the coverage-tracking feature, following #107279.
In order for DebugLoc coverage testing to work, we firstly have to set
annotations for intentionally-empty DebugLocs, and secondly we have to
ensure that we do not drop these annotations as we propagate DebugLocs
throughout compilation. As the annotations exist as part of the DebugLoc
class, and not the underlying DILocation, they will not survive a
DebugLoc->DILocation->DebugLoc roundtrip. Therefore this patch modifies
a number of places in the compiler to propagate DebugLocs directly
rather than via the underlying DILocation. This has no effect on the
output of normal builds; it only ensures that during coverage builds, we
do not drop incorrectly annotations and therefore create false
positives.
The bulk of these changes are in replacing
DILocation::getMergedLocation(s) with a DebugLoc equivalent, and in
changing the IRBuilder to store a DebugLoc directly rather than storing
DILocations in its general Metadata array. We also use a new function,
`DebugLoc::orElse`, which selects the "best" DebugLoc out of a pair
(valid location > annotated > empty), preferring the current DebugLoc on
a tie - this encapsulates the existing behaviour at a few sites where we
_may_ assign a DebugLoc to an existing instruction, while extending the
logic to handle annotation DebugLocs at the same time.
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index ccc164a..48b406e 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -1574,7 +1574,7 @@ MachineBasicBlock::findBranchDebugLoc() { DL = TI->getDebugLoc(); for (++TI ; TI != end() ; ++TI) if (TI->isBranch()) - DL = DILocation::getMergedLocation(DL, TI->getDebugLoc()); + DL = DebugLoc::getMergedLocation(DL, TI->getDebugLoc()); } return DL; } |