xref: /llvm-project/llvm/test/tools/lto/hide-linkonce-odr.ll (revision a273c40820f78d8b08e411897eee84dbda983488)
1; RUN: llvm-as %s -o %t.o
2; RUN: %ld64 -lto_library %llvmshlibdir/libLTO.dylib -dylib -arch x86_64 -macosx_version_min 10.10.0 -o %t.dylib %t.o -save-temps  -undefined dynamic_lookup -exported_symbol _c -exported_symbol _b  -exported_symbol _GlobLinkonce -lSystem
3
4; RUN: llvm-dis %t.dylib.lto.opt.bc -o - | FileCheck --check-prefix=IR %s
5; check that @a is no longer a linkonce_odr definition
6; IR-NOT: define linkonce_odr void @a()
7; check that @b is appended in llvm.used
8; IR: @llvm.compiler.used = appending global [2 x ptr] [ptr @GlobLinkonce, ptr @b], section "llvm.metadata"
9
10; RUN: llvm-nm %t.dylib | FileCheck --check-prefix=NM %s
11; check that the linker can hide @a but not @b, nor @GlobLinkonce
12; NM:  S _GlobLinkonce
13; NM:  t _a
14; NM:  T _b
15; NM:  T _c
16
17
18target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
19target triple = "x86_64-apple-macosx10.10.0"
20
21declare void @external()
22
23@GlobLinkonce = linkonce_odr unnamed_addr constant [1 x ptr] [ptr null], align 8
24
25define linkonce_odr void @a() noinline {
26  %use_of_GlobLinkonce = load [1 x ptr], ptr@GlobLinkonce
27  call void @external()
28  ret void
29}
30
31define linkonce_odr void @b() {
32  ret void
33}
34
35define ptr @c() {
36  call void @a()
37  ret ptr @b
38}
39