diff options
author | Stephen Tozer <Stephen.Tozer@Sony.com> | 2023-11-17 17:52:24 +0000 |
---|---|---|
committer | Stephen Tozer <Stephen.Tozer@Sony.com> | 2023-11-17 17:55:41 +0000 |
commit | f99a02005970cdcb0aad0de80fa4e5b546c6546b (patch) | |
tree | 100118629abadf627aee772fd0deedfdce9191e8 /llvm/lib/IR/LLVMContextImpl.cpp | |
parent | e2fb816c4f0286ddf8b1030148a343d5efc14e01 (diff) | |
download | llvm-f99a02005970cdcb0aad0de80fa4e5b546c6546b.zip llvm-f99a02005970cdcb0aad0de80fa4e5b546c6546b.tar.gz llvm-f99a02005970cdcb0aad0de80fa4e5b546c6546b.tar.bz2 |
Reapply "[DebugInfo] Make DIArgList inherit from Metadata and always unique"
This reverts commit 0fd5dc94380d5fe666dc6c603b4bb782cef743e7.
The original commit removed DIArgLists from being in an MDNode map, but did
not insert a new `delete` in the LLVMContextImpl destructor. This
reapply adds that call to delete, preventing a memory leak.
Diffstat (limited to 'llvm/lib/IR/LLVMContextImpl.cpp')
-rw-r--r-- | llvm/lib/IR/LLVMContextImpl.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp index 406850b..15c90a4 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,13 @@ 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); + delete AL; + } + DIArgLists.clear(); // Destroy MDNodes. for (MDNode *I : DistinctMDNodes) |