summaryrefslogtreecommitdiff
path: root/lib/VMCore/Metadata.cpp
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2010-03-13 01:26:15 +0000
committerJeffrey Yasskin <jyasskin@google.com>2010-03-13 01:26:15 +0000
commit6f555ca2cd0bba50542adcbb131f541ae70d34cd (patch)
tree551444ef3af31f75e10dbbee06c3470dff7a1ae8 /lib/VMCore/Metadata.cpp
parent815baebe1c8dc02accf128ae10dff9a1742d3244 (diff)
downloadllvm-6f555ca2cd0bba50542adcbb131f541ae70d34cd.tar.gz
llvm-6f555ca2cd0bba50542adcbb131f541ae70d34cd.tar.bz2
llvm-6f555ca2cd0bba50542adcbb131f541ae70d34cd.tar.xz
Delete MDNodes when LLVMContext is destroyed. Previous attempts: r97918, r97788.
Tested: clang debug bootstrap, llvm-gcc bootstrap, `make check-lit` after configuring with --with-llvmgccdir (and this did run the FrontendC* tests this time) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98410 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Metadata.cpp')
-rw-r--r--lib/VMCore/Metadata.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp
index 379aeb540a..06d4fd4ae5 100644
--- a/lib/VMCore/Metadata.cpp
+++ b/lib/VMCore/Metadata.cpp
@@ -101,8 +101,10 @@ MDNode::MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
MDNode::~MDNode() {
assert((getSubclassDataFromValue() & DestroyFlag) != 0 &&
"Not being destroyed through destroy()?");
- if (!isNotUniqued()) {
- LLVMContextImpl *pImpl = getType()->getContext().pImpl;
+ LLVMContextImpl *pImpl = getType()->getContext().pImpl;
+ if (isNotUniqued()) {
+ pImpl->NonUniquedMDNodes.erase(this);
+ } else {
pImpl->MDNodeSet.RemoveNode(this);
}
@@ -248,12 +250,10 @@ void MDNode::Profile(FoldingSetNodeID &ID) const {
ID.AddPointer(getOperand(i));
}
-// replaceAllOperandsWithNull - This is used while destroying llvm context to
-// gracefully delete all nodes. This method replaces all operands with null.
-void MDNode::replaceAllOperandsWithNull() {
- for (MDNodeOperand *Op = getOperandPtr(this, 0), *E = Op+NumOperands;
- Op != E; ++Op)
- replaceOperand(Op, 0);
+void MDNode::setIsNotUniqued() {
+ setValueSubclassData(getSubclassDataFromValue() | NotUniquedBit);
+ LLVMContextImpl *pImpl = getType()->getContext().pImpl;
+ pImpl->NonUniquedMDNodes.insert(this);
}
// Replace value from this node's operand list.