diff options
author | Stephen Tozer <stephen.tozer@sony.com> | 2023-11-17 14:04:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-17 14:04:54 +0000 |
commit | e77af7e1b07ac648c026922e4a0b07e9af35f714 (patch) | |
tree | aeb3a356b3541261c5423766766799826abffbcb /llvm/lib/IR/LLVMContextImpl.cpp | |
parent | e5e71affb72178ccfedae2083c686999d9fa4941 (diff) | |
download | llvm-e77af7e1b07ac648c026922e4a0b07e9af35f714.zip llvm-e77af7e1b07ac648c026922e4a0b07e9af35f714.tar.gz llvm-e77af7e1b07ac648c026922e4a0b07e9af35f714.tar.bz2 |
[DebugInfo] Make DIArgList inherit from Metadata and always unique (#72147)
This patch changes the `DIArgList` class's inheritance from `MDNode` to
`Metadata, ReplaceableMetadataImpl`, and ensures that it is always
unique, i.e. a distinct DIArgList should never be produced.
This should not result in any changes to IR or bitcode parsing and
printing, as the format for DIArgList is unchanged, and the order in which it
appears should also be identical. As a minor note, this patch also fixes
a gap in the verifier, where the ValueAsMetadata operands to a DIArgList
would not be visited.
Diffstat (limited to 'llvm/lib/IR/LLVMContextImpl.cpp')
-rw-r--r-- | llvm/lib/IR/LLVMContextImpl.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp index 406850b..993deaf 100644 --- a/llvm/lib/IR/LLVMContextImpl.cpp +++ b/llvm/lib/IR/LLVMContextImpl.cpp @@ -68,15 +68,8 @@ LLVMContextImpl::~LLVMContextImpl() { // Drop references for MDNodes. Do this before Values get deleted to avoid // unnecessary RAUW when nodes are still unresolved. - for (auto *I : DistinctMDNodes) { - // We may have DIArgList that were uniqued, and as it has a custom - // implementation of dropAllReferences, it needs to be explicitly invoked. - if (auto *AL = dyn_cast<DIArgList>(I)) { - AL->dropAllReferences(); - continue; - } + for (auto *I : DistinctMDNodes) I->dropAllReferences(); - } #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \ for (auto *I : CLASS##s) \ I->dropAllReferences(); @@ -87,6 +80,10 @@ LLVMContextImpl::~LLVMContextImpl() { Pair.second->dropUsers(); for (auto &Pair : MetadataAsValues) Pair.second->dropUse(); + // Do not untrack ValueAsMetadata references for DIArgLists, as they have + // already been more efficiently untracked above. + for (DIArgList *AL : DIArgLists) + AL->dropAllReferences(/* Untrack */ false); // Destroy MDNodes. for (MDNode *I : DistinctMDNodes) |