diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index 35fb47a5ffb..5cb1040e4bc 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "LLVMContextImpl.h" #include "llvm/Type.h" #include "llvm/Instructions.h" #include "llvm/Function.h" @@ -49,6 +50,10 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, // Out of line virtual method, so the vtable, etc has a home. Instruction::~Instruction() { + if (hasMetadata()) { + LLVMContext &Context = getContext(); + Context.pImpl->TheMetadata.ValueIsDeleted(this); + } assert(Parent == 0 && "Instruction still linked in the program!"); }