1 ; RUN: split-file %s %t
2 ; RUN: opt -module-summary %t/a.ll -o %t/a.bc
3 ; RUN: opt -module-summary %t/b.ll -o %t/b.bc
5 ;; With a small limit, *_aux are either imported declarations (external/linkonce_odr/weak_odr)
6 ;; or unimported (linkonce/weak). Check we discard dso_local.
7 ; RUN: llvm-lto2 run %t/a.bc %t/b.bc -o %t1 -save-temps -import-instr-limit=3 \
8 ; RUN: -r=%t/a.bc,main,plx -r=%t/a.bc,extern, -r=%t/a.bc,linkonce, -r=%t/a.bc,linkonceodr, -r=%t/a.bc,weak, -r=%t/a.bc,weakodr, \
9 ; RUN: -r=%t/b.bc,a,pl -r=%t/b.bc,b,pl -r=%t/b.bc,extern,pl -r=%t/b.bc,extern_aux,pl \
10 ; RUN: -r=%t/b.bc,linkonce,pl -r=%t/b.bc,linkonce_aux,pl -r=%t/b.bc,linkonceodr,pl -r=%t/b.bc,linkonceodr_aux,pl \
11 ; RUN: -r=%t/b.bc,weak,pl -r=%t/b.bc,weak_aux,pl -r=%t/b.bc,weakodr,pl -r=%t/b.bc,weakodr_aux,pl
12 ; RUN: llvm-dis %t1.1.3.import.bc -o - | FileCheck %s --check-prefixes=DEST,DEST1
14 ;; With a large limit, *_aux are either imported definitions (external/linkonce_odr/weak_odr)
15 ;; or unimported (linkonce/weak). Check we discard dso_local as well.
16 ; RUN: llvm-lto2 run %t/a.bc %t/b.bc -o %t2 -save-temps -import-instr-limit=10 \
17 ; RUN: -r=%t/a.bc,main,plx -r=%t/a.bc,extern, -r=%t/a.bc,linkonce, -r=%t/a.bc,linkonceodr, -r=%t/a.bc,weak, -r=%t/a.bc,weakodr, \
18 ; RUN: -r=%t/b.bc,a,pl -r=%t/b.bc,b,pl -r=%t/b.bc,extern,pl -r=%t/b.bc,extern_aux,pl \
19 ; RUN: -r=%t/b.bc,linkonce,pl -r=%t/b.bc,linkonce_aux,pl -r=%t/b.bc,linkonceodr,pl -r=%t/b.bc,linkonceodr_aux,pl \
20 ; RUN: -r=%t/b.bc,weak,pl -r=%t/b.bc,weak_aux,pl -r=%t/b.bc,weakodr,pl -r=%t/b.bc,weakodr_aux,pl
21 ; RUN: llvm-dis %t2.1.3.import.bc -o - | FileCheck %s --check-prefixes=DEST,DEST2
23 ; DEST: @a = available_externally global i32 42, align 4
24 ; DEST-NEXT: @b = external global ptr, align 8
25 ; DEST: declare void @linkonce()
26 ; DEST: declare void @weak()
27 ; DEST: define dso_local i32 @main()
28 ; DEST: define available_externally void @extern()
30 ; DEST1: declare i32 @extern_aux(ptr, ptr)
31 ; DEST1: declare i32 @linkonceodr_aux(ptr, ptr)
32 ; DEST2: define available_externally i32 @extern_aux(ptr %a, ptr %b)
33 ; DEST2: define available_externally i32 @linkonceodr_aux(ptr %a, ptr %b)
35 ; DEST: define available_externally void @weakodr()
37 ; DEST1: declare i32 @weakodr_aux(ptr, ptr)
38 ; DEST2: define available_externally i32 @weakodr_aux(ptr %a, ptr %b)
41 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
42 target triple = "x86_64-unknown-linux-gnu"
44 declare void @extern()
45 declare void @linkonce()
46 declare void @linkonceodr()
48 declare void @weakodr()
53 call void @linkonceodr()
60 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
61 target triple = "x86_64-unknown-linux-gnu"
63 @a = dso_local global i32 42, align 4
64 @b = dso_local global ptr @a, align 8
66 define dso_local void @extern() {
67 call i32 @extern_aux(ptr @a, ptr @b)
71 define dso_local i32 @extern_aux(ptr %a, ptr %b) {
72 %p = load ptr, ptr %b, align 8
73 store i32 33, ptr %p, align 4
74 %v = load i32, ptr %a, align 4
78 define linkonce dso_local void @linkonce() {
79 call i32 @linkonce_aux(ptr @a, ptr @b)
83 define linkonce i32 @linkonce_aux(ptr %a, ptr %b) {
84 %p = load ptr, ptr %b, align 8
85 store i32 33, ptr %p, align 4
86 %v = load i32, ptr %a, align 4
90 define linkonce_odr dso_local void @linkonceodr() {
91 call i32 @linkonceodr_aux(ptr @a, ptr @b)
95 define linkonce_odr i32 @linkonceodr_aux(ptr %a, ptr %b) {
96 %p = load ptr, ptr %b, align 8
97 store i32 33, ptr %p, align 4
98 %v = load i32, ptr %a, align 4
102 define weak dso_local void @weak() {
103 call i32 @weak_aux(ptr @a, ptr @b)
107 define weak i32 @weak_aux(ptr %a, ptr %b) {
108 %p = load ptr, ptr %b, align 8
109 store i32 33, ptr %p, align 4
110 %v = load i32, ptr %a, align 4
114 define weak_odr dso_local void @weakodr() {
115 call i32 @weakodr_aux(ptr @a, ptr @b)
119 define weak_odr i32 @weakodr_aux(ptr %a, ptr %b) {
120 %p = load ptr, ptr %b, align 8
121 store i32 33, ptr %p, align 4
122 %v = load i32, ptr %a, align 4