1c729c1b4SSam Clegg; Basic ThinLTO tests.
2c729c1b4SSam Clegg; RUN: opt -module-summary %s -o %t1.o
3c729c1b4SSam Clegg; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
4c729c1b4SSam Clegg
5c729c1b4SSam Clegg; First force single-threaded mode
6c729c1b4SSam Clegg; RUN: rm -f %t31.lto.o %t32.lto.o
7c729c1b4SSam Clegg; RUN: wasm-ld -r -save-temps --thinlto-jobs=1 %t1.o %t2.o -o %t3
8c729c1b4SSam Clegg; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
9c729c1b4SSam Clegg; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
10c729c1b4SSam Clegg
11c729c1b4SSam Clegg; Next force multi-threaded mode
12c729c1b4SSam Clegg; RUN: rm -f %t31.lto.o %t32.lto.o
13c729c1b4SSam Clegg; RUN: wasm-ld -r -save-temps --thinlto-jobs=2 %t1.o %t2.o -o %t3
14c729c1b4SSam Clegg; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
15c729c1b4SSam Clegg; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
16c729c1b4SSam Clegg
17eb4663d8SFangrui Song;; --thinlto-jobs= defaults to --threads=.
18eb4663d8SFangrui Song; RUN: rm -f %t31.lto.o %t32.lto.o
19eb4663d8SFangrui Song; RUN: wasm-ld -r -save-temps --threads=2 %t1.o %t2.o -o %t3
20eb4663d8SFangrui Song; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
21eb4663d8SFangrui Song; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
22eb4663d8SFangrui Song
23eb4663d8SFangrui Song;; --thinlto-jobs= overrides --threads=.
24eb4663d8SFangrui Song; RUN: rm -f %t31.lto.o %t32.lto.o
25eb4663d8SFangrui Song; RUN: wasm-ld -r -save-temps --threads=1 --thinlto-jobs=2 %t1.o %t2.o -o %t3
26eb4663d8SFangrui Song; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
27eb4663d8SFangrui Song; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
28eb4663d8SFangrui Song
2909158252SAlexandre Ganea; Test with all threads, on all cores, on all CPU sockets
3009158252SAlexandre Ganea; RUN: rm -f %t31.lto.o %t32.lto.o
3109158252SAlexandre Ganea; RUN: wasm-ld -r -save-temps --thinlto-jobs=all %t1.o %t2.o -o %t3
3209158252SAlexandre Ganea; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
3309158252SAlexandre Ganea; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
3409158252SAlexandre Ganea
3509158252SAlexandre Ganea; Test with many more threads than the system has
3609158252SAlexandre Ganea; RUN: rm -f %t31.lto.o %t32.lto.o
37717a4608SHans Wennborg; RUN: wasm-ld -r -save-temps --thinlto-jobs=100 %t1.o %t2.o -o %t3
3809158252SAlexandre Ganea; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
3909158252SAlexandre Ganea; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
4009158252SAlexandre Ganea
4109158252SAlexandre Ganea; Test with a bad value
4209158252SAlexandre Ganea; RUN: rm -f %t31.lto.o %t32.lto.o
4309158252SAlexandre Ganea; RUN: not wasm-ld -r -save-temps --thinlto-jobs=foo %t1.o %t2.o -o %t3 2>&1 | FileCheck %s --check-prefix=BAD-JOBS
4409158252SAlexandre Ganea; BAD-JOBS: error: --thinlto-jobs: invalid job count: foo
4509158252SAlexandre Ganea
4609158252SAlexandre Ganea; Check without --thinlto-jobs (which currently defaults to heavyweight_hardware_concurrency, meanning one thread per hardware core -- not SMT)
4709158252SAlexandre Ganea; RUN: rm -f %t31.lto.o %t32.lto.o
4809158252SAlexandre Ganea; RUN: wasm-ld -r -save-temps %t1.o %t2.o -o %t3
49c729c1b4SSam Clegg; RUN: llvm-nm %t31.lto.o | FileCheck %s --check-prefix=NM1
50c729c1b4SSam Clegg; RUN: llvm-nm %t32.lto.o | FileCheck %s --check-prefix=NM2
51c729c1b4SSam Clegg
52c729c1b4SSam Clegg; NM1: T f
53c729c1b4SSam Clegg; NM2: T g
54c729c1b4SSam Clegg
55*6d0c7bc1SPaulo Matostarget datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128"
56c729c1b4SSam Cleggtarget triple = "wasm32-unknown-unknown"
57c729c1b4SSam Clegg
58c729c1b4SSam Cleggdeclare void @g(...)
59c729c1b4SSam Clegg
60c729c1b4SSam Cleggdefine void @f() {
61c729c1b4SSam Cleggentry:
62c729c1b4SSam Clegg  call void (...) @g()
63c729c1b4SSam Clegg  ret void
64c729c1b4SSam Clegg}
65