diff options
author | Jeffrey Yasskin <jyasskin@google.com> | 2010-03-07 19:26:40 +0000 |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@google.com> | 2010-03-07 19:26:40 +0000 |
commit | 5cdbd7064cb6b4732df7d9e56bb66199877b4a2a (patch) | |
tree | 6ada41ad56bbaa7631185956ddbede389b7c84a0 | |
parent | 39f2fbd12938ed96871ce39e7530ad31a4761125 (diff) | |
download | llvm-5cdbd7064cb6b4732df7d9e56bb66199877b4a2a.zip llvm-5cdbd7064cb6b4732df7d9e56bb66199877b4a2a.tar.gz llvm-5cdbd7064cb6b4732df7d9e56bb66199877b4a2a.tar.bz2 |
Roll back r97918 again. Just configuring against llvm-gcc wasn't enough to run
the FrontendC* tests. :(
llvm-svn: 97921
-rw-r--r-- | llvm/include/llvm/Metadata.h | 7 | ||||
-rw-r--r-- | llvm/lib/VMCore/LLVMContextImpl.h | 25 | ||||
-rw-r--r-- | llvm/lib/VMCore/Metadata.cpp | 16 |
3 files changed, 22 insertions, 26 deletions
diff --git a/llvm/include/llvm/Metadata.h b/llvm/include/llvm/Metadata.h index cecb7da..e536322 100644 --- a/llvm/include/llvm/Metadata.h +++ b/llvm/include/llvm/Metadata.h @@ -108,6 +108,9 @@ class MDNode : public Value, public FoldingSetNode { /// node with T. void replaceOperand(MDNodeOperand *Op, Value *NewVal); ~MDNode(); + /// replaceAllOperandsWithNull - This is used while destroying llvm context to + /// gracefully delete all nodes. This method replaces all operands with null. + void replaceAllOperandsWithNull(); protected: explicit MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals, @@ -163,7 +166,9 @@ private: bool isNotUniqued() const { return (getSubclassDataFromValue() & NotUniquedBit) != 0; } - void setIsNotUniqued(); + void setIsNotUniqued() { + setValueSubclassData(getSubclassDataFromValue() | NotUniquedBit); + } // Shadow Value::setValueSubclassData with a private forwarding method so that // any future subclasses cannot accidentally use it. diff --git a/llvm/lib/VMCore/LLVMContextImpl.h b/llvm/lib/VMCore/LLVMContextImpl.h index 9978f40..9887f28 100644 --- a/llvm/lib/VMCore/LLVMContextImpl.h +++ b/llvm/lib/VMCore/LLVMContextImpl.h @@ -105,11 +105,6 @@ public: StringMap<MDString*> MDStringCache; FoldingSet<MDNode> MDNodeSet; - // MDNodes may be uniqued or not uniqued. When they're not uniqued, they - // aren't in the MDNodeSet, but they're still shared between objects, so no - // one object can destroy them. This set allows us to at least destroy them - // on Context destruction. - SmallPtrSet<MDNode*, 1> NonUniquedMDNodes; ConstantUniqueMap<char, Type, ConstantAggregateZero> AggZeroConstants; @@ -240,21 +235,17 @@ public: (*I)->AbstractTypeUsers.clear(); delete *I; } - // Destroy MDNodes. ~MDNode can move and remove nodes between the MDNodeSet - // and the NonUniquedMDNodes sets, so copy the values out first. - SmallVector<MDNode*, 8> MDNodes; - MDNodes.reserve(MDNodeSet.size() + NonUniquedMDNodes.size()); + // Destroy MDNode operands first. for (FoldingSetIterator<MDNode> I = MDNodeSet.begin(), E = MDNodeSet.end(); - I != E; ++I) { - MDNodes.push_back(&*I); + I != E;) { + MDNode *N = &(*I); + ++I; + N->replaceAllOperandsWithNull(); } - MDNodes.append(NonUniquedMDNodes.begin(), NonUniquedMDNodes.end()); - for (SmallVector<MDNode*, 8>::iterator I = MDNodes.begin(), - E = MDNodes.end(); I != E; ++I) { - (*I)->destroy(); + while (!MDNodeSet.empty()) { + MDNode *N = &(*MDNodeSet.begin()); + N->destroy(); } - assert(MDNodeSet.empty() && NonUniquedMDNodes.empty() && - "Destroying all MDNodes didn't empty the Context's sets."); // Destroy MDStrings. for (StringMap<MDString*>::iterator I = MDStringCache.begin(), E = MDStringCache.end(); I != E; ++I) { diff --git a/llvm/lib/VMCore/Metadata.cpp b/llvm/lib/VMCore/Metadata.cpp index faf83e6..a08c454 100644 --- a/llvm/lib/VMCore/Metadata.cpp +++ b/llvm/lib/VMCore/Metadata.cpp @@ -110,10 +110,8 @@ MDNode::MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals, MDNode::~MDNode() { assert((getSubclassDataFromValue() & DestroyFlag) != 0 && "Not being destroyed through destroy()?"); - LLVMContextImpl *pImpl = getType()->getContext().pImpl; - if (isNotUniqued()) { - pImpl->NonUniquedMDNodes.erase(this); - } else { + if (!isNotUniqued()) { + LLVMContextImpl *pImpl = getType()->getContext().pImpl; pImpl->MDNodeSet.RemoveNode(this); } @@ -259,10 +257,12 @@ void MDNode::Profile(FoldingSetNodeID &ID) const { ID.AddPointer(getOperand(i)); } -void MDNode::setIsNotUniqued() { - setValueSubclassData(getSubclassDataFromValue() | NotUniquedBit); - LLVMContextImpl *pImpl = getType()->getContext().pImpl; - pImpl->NonUniquedMDNodes.insert(this); +// 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); } // Replace value from this node's operand list. |