1; REQUIRES: x86
2
3; Generate summary sections and test lld handling.
4; RUN: opt -module-summary %s -o %t1.obj
5; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.obj
6
7; Include a file with an empty module summary index, to ensure that the expected
8; output files are created regardless, for a distributed build system.
9; RUN: opt -module-summary %p/Inputs/thinlto-empty.ll -o %t3.obj
10
11; Ensure lld generates imports files if requested for distributed backends.
12; RUN: rm -f %t3.obj.imports %t3.obj.thinlto.bc
13; RUN: lld-link -entry:main -thinlto-index-only \
14; RUN:     -thinlto-emit-imports-files %t1.obj %t2.obj %t3.obj -out:%t4.exe
15
16; The imports file for this module contains the bitcode file for
17; Inputs/thinlto.ll
18; RUN: cat %t1.obj.imports | count 1
19; RUN: cat %t1.obj.imports | FileCheck %s --check-prefix=IMPORTS1
20; IMPORTS1: thinlto-emit-imports.ll.tmp2.obj
21
22; The imports file for Input/thinlto.ll is empty as it does not import anything.
23; RUN: cat %t2.obj.imports | count 0
24
25; The imports file for Input/thinlto_empty.ll is empty but should exist.
26; RUN: cat %t3.obj.imports | count 0
27
28; The index file should be created even for the input with an empty summary.
29; RUN: ls %t3.obj.thinlto.bc
30
31; Ensure lld generates error if unable to write to imports file.
32; RUN: rm -f %t3.obj.imports
33; RUN: touch %t3.obj.imports
34; RUN: chmod 400 %t3.obj.imports
35; RUN: not lld-link -entry:main -thinlto-index-only \
36; RUN:     -thinlto-emit-imports-files %t1.obj %t2.obj %t3.obj \
37; RUN:     -out:%t4.exe 2>&1 | FileCheck %s --check-prefix=ERR
38; ERR: cannot open {{.*}}3.obj.imports: {{P|p}}ermission denied
39
40; Ensure lld doesn't generate import files when thinlto-index-only is not enabled
41; RUN: rm -f %t1.obj.imports
42; RUN: rm -f %t2.obj.imports
43; RUN: rm -f %t3.obj.imports
44; RUN: lld-link -entry:main -thinlto-emit-imports-files \
45; RUN:     %t1.obj %t2.obj %t3.obj -out:%t4.exe
46; RUN: not ls %t1.obj.imports
47; RUN: not ls %t2.obj.imports
48; RUN: not ls %t3.obj.imports
49
50target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
51target triple = "x86_64-pc-windows-msvc19.0.24215"
52
53declare void @g(...)
54
55define void @main() {
56entry:
57  call void (...) @g()
58  ret void
59}
60