aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/Metadata.cpp
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-12-16 02:52:09 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-12-16 02:52:09 +0000
commit57c0f206011ce3dff01075c0b38a8c55c19c7fc9 (patch)
tree39d2a97cf680096ad5ad51528a0ff106d171a991 /lib/VMCore/Metadata.cpp
parentbbc71b2904644bfa85d8785328dc08d61c534467 (diff)
MDNodes that refer to an instruction are local to a function; in that case, explicitly keep track of the function they are local to
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91497 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Metadata.cpp')
-rw-r--r--lib/VMCore/Metadata.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp
index b80b6bfebc..713661680c 100644
--- a/lib/VMCore/Metadata.cpp
+++ b/lib/VMCore/Metadata.cpp
@@ -49,13 +49,15 @@ MDString *MDString::get(LLVMContext &Context, const char *Str) {
//===----------------------------------------------------------------------===//
// MDNode implementation.
//
-MDNode::MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals)
+MDNode::MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
+ Function *LocalFunction)
: MetadataBase(Type::getMetadataTy(C), Value::MDNodeVal) {
NodeSize = NumVals;
Node = new ElementVH[NodeSize];
ElementVH *Ptr = Node;
for (unsigned i = 0; i != NumVals; ++i)
*Ptr++ = ElementVH(Vals[i], this);
+ LocalFunction = LocalFunction;
}
void MDNode::Profile(FoldingSetNodeID &ID) const {
@@ -63,17 +65,20 @@ void MDNode::Profile(FoldingSetNodeID &ID) const {
ID.AddPointer(getElement(i));
}
-MDNode *MDNode::get(LLVMContext &Context, Value*const* Vals, unsigned NumVals) {
+MDNode *MDNode::get(LLVMContext &Context, Value*const* Vals, unsigned NumVals,
+ Function *LocalFunction) {
LLVMContextImpl *pImpl = Context.pImpl;
FoldingSetNodeID ID;
for (unsigned i = 0; i != NumVals; ++i)
ID.AddPointer(Vals[i]);
+ if (LocalFunction)
+ ID.AddPointer(LocalFunction);
void *InsertPoint;
MDNode *N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
if (!N) {
// InsertPoint will have been set by the FindNodeOrInsertPos call.
- N = new MDNode(Context, Vals, NumVals);
+ N = new MDNode(Context, Vals, NumVals, LocalFunction);
pImpl->MDNodeSet.InsertNode(N, InsertPoint);
}
return N;