1 ; RUN: split-file %s %t
2 ; RUN: opt -module-summary %t/a.ll -o %ta.bc
3 ; RUN: opt -module-summary %t/b.ll -o %tb.bc
5 ;; Test visibility propagation. The prevailing definitions are all from %tb.bc.
6 ; RUN: llvm-lto2 run -save-temps -enable-import-metadata -o %t1.bc %ta.bc %tb.bc \
7 ; RUN: -r=%ta.bc,_var1,l -r=%ta.bc,_var2,l \
8 ; RUN: -r=%ta.bc,_hidden_def_weak_def,l -r=%ta.bc,_not_imported,l -r=%ta.bc,_hidden_def_ref,l \
9 ; RUN: -r=%ta.bc,_hidden_def_weak_ref,l \
10 ; RUN: -r=%ta.bc,_ext, -r=%ta.bc,_main,plx \
11 ; RUN: -r=%tb.bc,_var1,plx -r=%tb.bc,_var2,plx \
12 ; RUN: -r=%tb.bc,_hidden_def_weak_def,pl -r=%tb.bc,_not_imported,pl -r=%tb.bc,_hidden_def_ref,pl \
13 ; RUN: -r=%tb.bc,_hidden_def_weak_ref,pl
14 ; RUN: llvm-dis < %t1.bc.1.3.import.bc | FileCheck %s
15 ; RUN: llvm-dis < %t1.bc.2.1.promote.bc | FileCheck %s --check-prefix=CHECK2
18 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
19 target triple = "x86_64-apple-macosx10.15.0"
21 ; CHECK: @var1 = external hidden global i32, align 4
22 ; CHECK-NEXT: @var2 = available_externally hidden global i32 1, align 4
24 @var1 = weak global i32 1, align 4
25 @var2 = extern_weak global i32
27 declare void @ext(ptr)
29 ; CHECK: declare hidden i32 @hidden_def_weak_def()
30 ;; Currently the visibility is not propagated onto an unimported function,
31 ;; because we don't have summaries for declarations.
32 ; CHECK: declare extern_weak dso_local void @not_imported()
33 ; CHECK: define available_externally hidden void @hidden_def_ref() !thinlto_src_module !0 !thinlto_src_file !1
34 ; CHECK: define available_externally hidden void @hidden_def_weak_ref() !thinlto_src_module !0 !thinlto_src_file !1
36 ; CHECK2: define hidden i32 @hidden_def_weak_def()
37 ; CHECK2: define hidden void @hidden_def_ref()
38 ; CHECK2: define hidden void @hidden_def_weak_ref()
39 ; CHECK2: define hidden void @not_imported()
41 define weak i32 @hidden_def_weak_def() {
43 %0 = load i32, ptr @var2
47 declare extern_weak void @not_imported()
49 declare void @hidden_def_ref()
50 declare extern_weak void @hidden_def_weak_ref()
54 call void @ext(ptr @hidden_def_weak_def)
55 call void @ext(ptr @hidden_def_ref)
56 call void @ext(ptr @hidden_def_weak_ref)
57 call void @ext(ptr @not_imported)
59 ;; Calls ensure the functions are imported.
60 call i32 @hidden_def_weak_def()
61 call void @hidden_def_ref()
62 call void @hidden_def_weak_ref()
67 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
68 target triple = "x86_64-apple-macosx10.15.0"
70 @var1 = hidden global i32 1, align 4
71 @var2 = hidden global i32 1, align 4
73 define hidden i32 @hidden_def_weak_def() {
75 %0 = load i32, ptr @var1
79 define hidden void @hidden_def_ref() {
84 define hidden void @hidden_def_weak_ref() {
89 define hidden void @not_imported() {