]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ELF/lto/thinlto-index-only.ll
Vendor import of lld trunk r338150:
[FreeBSD/FreeBSD.git] / test / ELF / lto / thinlto-index-only.ll
1 ; REQUIRES: x86
2
3 ; First ensure that the ThinLTO handling in lld handles
4 ; bitcode without summary sections gracefully and generates index file.
5 ; RUN: llvm-as %s -o %t1.o
6 ; RUN: llvm-as %p/Inputs/thinlto.ll -o %t2.o
7 ; RUN: rm -f %t3
8 ; RUN: ld.lld --plugin-opt=thinlto-index-only -shared %t1.o %t2.o -o %t3
9 ; RUN: ls %t2.o.thinlto.bc
10 ; RUN: not test -e %t3
11 ; RUN: ld.lld -shared %t1.o %t2.o -o %t3
12 ; RUN: llvm-nm %t3 | FileCheck %s --check-prefix=NM
13
14 ; Basic ThinLTO tests.
15 ; RUN: opt -module-summary %s -o %t1.o
16 ; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
17 ; RUN: opt -module-summary %p/Inputs/thinlto_empty.ll -o %t3.o
18
19 ; Ensure lld generates an index and not a binary if requested.
20 ; RUN: rm -f %t4
21 ; RUN: ld.lld --plugin-opt=thinlto-index-only -shared %t1.o %t2.o -o %t4
22 ; RUN: llvm-bcanalyzer -dump %t1.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND1
23 ; RUN: llvm-bcanalyzer -dump %t2.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND2
24 ; RUN: not test -e %t4
25
26 ; Ensure lld generates an index even if the file is wrapped in --start-lib/--end-lib
27 ; RUN: rm -f %t2.o.thinlto.bc %t4
28 ; RUN: ld.lld --plugin-opt=thinlto-index-only -shared %t1.o %t3.o --start-lib %t2.o --end-lib -o %t4
29 ; RUN: ls %t2.o.thinlto.bc
30 ; RUN: not test -e %t4
31
32 ; Test that LLD generates an empty index even for lazy object file that is not added to link.
33 ; Test LLD generates empty imports file either because of thinlto-emit-imports-files option.
34 ; RUN: rm -f %t1.o.thinlto.bc
35 ; RUN: rm -f %t1.o.imports
36 ; RUN: ld.lld --plugin-opt=thinlto-index-only -shared %t2.o --start-lib %t1.o --end-lib \
37 ; RUN: --plugin-opt=thinlto-emit-imports-files -o %t3
38 ; RUN: ls %t1.o.thinlto.bc
39 ; RUN: ls %t1.o.imports
40
41 ; Ensure lld generates an error if unable to write an empty index file
42 ; for lazy object file that is not added to link.
43 ; RUN: rm -f %t1.o.thinlto.bc
44 ; RUN: touch %t1.o.thinlto.bc
45 ; RUN: chmod 400 %t1.o.thinlto.bc
46 ; RUN: not ld.lld --plugin-opt=thinlto-index-only -shared %t2.o --start-lib %t1.o --end-lib \
47 ; RUN:   -o %t3 2>&1 | FileCheck %s
48 ; CHECK: cannot open {{.*}}1.o.thinlto.bc: {{P|p}}ermission denied
49 ; RUN: rm -f %t1.o.thinlto.bc
50
51 ; NM: T f
52
53 ; The backend index for this module contains summaries from itself and
54 ; Inputs/thinlto.ll, as it imports from the latter.
55 ; BACKEND1: <MODULE_STRTAB_BLOCK
56 ; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}thinlto-index-only.ll.tmp{{.*}}.o'
57 ; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}thinlto-index-only.ll.tmp{{.*}}.o'
58 ; BACKEND1-NEXT: </MODULE_STRTAB_BLOCK
59 ; BACKEND1: <GLOBALVAL_SUMMARY_BLOCK
60 ; BACKEND1: <VERSION
61 ; BACKEND1: <FLAGS
62 ; BACKEND1: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
63 ; BACKEND1: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
64 ; BACKEND1: <COMBINED
65 ; BACKEND1: <COMBINED
66 ; BACKEND1: </GLOBALVAL_SUMMARY_BLOCK
67
68 ; The backend index for Input/thinlto.ll contains summaries from itself only,
69 ; as it does not import anything.
70 ; BACKEND2: <MODULE_STRTAB_BLOCK
71 ; BACKEND2-NEXT: <ENTRY {{.*}} record string = '{{.*}}thinlto-index-only.ll.tmp2.o'
72 ; BACKEND2-NEXT: </MODULE_STRTAB_BLOCK
73 ; BACKEND2-NEXT: <GLOBALVAL_SUMMARY_BLOCK
74 ; BACKEND2-NEXT: <VERSION
75 ; BACKEND2-NEXT: <FLAGS
76 ; BACKEND2-NEXT: <VALUE_GUID op0=1 op1=-5300342847281564238
77 ; BACKEND2-NEXT: <COMBINED
78 ; BACKEND2-NEXT: </GLOBALVAL_SUMMARY_BLOCK
79
80 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
81 target triple = "x86_64-unknown-linux-gnu"
82
83 declare void @g(...)
84
85 define void @f() {
86 entry:
87   call void (...) @g()
88   ret void
89 }