aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Metadata.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-08-24 23:21:12 +0000
committerDan Gohman <gohman@apple.com>2010-08-24 23:21:12 +0000
commit7548fb37f1fe2187c97a1fb5bf1d44e9cd34698f (patch)
treefd29f5370b88fb070865abea72f7a9391567069c /lib/VMCore/Metadata.cpp
parent3ac18845098b34b7b76c6fa4b95cfde7752ff8ad (diff)
downloadexternal_llvm-7548fb37f1fe2187c97a1fb5bf1d44e9cd34698f.zip
external_llvm-7548fb37f1fe2187c97a1fb5bf1d44e9cd34698f.tar.gz
external_llvm-7548fb37f1fe2187c97a1fb5bf1d44e9cd34698f.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111995 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Metadata.cpp')
-rw-r--r--lib/VMCore/Metadata.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp
index 7f7b9ec..17e0bc2 100644
--- a/lib/VMCore/Metadata.cpp
+++ b/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() {