Skip to content

Commit 4512dda

Browse files
committed
[ELF][test] Clean up thinlto*
1 parent 9320a32 commit 4512dda

File tree

3 files changed

+89
-96
lines changed

3 files changed

+89
-96
lines changed

lld/test/ELF/lto/thinlto-index-file.ll

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
; REQUIRES: x86
2+
; RUN: rm -rf %t && mkdir %t && cd %t
3+
; RUN: opt -module-summary %s -o 1.o
4+
; RUN: opt -module-summary %p/Inputs/thinlto.ll -o 2.o
5+
; RUN: opt -module-summary %p/Inputs/thinlto_empty.ll -o 3.o
26

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-
; RUN: opt -module-summary %p/Inputs/thinlto_empty.ll -o %t3.o
7+
;; Ensure lld writes linked files to linked objects file
8+
; RUN: ld.lld --plugin-opt=thinlto-index-only=1.txt -shared 1.o 2.o 3.o -o /dev/null
9+
; RUN: FileCheck %s < 1.txt
10+
; CHECK: 1.o
11+
; CHECK: 2.o
12+
; CHECK: 3.o
713

8-
; Ensure lld writes linked files to linked objects file
9-
; RUN: ld.lld --plugin-opt=thinlto-index-only=%t.idx -shared %t1.o %t2.o %t3.o -o /dev/null
10-
; RUN: FileCheck %s < %t.idx
11-
; CHECK: {{.*}}thinlto-index-file.ll.tmp1.o
12-
; CHECK: {{.*}}thinlto-index-file.ll.tmp2.o
13-
; CHECK: {{.*}}thinlto-index-file.ll.tmp3.o
14-
15-
; Check that this also works without the --plugin-opt= prefix.
16-
; RUN: ld.lld --thinlto-index-only=%t.idx -shared %t1.o %t2.o %t3.o -o /dev/null
17-
; RUN: FileCheck %s < %t.idx
14+
;; Check that this also works without the --plugin-opt= prefix.
15+
; RUN: ld.lld --thinlto-index-only=2.txt -shared 1.o 2.o 3.o -o /dev/null
16+
; RUN: diff 1.txt 2.txt
1817

1918
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
2019
target triple = "x86_64-unknown-linux-gnu"

lld/test/ELF/lto/thinlto-index-only.ll

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,54 @@
11
; REQUIRES: x86
2+
; RUN: rm -rf %t && mkdir %t && cd %t
23

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
4+
;; First ensure that the ThinLTO handling in lld handles
5+
;; bitcode without summary sections gracefully and generates index file.
6+
; RUN: llvm-as %s -o 1.o
7+
; RUN: llvm-as %p/Inputs/thinlto.ll -o 2.o
8+
; RUN: ld.lld --plugin-opt=thinlto-index-only -shared 1.o 2.o -o 3
9+
; RUN: ls 2.o.thinlto.bc
10+
; RUN: not test -e 3
11+
; RUN: ld.lld -shared 1.o 2.o -o 3
12+
; RUN: llvm-nm 3 | FileCheck %s --check-prefix=NM
1313

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
14+
;; Basic ThinLTO tests.
15+
; RUN: opt -module-summary %s -o 1.o
16+
; RUN: opt -module-summary %p/Inputs/thinlto.ll -o 2.o
17+
; RUN: opt -module-summary %p/Inputs/thinlto_empty.ll -o 3.o
1818

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
19+
;; Ensure lld generates an index and not a binary if requested.
20+
; RUN: ld.lld --plugin-opt=thinlto-index-only -shared 1.o 2.o -o 4
21+
; RUN: llvm-bcanalyzer -dump 1.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND1
22+
; RUN: llvm-bcanalyzer -dump 2.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND2
23+
; RUN: not test -e 4
2524

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: llvm-dis < %t2.o.thinlto.bc | grep -q '\^0 = module:'
30-
; RUN: not test -e %t4
25+
;; Ensure lld generates an index even if the file is wrapped in --start-lib/--end-lib
26+
; RUN: rm -f 2.o.thinlto.bc 4
27+
; RUN: ld.lld --plugin-opt=thinlto-index-only -shared 1.o 3.o --start-lib 2.o --end-lib -o 4
28+
; RUN: llvm-dis < 2.o.thinlto.bc | grep -q '\^0 = module:'
29+
; RUN: not test -e 4
3130

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
31+
;; Test that LLD generates an empty index even for lazy object file that is not added to link.
32+
;; Test LLD generates empty imports file either because of thinlto-emit-imports-files option.
33+
; RUN: rm -f 1.o.thinlto.bc 1.o.imports
34+
; RUN: ld.lld --plugin-opt=thinlto-index-only -shared 2.o --start-lib 1.o --end-lib \
35+
; RUN: --plugin-opt=thinlto-emit-imports-files -o 3
36+
; RUN: ls 1.o.thinlto.bc
37+
; RUN: ls 1.o.imports
4038

