168da426eSMehdi Amini; RUN: opt -module-summary %s -o %t.o
268da426eSMehdi Amini; RUN: opt -module-summary %p/Inputs/thinlto_linkonceresolution.ll -o %t2.o
3a17f2cd1STeresa Johnson
4a17f2cd1STeresa Johnson; Ensure the plugin ensures that for ThinLTO the prevailing copy of a
5a17f2cd1STeresa Johnson; linkonce symbol is changed to weak to ensure it is not eliminated.
6a17f2cd1STeresa Johnson; Note that gold picks the first copy of f() as the prevailing one,
7a17f2cd1STeresa Johnson; so listing %t2.o first is sufficient to ensure that this copy is
8a17f2cd1STeresa Johnson; preempted. Also, set the import-instr-limit to 0 to prevent f() from
9a17f2cd1STeresa Johnson; being imported from %t2.o which hides the problem.
103efcfaddSEugene Leviant; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
11a17f2cd1STeresa Johnson; RUN:     --plugin-opt=thinlto \
12a17f2cd1STeresa Johnson; RUN:     --plugin-opt=-import-instr-limit=0 \
13a17f2cd1STeresa Johnson; RUN:     --plugin-opt=save-temps \
147ab1f692STeresa Johnson; RUN:     -shared \
15a17f2cd1STeresa Johnson; RUN:     -o %t3.o %t2.o %t.o
16a17f2cd1STeresa Johnson; RUN: llvm-nm %t3.o | FileCheck %s
179ba95f99STeresa Johnson; RUN: llvm-dis %t.o.4.opt.bc -o - | FileCheck --check-prefix=OPT %s
189ba95f99STeresa Johnson; RUN: llvm-dis %t2.o.4.opt.bc -o - | FileCheck --check-prefix=OPT2 %s
19a17f2cd1STeresa Johnson
20a17f2cd1STeresa Johnson; Ensure that f() is defined in resulting object file, and also
21a17f2cd1STeresa Johnson; confirm the weak linkage directly in the saved opt bitcode files.
22a17f2cd1STeresa Johnson; CHECK-NOT: U f
239ba95f99STeresa Johnson; OPT-NOT: @f()
24*9fbc0405SRafael Espindola; OPT2: define weak_odr hidden void @f()
25a17f2cd1STeresa Johnson
262ceb628fSDavide Italianotarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
27a17f2cd1STeresa Johnsontarget triple = "x86_64-unknown-linux-gnu"
28a17f2cd1STeresa Johnsondefine i32 @g() {
29a17f2cd1STeresa Johnson  call void @f()
30a17f2cd1STeresa Johnson  ret i32 0
31a17f2cd1STeresa Johnson}
32a17f2cd1STeresa Johnsondefine linkonce_odr hidden void @f() {
33a17f2cd1STeresa Johnson  ret void
34a17f2cd1STeresa Johnson}
35