llvm.org GIT mirror llvm / 8efc190
Linker: Copy over function metadata attachments Update `lib/Linker` to handle `Function` metadata attachments. The attachments stick with the function body. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235786 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 5 years ago
3 changed file(s) with 46 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
12041204 ++DI;
12051205 }
12061206
1207 // Copy over the metadata attachments.
1208 SmallVector, 8> MDs;
1209 Src.getAllMetadata(MDs);
1210 for (const auto &I : MDs)
1211 Dst.setMetadata(I.first, MapMetadata(I.second, ValueMap, RF_None, &TypeMap,
1212 &ValMaterializer));
1213
12071214 // Splice the body of the source function into the dest function.
12081215 Dst.getBasicBlockList().splice(Dst.end(), Src.getBasicBlockList());
12091216
0 define weak void @foo() !weak !0 {
1 unreachable
2 }
3
4 define void @baz() !baz !0 {
5 unreachable
6 }
7
8 define void @b() !b !0 {
9 unreachable
10 }
11
12 !0 = !{!"b"}
0 ; RUN: llvm-link %s %S/Inputs/metadata-function.ll -S | FileCheck %s
1 ; RUN: llvm-link %S/Inputs/metadata-function.ll %s -S | FileCheck %s
2
3 ; CHECK-DAG: define weak void @foo() !weak ![[B:[0-9]+]] {
4 define linkonce void @foo() !linkonce !0 {
5 unreachable
6 }
7
8 ; CHECK-DAG: define void @bar() !bar ![[A:[0-9]+]] {
9 define void @bar() !bar !0 {
10 call void @baz()
11 unreachable
12 }
13
14 ; CHECK-DAG: define void @baz() !baz ![[B]] {
15 declare void @baz()
16
17 ; CHECK-DAG: define void @a() !a ![[A]] {
18 ; CHECK-DAG: define void @b() !b ![[B]] {
19 define void @a() !a !0 {
20 unreachable
21 }
22
23 ; CHECK-DAG: ![[A]] = !{!"a"}
24 ; CHECK-DAG: ![[B]] = !{!"b"}
25 !0 = !{!"a"}