1*7ab1f692STeresa Johnson; RUN: opt -module-summary %s -o %t.o
2*7ab1f692STeresa Johnson; RUN: opt -module-summary %p/Inputs/thinlto_alias.ll -o %t2.o
3*7ab1f692STeresa Johnson
4*7ab1f692STeresa Johnson; Ensure that a preempted weak symbol that is linked in as a local
5*7ab1f692STeresa Johnson; copy is handled properly. Specifically, the local copy will be promoted,
6*7ab1f692STeresa Johnson; and internalization should be able to use the original non-promoted
7*7ab1f692STeresa Johnson; name to locate the summary (otherwise internalization will abort because
8*7ab1f692STeresa Johnson; it expects to locate summaries for all definitions).
9*7ab1f692STeresa Johnson; Note that gold picks the first copy of weakfunc() as the prevailing one,
10*7ab1f692STeresa Johnson; so listing %t2.o first is sufficient to ensure that this copy is
11*7ab1f692STeresa Johnson; preempted.
12*7ab1f692STeresa Johnson; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold.so \
13*7ab1f692STeresa Johnson; RUN:     --plugin-opt=thinlto \
14*7ab1f692STeresa Johnson; RUN:     --plugin-opt=save-temps \
15*7ab1f692STeresa Johnson; RUN:     -o %t3.o %t2.o %t.o
16*7ab1f692STeresa Johnson; RUN: llvm-nm %t3.o | FileCheck %s
17*7ab1f692STeresa Johnson; RUN: llvm-dis %t.o.opt.bc -o - | FileCheck --check-prefix=OPT %s
18*7ab1f692STeresa Johnson; RUN: llvm-dis %t2.o.opt.bc -o - | FileCheck --check-prefix=OPT2 %s
19*7ab1f692STeresa Johnson
20*7ab1f692STeresa Johnson; CHECK-NOT: U f
21*7ab1f692STeresa Johnson; OPT: define hidden void @weakfunc.llvm.0()
22*7ab1f692STeresa Johnson; OPT2: define weak void @weakfunc()
23*7ab1f692STeresa Johnson
24*7ab1f692STeresa Johnsontarget triple = "x86_64-unknown-linux-gnu"
25*7ab1f692STeresa Johnson
26*7ab1f692STeresa Johnson@weakfuncAlias = alias void (...), bitcast (void ()* @weakfunc to void (...)*)
27*7ab1f692STeresa Johnsondefine weak void @weakfunc() {
28*7ab1f692STeresa Johnsonentry:
29*7ab1f692STeresa Johnson  ret void
30*7ab1f692STeresa Johnson}
31