1; Basic ThinLTO tests.
2; RUN: opt -module-summary %s -o %t1.o
3; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
4
5; First force single-threaded mode
6; RUN: rm -f %t31.lto.o %t32.lto.o
7; RUN: wasm-ld -r -save-temps --thinlto-jobs=1 %t1.o %t2.o -o %t3
8; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
9; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
10
11; Next force multi-threaded mode
12; RUN: rm -f %t31.lto.o %t32.lto.o
13; RUN: wasm-ld -r -save-temps --thinlto-jobs=2 %t1.o %t2.o -o %t3
14; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
15; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
16
17;; --thinlto-jobs= defaults to --threads=.
18; RUN: rm -f %t31.lto.o %t32.lto.o
19; RUN: wasm-ld -r -save-temps --threads=2 %t1.o %t2.o -o %t3
20; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
21; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
22
23;; --thinlto-jobs= overrides --threads=.
24; RUN: rm -f %t31.lto.o %t32.lto.o
25; RUN: wasm-ld -r -save-temps --threads=1 --thinlto-jobs=2 %t1.o %t2.o -o %t3
26; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
27; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
28
29; Test with all threads, on all cores, on all CPU sockets
30; RUN: rm -f %t31.lto.o %t32.lto.o
31; RUN: wasm-ld -r -save-temps --thinlto-jobs=all %t1.o %t2.o -o %t3
32; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
33; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
34
35; Test with many more threads than the system has
36; RUN: rm -f %t31.lto.o %t32.lto.o
37; RUN: wasm-ld -r -save-temps --thinlto-jobs=100 %t1.o %t2.o -o %t3
38; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
39; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
40
41; Test with a bad value
42; RUN: rm -f %t31.lto.o %t32.lto.o
43; RUN: not wasm-ld -r -save-temps --thinlto-jobs=foo %t1.o %t2.o -o %t3 2>&1 | FileCheck %s --check-prefix=BAD-JOBS
44; BAD-JOBS: error: --thinlto-jobs: invalid job count: foo
45
46; Check without --thinlto-jobs (which currently defaults to heavyweight_hardware_concurrency, meanning one thread per hardware core -- not SMT)
47; RUN: rm -f %t31.lto.o %t32.lto.o
48; RUN: wasm-ld -r -save-temps %t1.o %t2.o -o %t3
49; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
50; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
51
52; NM1: T f
53; NM2: T g
54
55target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
56target triple = "wasm32-unknown-unknown"
57
58declare void @g(...)
59
60define void @f() {
61entry:
62  call void (...) @g()
63  ret void
64}
65