• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test to ensure that ThinLTO sorts the modules before passing to the
2; final native link based on the linker's determination of which
3; object within a static library contains the prevailing def of a symbol.
4
5; First generate bitcode with a module summary index for each file
6; RUN: opt -module-summary %s -o %t.o
7; RUN: opt -module-summary %p/Inputs/thinlto_weak_library1.ll -o %t2.o
8; RUN: opt -module-summary %p/Inputs/thinlto_weak_library2.ll -o %t3.o
9
10; Although the objects are ordered "%t2.o %t3.o" in the library, the
11; linker selects %t3.o first since it satisfies a strong reference from
12; %t.o. It later selects %t2.o based on the strong ref from %t3.o.
13; Therefore, %t3.o's copy of @f is prevailing, and we need to link
14; %t3.o before %t2.o in the final native link.
15; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
16; RUN:    --plugin-opt=thinlto \
17; RUN:    --plugin-opt=save-temps \
18; RUN:    -m elf_x86_64 \
19; RUN:    -o %t4 \
20; RUN:    %t.o \
21; RUN:    --start-lib %t2.o %t3.o --end-lib
22
23; Make sure we completely dropped the definition of the non-prevailing
24; copy of f() (and didn't simply convert to available_externally, which
25; would incorrectly enable inlining).
26; RUN: llvm-dis %t2.o.1.promote.bc -o - | FileCheck %s
27; CHECK: declare i32 @f()
28
29; ModuleID = 'thinlto_weak_library.c'
30source_filename = "thinlto_weak_library.c"
31target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
32target triple = "x86_64-unknown-linux-gnu"
33
34; Function Attrs: nounwind uwtable
35define i32 @main() local_unnamed_addr {
36entry:
37  tail call void (...) @test2()
38  ret i32 0
39}
40
41declare void @test2(...) local_unnamed_addr
42