aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/DebugInfoMetadata.cpp
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2023-11-08 14:58:34 +0000
committerJeremy Morse <jeremy.morse@sony.com>2023-11-08 16:42:35 +0000
commitf1b0a544514f3d343f32a41de9d6fb0b6cbb6021 (patch)
tree70aa779bf9cced26244c37cf3c16048aa548f46a /llvm/lib/IR/DebugInfoMetadata.cpp
parent671d10ad3959c3ea12e18ded1c7b5a9b2dcb7fa9 (diff)
downloadllvm-f1b0a544514f3d343f32a41de9d6fb0b6cbb6021.zip
llvm-f1b0a544514f3d343f32a41de9d6fb0b6cbb6021.tar.gz
llvm-f1b0a544514f3d343f32a41de9d6fb0b6cbb6021.tar.bz2
Reapply 7d77bbef4ad92, adding new debug-info classes
This reverts commit 957efa4ce4f0391147cec62746e997226ee2b836. Original commit message below -- in this follow up, I've shifted un-necessary inclusions of DebugProgramInstruction.h into being forward declarations (fixes clang-compile time I hope), and a memory leak in the DebugInfoTest.cpp IR unittests. I also tracked a compile-time regression in D154080, more explanation there, but the result of which is hiding some of the changes behind the EXPERIMENTAL_DEBUGINFO_ITERATORS compile-time flag. This is tested by the "new-debug-iterators" buildbot. [DebugInfo][RemoveDIs] Add prototype storage classes for "new" debug-info This patch adds a variety of classes needed to record variable location debug-info without using the existing intrinsic approach, see the rationale at [0]. The two added files and corresponding unit tests are the majority of the plumbing required for this, but at this point isn't accessible from the rest of LLVM as we need to stage it into the repo gently. An overview is that classes are added for recording variable information attached to Real (TM) instructions, in the form of DPValues and DPMarker objects. The metadata-uses of DPValues is plumbed into the metadata hierachy, and a field added to class Instruction, which are all stimulated in the unit tests. The next few patches in this series add utilities to convert to/from this new debug-info format and add instruction/block utilities to have debug-info automatically updated in the background when various operations occur. This patch was reviewed in Phab in D153990 and D154080, I've squashed them together into this commit as there are dependencies between the two patches, and there's little profit in landing them separately. [0] https://discourse.llvm.org/t/rfc-instruction-api-changes-needed-to-eliminate-debug-intrinsics-from-ir/68939
Diffstat (limited to 'llvm/lib/IR/DebugInfoMetadata.cpp')
-rw-r--r--llvm/lib/IR/DebugInfoMetadata.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index f7f3612..48c4b62 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -2135,8 +2135,26 @@ void DIArgList::handleChangedOperand(void *Ref, Metadata *New) {
}
}
if (Uniq) {
+ // In the RemoveDIs project (eliminating debug-info-intrinsics), DIArgLists
+ // can be referred to by DebugValueUser objects, which necessitates them
+ // being unique and replaceable metadata. This causes a slight
+ // performance regression that's to be avoided during the early stages of
+ // the RemoveDIs prototype, see D154080.
+#ifdef EXPERIMENTAL_DEBUGINFO_ITERATORS
+ MDNode *UniqueArgList = uniquify();
+ if (UniqueArgList != this) {
+ replaceAllUsesWith(UniqueArgList);
+ // Clear this here so we don't try to untrack in the destructor.
+ Args.clear();
+ delete this;
+ return;
+ }
+#else
+ // Otherwise, don't fully unique, become distinct instead. See D108968,
+ // there's a latent bug that presents here as nondeterminism otherwise.
if (uniquify() != this)
storeDistinctInContext();
+#endif
}
track();
}