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 4 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 16 17;--- a.ll 18target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 19target triple = "x86_64-apple-macosx10.15.0" 20 21; CHECK: @var1 = external hidden global i32, align 4 22; CHECK-NEXT: @var2 = available_externally hidden global i32 1, align 4 23 24@var1 = weak global i32 1, align 4 25@var2 = extern_weak global i32 26 27declare void @ext(ptr) 28 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 35 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() 40 41define weak i32 @hidden_def_weak_def() { 42entry: 43 %0 = load i32, ptr @var2 44 ret i32 %0 45} 46 47declare extern_weak void @not_imported() 48 49declare void @hidden_def_ref() 50declare extern_weak void @hidden_def_weak_ref() 51 52define i32 @main() { 53entry: 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) 58 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() 63 ret i32 0 64} 65 66;--- b.ll 67target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 68target triple = "x86_64-apple-macosx10.15.0" 69 70@var1 = hidden global i32 1, align 4 71@var2 = hidden global i32 1, align 4 72 73define hidden i32 @hidden_def_weak_def() { 74entry: 75 %0 = load i32, ptr @var1 76 ret i32 %0 77} 78 79define hidden void @hidden_def_ref() { 80entry: 81 ret void 82} 83 84define hidden void @hidden_def_weak_ref() { 85entry: 86 ret void 87} 88 89define hidden void @not_imported() { 90entry: 91 ret void 92} 93