82 lines · plain
1; REQUIRES: x862; RUN: rm -rf %t; split-file %s %t3 4;; Check that `-exported_symbol` causes all non-exported symbols to be marked5;; as hidden before LTO. We don't want to downgrade them to private extern only6;; after LTO runs as that likely causes LTO to miss optimization opportunities.7 8; RUN: llvm-as %t/foo.ll -o %t/foo.o9; RUN: llvm-as %t/refs-foo.ll -o %t/refs-foo.o10 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_caller13 14; RUN: llvm-dis %t/test-fulllto.0.2.internalize.bc -o - | FileCheck %s --check-prefix=FULLLTO15; RUN: llvm-objdump --macho --syms %t/test-fulllto | FileCheck %s --check-prefix=FULLLTO-SYMS16 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()21 22;; LTO is able to elide the hidden symbols, and they will be entirely absent23;; from the final symbol table.24 25; FULLLTO-SYMS: SYMBOL TABLE:26; FULLLTO-SYMS: g F __TEXT,__text _refs_foo27; FULLLTO-SYMS: g F __TEXT,__text _same_module_caller28; FULLLTO-SYMS: *UND* dyld_stub_binder29; FULLLTO-SYMS-EMPTY:30 31;; ThinLTO is unable to internalize symbols that are referenced from another32;; module. Verify that we still mark the final symbol as private extern.33 34; RUN: opt -module-summary %t/foo.ll -o %t/foo.thinlto.o35; RUN: opt -module-summary %t/refs-foo.ll -o %t/refs-foo.thinlto.o36 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_caller39 40; RUN: llvm-dis %t/foo.thinlto.o.2.internalize.bc -o - | FileCheck %s --check-prefix=THINLTO-FOO41; RUN: llvm-dis %t/refs-foo.thinlto.o.2.internalize.bc -o - | FileCheck %s --check-prefix=THINLTO-REFS-FOO42; RUN: llvm-objdump --macho --syms %t/test-thinlto | FileCheck %s --check-prefix=THINLTO-SYMS43 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()48 49; THINLTO-SYMS: l F __TEXT,__text .hidden _foo50; THINLTO-SYMS: g F __TEXT,__text _refs_foo51; THINLTO-SYMS: g F __TEXT,__text _same_module_caller52 53;--- foo.ll54 55target triple = "x86_64-apple-macosx10.15.0"56target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"57 58define void @foo() {59 ret void60}61 62define void @same_module_callee() {63 ret void64}65 66define void @same_module_caller() {67 call void @same_module_callee()68 ret void69}70 71;--- refs-foo.ll72 73target triple = "x86_64-apple-macosx10.15.0"74target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"75 76declare void @foo()77 78define void @refs_foo() {79 call void @foo()80 ret void81}82