• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 -lSystem -o %t.dylib %t.o -save-temps  -undefined dynamic_lookup -exported_symbol _c -exported_symbol _b  -exported_symbol _GlobLinkonce
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 i8*] [i8* bitcast ([1 x i8*]* @GlobLinkonce to i8*), i8* bitcast (void ()* @b to i8*)], 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: 0000000000000f48 S _GlobLinkonce
13; NM: 0000000000000f10 t _a
14; NM: 0000000000000f20 T _b
15; NM: 0000000000000f00 T _c
16
17
18target triple = "x86_64-apple-macosx10.10.0"
19
20declare void @external()
21
22@GlobLinkonce = linkonce_odr unnamed_addr constant [1 x i8*] [i8* null], align 8
23
24define linkonce_odr void @a() noinline {
25  %use_of_GlobLinkonce = load [1 x i8*], [1 x i8*] *@GlobLinkonce
26  call void @external()
27  ret void
28}
29
30define linkonce_odr void @b() {
31  ret void
32}
33
34define void()* @c() {
35  call void @a()
36  ret void()* @b
37}
38