41-
; Ensure LLD generates an empty index for each bitcode file even if all bitcode files are lazy.
42-
; RUN: rm -f %t1.o.thinlto.bc
43-
; RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux-gnu /dev/null -o %tdummy.o
44-
; RUN: ld.lld --plugin-opt=thinlto-index-only -shared %tdummy.o --start-lib %t1.o --end-lib -o /dev/null
45-
; RUN: ls %t1.o.thinlto.bc
39+
;; Ensure LLD generates an empty index for each bitcode file even if all bitcode files are lazy.
40+
; RUN: rm -f 1.o.thinlto.bc
41+
; RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux-gnu /dev/null -o dummy.o
42+
; RUN: ld.lld --plugin-opt=thinlto-index-only -shared dummy.o --start-lib 1.o --end-lib -o /dev/null
43+
; RUN: ls 1.o.thinlto.bc
4644

4745
; NM: T f
4846

49-
; The backend index for this module contains summaries from itself and
50-
; Inputs/thinlto.ll, as it imports from the latter.
47+
;; The backend index for this module contains summaries from itself and
48+
;; Inputs/thinlto.ll, as it imports from the latter.
5149
; BACKEND1: <MODULE_STRTAB_BLOCK
52-
; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}thinlto-index-only.ll.tmp{{.*}}.o'
53-
; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}thinlto-index-only.ll.tmp{{.*}}.o'
50+
; BACKEND1-NEXT: <ENTRY {{.*}} record string = '1.o'
51+
; BACKEND1-NEXT: <ENTRY {{.*}} record string = '2.o'
5452
; BACKEND1-NEXT: </MODULE_STRTAB_BLOCK
5553
; BACKEND1: <GLOBALVAL_SUMMARY_BLOCK
5654
; BACKEND1: <VERSION
@@ -61,10 +59,10 @@
6159
; BACKEND1: <COMBINED
6260
; BACKEND1: </GLOBALVAL_SUMMARY_BLOCK
6361

64-
; The backend index for Input/thinlto.ll contains summaries from itself only,
65-
; as it does not import anything.
62+
;; The backend index for Input/thinlto.ll contains summaries from itself only,
63+
;; as it does not import anything.
6664
; BACKEND2: <MODULE_STRTAB_BLOCK
67-
; BACKEND2-NEXT: <ENTRY {{.*}} record string = '{{.*}}thinlto-index-only.ll.tmp2.o'
65+
; BACKEND2-NEXT: <ENTRY {{.*}} record string = '2.o'
6866
; BACKEND2-NEXT: </MODULE_STRTAB_BLOCK
6967
; BACKEND2-NEXT: <GLOBALVAL_SUMMARY_BLOCK
7068
; BACKEND2-NEXT: <VERSION

lld/test/ELF/lto/thinlto-object-suffix-replace.ll

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,41 @@
11
; REQUIRES: x86
2+
;; Test to make sure the thinlto-object-suffix-replace option is handled
3+
;; correctly.
4+
; RUN: rm -rf %t && mkdir %t && cd %t
25

