[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)

Stephen Tozer via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 25 09:07:01 PDT 2024


================
@@ -1279,6 +1279,9 @@ void Instruction::swapProfMetadata() {
 
 void Instruction::copyMetadata(const Instruction &SrcInst,
                                ArrayRef<unsigned> WL) {
+  if (WL.empty() || is_contained(WL, LLVMContext::MD_dbg))
+    setDebugLoc(SrcInst.getDebugLoc());
----------------
SLTozer wrote:

The short answer is that the patch "works" without this change, but this patch is needed to ensure that the DebugLoc from SrcInst is always copied to the current instruction if MD_dbg is in the set to copy, even if SrcInst has no DebugLoc. The importance of this is straightforward - if the receiving instruction is meant to get its DebugLoc from SrcInst, and SrcInst has no DebugLoc, then we should copy the annotation (or lack of) from SrcInst to determine whether there's a bug and where it comes from.

https://github.com/llvm/llvm-project/pull/107369


More information about the cfe-commits mailing list