1*a17f2cd1STeresa Johnson; RUN: llvm-as -function-summary %s -o %t.o 2*a17f2cd1STeresa Johnson; RUN: llvm-as -function-summary %p/Inputs/thinlto_linkonceresolution.ll -o %t2.o 3*a17f2cd1STeresa Johnson 4*a17f2cd1STeresa Johnson; Ensure the plugin ensures that for ThinLTO the prevailing copy of a 5*a17f2cd1STeresa Johnson; linkonce symbol is changed to weak to ensure it is not eliminated. 6*a17f2cd1STeresa Johnson; Note that gold picks the first copy of f() as the prevailing one, 7*a17f2cd1STeresa Johnson; so listing %t2.o first is sufficient to ensure that this copy is 8*a17f2cd1STeresa Johnson; preempted. Also, set the import-instr-limit to 0 to prevent f() from 9*a17f2cd1STeresa Johnson; being imported from %t2.o which hides the problem. 10*a17f2cd1STeresa Johnson; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ 11*a17f2cd1STeresa Johnson; RUN: --plugin-opt=thinlto \ 12*a17f2cd1STeresa Johnson; RUN: --plugin-opt=-import-instr-limit=0 \ 13*a17f2cd1STeresa Johnson; RUN: --plugin-opt=save-temps \ 14*a17f2cd1STeresa Johnson; RUN: -o %t3.o %t2.o %t.o 15*a17f2cd1STeresa Johnson; RUN: llvm-nm %t3.o | FileCheck %s 16*a17f2cd1STeresa Johnson; RUN: llvm-dis %t.o.opt.bc -o - | FileCheck --check-prefix=OPT %s 17*a17f2cd1STeresa Johnson; RUN: llvm-dis %t2.o.opt.bc -o - | FileCheck --check-prefix=OPT2 %s 18*a17f2cd1STeresa Johnson 19*a17f2cd1STeresa Johnson; Ensure that f() is defined in resulting object file, and also 20*a17f2cd1STeresa Johnson; confirm the weak linkage directly in the saved opt bitcode files. 21*a17f2cd1STeresa Johnson; CHECK-NOT: U f 22*a17f2cd1STeresa Johnson; OPT: declare extern_weak hidden void @f() 23*a17f2cd1STeresa Johnson; OPT2: define weak_odr hidden void @f() 24*a17f2cd1STeresa Johnson 25*a17f2cd1STeresa Johnsontarget triple = "x86_64-unknown-linux-gnu" 26*a17f2cd1STeresa Johnsondefine i32 @g() { 27*a17f2cd1STeresa Johnson call void @f() 28*a17f2cd1STeresa Johnson ret i32 0 29*a17f2cd1STeresa Johnson} 30*a17f2cd1STeresa Johnsondefine linkonce_odr hidden void @f() { 31*a17f2cd1STeresa Johnson ret void 32*a17f2cd1STeresa Johnson} 33