3-
; Test to make sure the thinlto-object-suffix-replace option is handled
4-
; correctly.
5-
6-
; Generate bitcode file with summary, as well as a minimized bitcode without
6+
;; Generate bitcode file with summary, as well as a minimized bitcode without
77
; the debug metadata for the thin link.
8-
; RUN: opt --thinlto-bc %s -thin-link-bitcode-file=%t1.thinlink.bc -o %t1.o
9-
10-
; First perform the thin link on the normal bitcode file, and save the
11-
; resulting index.
12-
; RUN: ld.lld --plugin-opt=thinlto-index-only -shared %t1.o -o %t3
13-
; RUN: cp %t1.o.thinlto.bc %t1.o.thinlto.bc.orig
14-
15-
; Next perform the thin link on the minimized bitcode file, and compare dump
16-
; of the resulting index to the above dump to ensure they are identical.
17-
; RUN: rm -f %t1.o.thinlto.bc
18-
; Make sure it isn't inadvertently using the regular bitcode file.
19-
; RUN: rm -f %t1.o
20-
; RUN: ld.lld --plugin-opt=thinlto-index-only \
21-
; RUN: --plugin-opt=thinlto-object-suffix-replace=".thinlink.bc;.o" \
22-
; RUN: -shared %t1.thinlink.bc -o %t3
23-
; RUN: diff %t1.o.thinlto.bc.orig %t1.o.thinlto.bc
24-
; Also check that this works without the --plugin-opt= prefix.
25-
; RUN: ld.lld --thinlto-index-only \
26-
; RUN: --thinlto-object-suffix-replace=".thinlink.bc;.o" \
27-
; RUN: -shared %t1.thinlink.bc -o %t3
28-
; RUN: diff %t1.o.thinlto.bc.orig %t1.o.thinlto.bc
29-
30-
; Ensure lld generates error if object suffix replace option does not have 'old;new' format
31-
; RUN: rm -f %t1.o.thinlto.bc
32-
; RUN: not ld.lld --plugin-opt=thinlto-index-only \
33-
; RUN: --plugin-opt=thinlto-object-suffix-replace="abc:def" -shared %t1.thinlink.bc \
34-
; RUN: -o %t3 2>&1 | FileCheck %s --check-prefix=ERR1
8+
; RUN: opt --thinlto-bc %s -thin-link-bitcode-file=1.thinlink.bc -o 1.o
9+
10+
;; First perform the thin link on the normal bitcode file, and save the
11+
;; resulting index.
12+
; RUN: ld.lld --plugin-opt=thinlto-index-only -shared 1.o -o 3
13+
; RUN: cp 1.o.thinlto.bc 1.o.thinlto.bc.orig
14+
15+
;; Next perform the thin link on the minimized bitcode file, and compare dump
16+
;; of the resulting index to the above dump to ensure they are identical.
17+
; RUN: rm -f 1.o.thinlto.bc
18+
;; Make sure it isn't inadvertently using the regular bitcode file.
19+
; RUN: rm -f 1.o
20+
; RUN: ld.lld --plugin-opt=thinlto-index-only --plugin-opt=thinlto-object-suffix-replace=".thinlink.bc;.o" \
21+
; RUN: -shared 1.thinlink.bc -o 3
22+
; RUN: cmp 1.o.thinlto.bc.orig 1.o.thinlto.bc
23+
;; Also check that this works without the --plugin-opt= prefix.
24+
; RUN: ld.lld --thinlto-index-only --thinlto-object-suffix-replace=".thinlink.bc;.o" \
25+
; RUN: -shared 1.thinlink.bc -o 3
26+
; RUN: cmp 1.o.thinlto.bc.orig 1.o.thinlto.bc
27+
28+
;; Ensure lld generates error if object suffix replace option does not have 'old;new' format
29+
; RUN: rm -f 1.o.thinlto.bc
30+
; RUN: not ld.lld --plugin-opt=thinlto-index-only --plugin-opt=thinlto-object-suffix-replace="abc:def" -shared 1.thinlink.bc \
31+
; RUN: -o 3 2>&1 | FileCheck %s --check-prefix=ERR1
3532
; ERR1: --plugin-opt=thinlto-object-suffix-replace= expects 'old;new' format, but got abc:def
3633

37-
; If filename does not end with old suffix, no suffix change should occur,
38-
; so ".thinlto.bc" will simply be appended to the input file name.
39-
; RUN: rm -f %t1.thinlink.bc.thinlto.bc
40-
; RUN: ld.lld --plugin-opt=thinlto-index-only \
41-
; RUN: --plugin-opt=thinlto-object-suffix-replace=".abc;.o" -shared %t1.thinlink.bc -o /dev/null
42-
; RUN: ls %t1.thinlink.bc.thinlto.bc
34+
;; If filename does not end with old suffix, no suffix change should occur,
35+
;; so ".thinlto.bc" will simply be appended to the input file name.
36+
; RUN: rm -f 1.thinlink.bc.thinlto.bc
37+
; RUN: ld.lld --plugin-opt=thinlto-index-only --plugin-opt=thinlto-object-suffix-replace=".abc;.o" -shared 1.thinlink.bc -o /dev/null
38+
; RUN: ls 1.thinlink.bc.thinlto.bc
4339

4440
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
4541
target triple = "x86_64-unknown-linux-gnu"

0 commit comments

Comments
 (0)