summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Metadata.cpp
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2010-03-07 18:46:57 +0000
committerJeffrey Yasskin <jyasskin@google.com>2010-03-07 18:46:57 +0000
commitaba6ea8254231f7f61e4e9b7311a58ff07a1d873 (patch)
treed23ffb23dd0d0a801ac58026d1c8f883a06b4822 /llvm/lib/VMCore/Metadata.cpp
parent37a0372fc4ac68e4b0b6f4e9c34b7f87ba896d83 (diff)
downloadbcm5719-llvm-aba6ea8254231f7f61e4e9b7311a58ff07a1d873.tar.gz
bcm5719-llvm-aba6ea8254231f7f61e4e9b7311a58ff07a1d873.zip
Reapply r97788 to free MDNodes when the LLVMContext is destroyed. It
bootstraps llvm-gcc this time. llvm-svn: 97918
Diffstat (limited to 'llvm/lib/VMCore/Metadata.cpp')
-rw-r--r--llvm/lib/VMCore/Metadata.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/VMCore/Metadata.cpp b/llvm/lib/VMCore/Metadata.cpp
index a08c45480b6..faf83e6588e 100644
--- a/llvm/lib/VMCore/Metadata.cpp
+++ b/llvm/lib/VMCore/Metadata.cpp
@@ -110,8 +110,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);
}
@@ -257,12 +259,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.
OpenPOWER on IntegriCloud