1; REQUIRES: x86
2
3; Basic ThinLTO tests.
4; RUN: opt -module-summary %s -o %t1.o
5; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
6
7; First force single-threaded mode
8; RUN: rm -f %t31.lto.o %t32.lto.o
9; RUN: ld.lld -save-temps --thinlto-jobs=1 -shared %t1.o %t2.o -o %t3
10; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
11; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
12
13; Next force multi-threaded mode
14; RUN: rm -f %t31.lto.o %t32.lto.o
15; RUN: ld.lld -save-temps --thinlto-jobs=2 -shared %t1.o %t2.o -o %t3
16; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
17; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
18
19;; --plugin-opt=jobs= is an alias.
20; RUN: rm -f %t31.lto.o %t32.lto.o
21; RUN: ld.lld -save-temps --plugin-opt=jobs=2 -shared %t1.o %t2.o -o %t3
22; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
23; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
24
25; Test with all threads, on all cores, on all CPU sockets
26; RUN: rm -f %t31.lto.o %t32.lto.o
27; RUN: ld.lld -save-temps --thinlto-jobs=all -shared %t1.o %t2.o -o %t3
28; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
29; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
30
31; Test with many more threads than the system has
32; RUN: rm -f %t31.lto.o %t32.lto.o
33; RUN: ld.lld -save-temps --thinlto-jobs=1000 -shared %t1.o %t2.o -o %t3
34; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
35; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
36
37; Test with a bad value
38; RUN: rm -f %t31.lto.o %t32.lto.o
39; RUN: not ld.lld -save-temps --thinlto-jobs=foo -shared %t1.o %t2.o -o %t3 2>&1 | FileCheck %s --check-prefix=BAD-JOBS
40; BAD-JOBS: error: --thinlto-jobs: invalid job count: foo
41
42; Then check without --thinlto-jobs (which currently defaults to heavyweight_hardware_concurrency, meanning one thread per hardware core -- not SMT)
43; RUN: ld.lld -shared -save-temps %t1.o %t2.o -o %t3
44; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
45; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
46
47; Check that -save-temps is usable with thin archives
48; RUN: rm -fr %t.dir
49; RUN: mkdir -p %t.dir
50; RUN: cp %t2.o %t.dir/t.o
51; RUN: llvm-ar rcsT %t.dir/t.a %t.dir/t.o
52; RUN: ld.lld -save-temps %t1.o %t.dir/t.a -o %t.null
53; RUN: ls '%t.dir/t.a(t.o at 0).0.preopt.bc'
54
55; NM1: T f
56; NM2: T g
57
58target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
59target triple = "x86_64-unknown-linux-gnu"
60
61declare void @g(...)
62
63define void @f() {
64entry:
65  call void (...) @g()
66  ret void
67}
68