2 ; RUN: rm -rf %t; split-file %s %t
4 ;; Check that `-exported_symbol` causes all non-exported symbols to be marked
5 ;; as hidden before LTO. We don't want to downgrade them to private extern only
6 ;; after LTO runs as that likely causes LTO to miss optimization opportunities.
8 ; RUN: llvm-as %t/foo.ll -o %t/foo.o
9 ; RUN: llvm-as %t/refs-foo.ll -o %t/refs-foo.o
11 ; RUN: %lld -lSystem -dylib %t/foo.o %t/refs-foo.o -o %t/test-fulllto \
12 ; RUN: -save-temps -exported_symbol _refs_foo -exported_symbol _same_module_caller
14 ; RUN: llvm-dis %t/test-fulllto.0.2.internalize.bc -o - | FileCheck %s --check-prefix=FULLLTO
15 ; RUN: llvm-objdump --macho --syms %t/test-fulllto | FileCheck %s --check-prefix=FULLLTO-SYMS
17 ; FULLLTO: define internal void @foo()
18 ; FULLLTO: define internal void @same_module_callee()
19 ; FULLLTO: define dso_local void @same_module_caller()
20 ; FULLLTO: define dso_local void @refs_foo()
22 ;; LTO is able to elide the hidden symbols, and they will be entirely absent
23 ;; from the final symbol table.
25 ; FULLLTO-SYMS: SYMBOL TABLE:
26 ; FULLLTO-SYMS: g F __TEXT,__text _same_module_caller
27 ; FULLLTO-SYMS: g F __TEXT,__text _refs_foo
28 ; FULLLTO-SYMS: *UND* dyld_stub_binder
31 ;; ThinLTO is unable to internalize symbols that are referenced from another
32 ;; module. Verify that we still mark the final symbol as private extern.
34 ; RUN: opt -module-summary %t/foo.ll -o %t/foo.thinlto.o
35 ; RUN: opt -module-summary %t/refs-foo.ll -o %t/refs-foo.thinlto.o
37 ; RUN: %lld -lSystem -dylib %t/foo.thinlto.o %t/refs-foo.thinlto.o -o %t/test-thinlto \
38 ; RUN: -save-temps -exported_symbol _refs_foo -exported_symbol _same_module_caller
40 ; RUN: llvm-dis %t/foo.thinlto.o.2.internalize.bc -o - | FileCheck %s --check-prefix=THINLTO-FOO
41 ; RUN: llvm-dis %t/refs-foo.thinlto.o.2.internalize.bc -o - | FileCheck %s --check-prefix=THINLTO-REFS-FOO
42 ; RUN: llvm-objdump --macho --syms %t/test-thinlto | FileCheck %s --check-prefix=THINLTO-SYMS
44 ; THINLTO-FOO: define dso_local void @foo()
45 ; THINLTO-FOO: define internal void @same_module_callee()
46 ; THINLTO-REFS-FOO: declare dso_local void @foo()
47 ; THINLTO-REFS-FOO: define dso_local void @refs_foo()
49 ; THINLTO-SYMS: l F __TEXT,__text .hidden _foo
50 ; THINLTO-SYMS: g F __TEXT,__text _same_module_caller
51 ; THINLTO-SYMS: g F __TEXT,__text _refs_foo
55 target triple = "x86_64-apple-macosx10.15.0"
56 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
62 define void @same_module_callee() {
66 define void @same_module_caller() {
67 call void @same_module_callee()
73 target triple = "x86_64-apple-macosx10.15.0"
74 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
78 define void @refs_foo() {