diff options
| author | Dan Gohman <gohman@apple.com> | 2010-08-24 23:21:12 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2010-08-24 23:21:12 +0000 |
| commit | 01579b20a6ea42e5a01b708bea595ca07ddcb201 (patch) | |
| tree | 9c6e5ccc83584117c9802b3a30ceff59db0f4477 | |
| parent | 05bcb488b5be7e2d837a0b09aea5074d8397d5d9 (diff) | |
| download | bcm5719-llvm-01579b20a6ea42e5a01b708bea595ca07ddcb201.tar.gz bcm5719-llvm-01579b20a6ea42e5a01b708bea595ca07ddcb201.zip | |
Don't include the is-function-local bit in the FoldingSetNodeID
for MDNodes, since this information is effectively implied by
the operands. This allow allows the code to avoid doing a
recursive is-it-really-function-local check in some cases.
llvm-svn: 111995
| -rw-r--r-- | llvm/lib/VMCore/Metadata.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/llvm/lib/VMCore/Metadata.cpp b/llvm/lib/VMCore/Metadata.cpp index 7f7b9eca59a..17e0bc28da0 100644 --- a/llvm/lib/VMCore/Metadata.cpp +++ b/llvm/lib/VMCore/Metadata.cpp @@ -187,6 +187,19 @@ MDNode *MDNode::getMDNode(LLVMContext &Context, Value *const *Vals, unsigned NumVals, FunctionLocalness FL, bool Insert) { LLVMContextImpl *pImpl = Context.pImpl; + + // Add all the operand pointers. Note that we don't have to add the + // isFunctionLocal bit because that's implied by the operands. + FoldingSetNodeID ID; + for (unsigned i = 0; i != NumVals; ++i) + ID.AddPointer(Vals[i]); + + void *InsertPoint; + MDNode *N = NULL; + + if ((N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint))) + return N; + bool isFunctionLocal = false; switch (FL) { case FL_Unknown: @@ -207,20 +220,6 @@ MDNode *MDNode::getMDNode(LLVMContext &Context, Value *const *Vals, break; } - FoldingSetNodeID ID; - for (unsigned i = 0; i != NumVals; ++i) - ID.AddPointer(Vals[i]); - ID.AddBoolean(isFunctionLocal); - - void *InsertPoint; - MDNode *N = NULL; - - if ((N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint))) - return N; - - if (!Insert) - return NULL; - // Coallocate space for the node and Operands together, then placement new. void *Ptr = malloc(sizeof(MDNode)+NumVals*sizeof(MDNodeOperand)); N = new (Ptr) MDNode(Context, Vals, NumVals, isFunctionLocal); @@ -275,9 +274,10 @@ Value *MDNode::getOperand(unsigned i) const { } void MDNode::Profile(FoldingSetNodeID &ID) const { + // Add all the operand pointers. Note that we don't have to add the + // isFunctionLocal bit because that's implied by the operands. for (unsigned i = 0, e = getNumOperands(); i != e; ++i) ID.AddPointer(getOperand(i)); - ID.AddBoolean(isFunctionLocal()); } void MDNode::setIsNotUniqued() { |

