diff --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h index 573e49fbb069..5e1b294fa1ff 100644 --- a/llvm/include/llvm/IR/Metadata.h +++ b/llvm/include/llvm/IR/Metadata.h @@ -598,7 +598,7 @@ protected: } MDNode(LLVMContext &Context, unsigned ID, ArrayRef MDs); - ~MDNode() { dropAllReferences(); } + ~MDNode() {} void dropAllReferences(); void storeDistinctInContext(); @@ -766,7 +766,7 @@ class MDNodeFwdDecl : public MDNode, ReplaceableMetadataImpl { MDNodeFwdDecl(LLVMContext &C, ArrayRef Vals) : MDNode(C, MDNodeFwdDeclKind, Vals) {} - ~MDNodeFwdDecl() {} + ~MDNodeFwdDecl() { dropAllReferences(); } public: static bool classof(const Metadata *MD) { diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index 0f748495261b..506284fa87ae 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -428,6 +428,7 @@ GenericMDNode::~GenericMDNode() { pImpl->NonUniquedMDNodes.erase(this); else pImpl->MDNodeSet.erase(this); + dropAllReferences(); } void GenericMDNode::resolve() {