blob: 810b2dd7b2d089b369543969bd4b08ec658a047e [file] [log] [blame]
Mehdi Amini68da4262016-04-12 21:35:18 +00001; RUN: opt -module-summary %s -o %t.o
2; RUN: opt -module-summary %p/Inputs/thinlto_linkonceresolution.ll -o %t2.o
Teresa Johnsona17f2cd2016-03-04 17:48:35 +00003
4; Ensure the plugin ensures that for ThinLTO the prevailing copy of a
5; linkonce symbol is changed to weak to ensure it is not eliminated.
6; Note that gold picks the first copy of f() as the prevailing one,
7; so listing %t2.o first is sufficient to ensure that this copy is
8; preempted. Also, set the import-instr-limit to 0 to prevent f() from
9; being imported from %t2.o which hides the problem.
Teresa Johnson5d075312016-03-04 21:19:08 +000010; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold.so \
Teresa Johnsona17f2cd2016-03-04 17:48:35 +000011; RUN: --plugin-opt=thinlto \
12; RUN: --plugin-opt=-import-instr-limit=0 \
13; RUN: --plugin-opt=save-temps \
Teresa Johnson7ab1f692016-06-09 01:14:13 +000014; RUN: -shared \
Teresa Johnsona17f2cd2016-03-04 17:48:35 +000015; RUN: -o %t3.o %t2.o %t.o
16; RUN: llvm-nm %t3.o | FileCheck %s
Teresa Johnson9ba95f92016-08-11 14:58:12 +000017; RUN: llvm-dis %t.o.4.opt.bc -o - | FileCheck --check-prefix=OPT %s
18; RUN: llvm-dis %t2.o.4.opt.bc -o - | FileCheck --check-prefix=OPT2 %s
Teresa Johnsona17f2cd2016-03-04 17:48:35 +000019
20; Ensure that f() is defined in resulting object file, and also
21; confirm the weak linkage directly in the saved opt bitcode files.
22; CHECK-NOT: U f
Teresa Johnson9ba95f92016-08-11 14:58:12 +000023; OPT-NOT: @f()
Teresa Johnsona17f2cd2016-03-04 17:48:35 +000024; OPT2: define weak_odr hidden void @f()
25
26target triple = "x86_64-unknown-linux-gnu"
27define i32 @g() {
28 call void @f()
29 ret i32 0
30}
31define linkonce_odr hidden void @f() {
32 ret void
33}