Remove some unused variables to clean up the -Werror build
[oota-llvm.git] / test / Linker / only-needed-named-metadata.ll
1 ; RUN: llvm-as %S/only-needed-named-metadata.ll -o %t.bc
2 ; RUN: llvm-as %S/Inputs/only-needed-named-metadata.ll -o %t2.bc
3
4 ; Without -only-needed we should lazy link linkonce globals, and the
5 ; metadata reference should not cause them to be linked.
6 ; RUN: llvm-link -S %t2.bc %t.bc | FileCheck %s
7 ; CHECK-NOT:@U_linkonce
8 ; CHECK-NOT:@unused_linkonce()
9
10 ; With -only-needed the metadata references should not cause any of the
11 ; otherwise unreferenced globals to be linked. This also ensures that the
12 ; metadata references don't provoke the module linker to create declarations,
13 ; which are illegal for aliases and globals in comdats.
14 ; Note that doing -only-needed with the comdat shown below leads to a only
15 ; part of the comdat group being linked, which is not technically correct.
16 ; RUN: llvm-link -S -only-needed %t2.bc %t.bc | FileCheck %s -check-prefix=ONLYNEEDED
17 ; RUN: llvm-link -S -internalize -only-needed %t2.bc %t.bc | FileCheck %s -check-prefix=ONLYNEEDED
18 ; ONLYNEEDED-NOT:@U
19 ; ONLYNEEDED-NOT:@U_linkonce
20 ; ONLYNEEDED-NOT:@unused()
21 ; ONLYNEEDED-NOT:@unused_linkonce()
22 ; ONLYNEEDED-NOT:@linkoncealias
23 ; ONLYNEEDED-NOT:@linkoncefunc2()
24 ; ONLYNEEDED-NOT:@weakalias
25 ; ONLYNEEDED-NOT:@globalfunc1()
26 ; ONLYNEEDED-NOT:@analias
27 ; ONLYNEEDED-NOT:@globalfunc2()
28 ; ONLYNEEDED-NOT:@c1_c
29 ; ONLYNEEDED-NOT:@c1()
30
31 $c1 = comdat any
32 @c1_c = global i32 0, comdat($c1)
33 define void @c1() comdat {
34   ret void
35 }
36 define void @c1_a() comdat($c1) {
37   ret void
38 }
39
40 @X = global i32 5
41 @U = global i32 6
42 @U_linkonce = linkonce_odr hidden global i32 6
43 define i32 @foo() { ret i32 7 }
44 define i32 @unused() { ret i32 8 }
45 define linkonce_odr hidden i32 @unused_linkonce() { ret i32 8 }
46 @linkoncealias = alias void (...), bitcast (void ()* @linkoncefunc2 to void (...)*)
47
48 @weakalias = weak alias void (...), bitcast (void ()* @globalfunc1 to void (...)*)
49 @analias = alias void (...), bitcast (void ()* @globalfunc2 to void (...)*)
50
51 define void @globalfunc1() #0 {
52 entry:
53   ret void
54 }
55
56 define void @globalfunc2() #0 {
57 entry:
58   ret void
59 }
60
61 $linkoncefunc2 = comdat any
62 define linkonce_odr void @linkoncefunc2() #0 comdat {
63 entry:
64   ret void
65 }
66
67 !llvm.named = !{!0, !1, !2, !3, !4, !5, !6, !7}
68 !0 = !{i32 ()* @unused}
69 !1 = !{i32* @U}
70 !2 = !{i32 ()* @unused_linkonce}
71 !3 = !{i32* @U_linkonce}
72 !4 = !{void (...)* @weakalias}
73 !5 = !{void (...)* @analias}
74 !6 = !{void (...)* @linkoncealias}
75 !7 = !{void ()* @c1}