summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-31 01:05:46 +0000
committerChris Lattner <sabre@nondot.org>2009-12-31 01:05:46 +0000
commitb76359e36e75dfe16c5153c3cac903efbb2cd8d7 (patch)
tree289a79ca7ed2cd8b1bf9563b0a473e435aef5654 /include
parentcc7b011728b9e8c3574247b81f79689840b3d33a (diff)
downloadllvm-b76359e36e75dfe16c5153c3cac903efbb2cd8d7.tar.gz
llvm-b76359e36e75dfe16c5153c3cac903efbb2cd8d7.tar.bz2
llvm-b76359e36e75dfe16c5153c3cac903efbb2cd8d7.tar.xz
Optimize MDNode to coallocate the operand list immediately
after the MDNode in memory. This eliminates the operands pointer and saves a new[] per node. Note that the code in DIDerivedType::replaceAllUsesWith is wrong and quite scary. A MDNode should not be RAUW'd with something else: this changes all uses of the mdnode, which may not be debug info related! Debug info should use something non-mdnode for declarations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92321 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Metadata.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/include/llvm/Metadata.h b/include/llvm/Metadata.h
index b53fd49b6c..967a09aead 100644
--- a/include/llvm/Metadata.h
+++ b/include/llvm/Metadata.h
@@ -90,7 +90,8 @@ class MDNode : public MetadataBase, public FoldingSetNode {
void operator=(const MDNode &); // DO NOT IMPLEMENT
friend class MDNodeElement;
- MDNodeElement *Operands;
+ /// NumOperands - This many 'MDNodeElement' items are co-allocated onto the
+ /// end of this MDNode.
unsigned NumOperands;
// Subclass data enums.
@@ -102,11 +103,16 @@ class MDNode : public MetadataBase, public FoldingSetNode {
/// NotUniquedBit - This is set on MDNodes that are not uniqued because they
/// have a null perand.
- NotUniquedBit = 1 << 1
+ NotUniquedBit = 1 << 1,
+
+ /// DestroyFlag - This bit is set by destroy() so the destructor can assert
+ /// that the node isn't being destroyed with a plain 'delete'.
+ DestroyFlag = 1 << 2
};
// Replace each instance of F from the element list of this node with T.
void replaceElement(MDNodeElement *Op, Value *NewVal);
+ ~MDNode();
protected:
explicit MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
@@ -115,9 +121,6 @@ public:
// Constructors and destructors.
static MDNode *get(LLVMContext &Context, Value *const *Vals, unsigned NumVals,
bool isFunctionLocal = false);
-
- /// ~MDNode - Destroy MDNode.
- ~MDNode();
/// getElement - Return specified element.
Value *getElement(unsigned i) const;
@@ -133,6 +136,9 @@ public:
return (getSubclassDataFromValue() & FunctionLocalBit) != 0;
}
+ // destroy - Delete this node. Only when there are no uses.
+ void destroy();
+
/// Profile - calculate a unique identifier for this MDNode to collapse
/// duplicates
void Profile(FoldingSetNodeID &ID) const;