brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 6c19319 Raw
42 lines · plain
1; Test to ensure that ThinLTO sorts the modules before passing to the2; final native link based on the linker's determination of which3; object within a static library contains the prevailing def of a symbol.4 5; First generate bitcode with a module summary index for each file6; RUN: opt -module-summary %s -o %t.o7; RUN: opt -module-summary %p/Inputs/thinlto_weak_library1.ll -o %t2.o8; RUN: opt -module-summary %p/Inputs/thinlto_weak_library2.ll -o %t3.o9 10; Although the objects are ordered "%t2.o %t3.o" in the library, the11; linker selects %t3.o first since it satisfies a strong reference from12; %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 link14; %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-lib22 23; Make sure we completely dropped the definition of the non-prevailing24; copy of f() (and didn't simply convert to available_externally, which25; would incorrectly enable inlining).26; RUN: llvm-dis %t2.o.1.promote.bc -o - | FileCheck %s27; 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 uwtable35define i32 @main() local_unnamed_addr {36entry:37  tail call void (...) @test2()38  ret i32 039}40 41declare void @test2(...) local_unnamed_addr42