84 lines · plain
1; REQUIRES: x862; RUN: rm -rf %t; split-file %s %t3 4; RUN: llc -filetype=obj %t/q.ll -o %t/q.o5; RUN: llvm-ar cru %t/libq.a %t/q.o6 7; RUN: llc -filetype=obj %t/f.ll -o %t/f.nolto.o8; RUN: opt --thinlto-bc %t/f.ll -o %t/f.thinlto.o9; RUN: opt %t/f.ll -o %t/f.lto.o10 11; RUN: llc -filetype=obj %t/b.ll -o %t/b.nolto.o12; RUN: opt --thinlto-bc %t/b.ll -o %t/b.thinlto.o13; RUN: opt %t/b.ll -o %t/b.lto.o14 15; (1) NoLTO-NoLTO16; RUN: %lld -dylib -lSystem -L%t %t/f.nolto.o %t/b.nolto.o -o %t/nolto-nolto.out17; RUN: llvm-objdump --syms %t/nolto-nolto.out | FileCheck %s18 19; (2) NoLTO-ThinLTO20; RUN: %lld -dylib -lSystem -L%t %t/f.nolto.o %t/b.thinlto.o -o %t/nolto-thinlto.out21; RUN: llvm-objdump --syms %t/nolto-thinlto.out | FileCheck %s22 23; (3) ThinLTO-NoLTO24; RUN: %lld -dylib -lSystem -L%t %t/f.thinlto.o %t/b.nolto.o -o %t/thinlto-nolto.out25; RUN: llvm-objdump --syms %t/thinlto-nolto.out | FileCheck %s26 27; (4) NoLTO-LTO28; RUN: %lld -dylib -lSystem -L%t %t/f.nolto.o %t/b.lto.o -o %t/nolto-lto.out29; RUN: llvm-objdump --syms %t/nolto-lto.out | FileCheck %s30 31; (5) LTO-NoLTO32; RUN: %lld -dylib -lSystem -L%t %t/f.lto.o %t/b.nolto.o -o %t/lto-nolto.out33; RUN: llvm-objdump --syms %t/lto-nolto.out | FileCheck %s34 35; (6) LTO-ThinLTO36; RUN: %lld -dylib -lSystem -L%t %t/f.lto.o %t/b.thinlto.o -o %t/lto-thinlto.out37; RUN: llvm-objdump --syms %t/lto-thinlto.out | FileCheck %s38 39; (7) ThinLTO-NoLTO40; RUN: %lld -dylib -lSystem -L%t %t/f.thinlto.o %t/b.lto.o -o %t/thinlto-lto.out41; RUN: llvm-objdump --syms %t/thinlto-lto.out | FileCheck %s42 43; We expect to resolve _weak1 from f.ll and _weak2 from b.ll as per the input order.44; As _weak2 from q.ll pulled in via LC_LINKER_OPTION is processed45; in the second pass, it won't prevail due to _weak2 from b.ll.46 47; CHECK: w O __TEXT,f _weak148; CHECK: w O __TEXT,b _weak249 50;--- q.ll51target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"52target triple = "x86_64-apple-macosx10.15.0"53 54define i32 @weak2() section "__TEXT,q" {55 ret i32 256}57 58;--- f.ll59target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"60target triple = "x86_64-apple-macosx10.15.0"61 62!0 = !{!"-lq"}63!llvm.linker.options = !{!0}64 65define weak i32 @weak1() section "__TEXT,f" {66 %call = call i32 @weak2()67 %add = add nsw i32 %call, 168 ret i32 %add69}70 71declare i32 @weak2(...)72 73;--- b.ll74target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"75target triple = "x86_64-apple-macosx10.15.0"76 77define weak i32 @weak1() section "__TEXT,b" {78 ret i32 379}80 81define weak i32 @weak2() section "__TEXT,b" {82 ret i32 483}84