[llvm-commits] [llvm] r78652 - in /llvm/trunk: lib/Linker/LinkModules.cpp test/Linker/linkmdnode.ll test/Linker/linkmdnode2.ll
Devang Patel
dpatel at apple.com
Mon Aug 10 23:46:31 PDT 2009
Author: dpatel
Date: Tue Aug 11 01:46:31 2009
New Revision: 78652
URL: http://llvm.org/viewvc/llvm-project?rev=78652&view=rev
Log:
Link metadata.
Added:
llvm/trunk/test/Linker/linkmdnode.ll
llvm/trunk/test/Linker/linkmdnode2.ll
Modified:
llvm/trunk/lib/Linker/LinkModules.cpp
Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=78652&r1=78651&r2=78652&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Tue Aug 11 01:46:31 2009
@@ -395,6 +395,14 @@
assert(!isa<GlobalValue>(CPV) && "Unmapped global?");
llvm_unreachable("Unknown type of derived type constant value!");
}
+ } else if (const MDNode *N = dyn_cast<MDNode>(In)) {
+ std::vector<Value*> Elems;
+ for (unsigned i = 0, e = N->getNumElements(); i !=e; ++i)
+ Elems.push_back(RemapOperand(N->getElement(i), ValueMap, Context));
+ if (!Elems.empty())
+ Result = MDNode::get(Context, &Elems[0], Elems.size());
+ } else if (const MDString *MDS = dyn_cast<MDString>(In)) {
+ Result = MDString::get(Context, MDS->getString());
} else if (isa<InlineAsm>(In)) {
Result = const_cast<Value*>(In);
}
Added: llvm/trunk/test/Linker/linkmdnode.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/linkmdnode.ll?rev=78652&view=auto
==============================================================================
--- llvm/trunk/test/Linker/linkmdnode.ll (added)
+++ llvm/trunk/test/Linker/linkmdnode.ll Tue Aug 11 01:46:31 2009
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s > %t.bc
+; RUN: llvm-as < %p/linkmdnode2.ll > %t2.bc
+; RUN: llvm-link %t.bc %t2.bc
+
+
+!21 = metadata !{i32 42, metadata !"foobar"}
+
+declare i8 @llvm.something(metadata %a)
+define void @foo() {
+ %x = call i8 @llvm.something(metadata !21)
+ ret void
+}
Added: llvm/trunk/test/Linker/linkmdnode2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/linkmdnode2.ll?rev=78652&view=auto
==============================================================================
--- llvm/trunk/test/Linker/linkmdnode2.ll (added)
+++ llvm/trunk/test/Linker/linkmdnode2.ll Tue Aug 11 01:46:31 2009
@@ -0,0 +1,12 @@
+; This file is used by linkmdnode.ll, so it doesn't actually do anything itself
+;
+; RUN: true
+
+!22 = metadata !{i32 42, metadata !"foobar"}
+
+declare i8 @llvm.something(metadata %a)
+define void @foo1() {
+ ;; Intrinsic using MDNode and MDString
+ %x = call i8 @llvm.something(metadata !22)
+ ret void
+}
More information about the llvm-commits
mailing list