Skip to content

Commit a298e49

Browse files
Added llvm-lto2 test
1 parent 81597e5 commit a298e49

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
; Test DTLTO output with llvm-lto2.
2+
3+
RUN: rm -rf %t && split-file %s %t && cd %t
4+
5+
; Generate bitcode files with summary.
6+
RUN: opt -thinlto-bc t1.ll -o t1.bc
7+
RUN: opt -thinlto-bc t2.ll -o t2.bc
8+
9+
; Generate fake object files for mock.py to return.
10+
RUN: touch t1.o t2.o
11+
12+
; Create an empty subdirectory to avoid having to account for the input files.
13+
RUN: mkdir %t/out && cd %t/out
14+
15+
; Define a substitution to share the common DTLTO arguments with caching enabled.
16+
DEFINE: %{command} = llvm-lto2 run ../t1.bc ../t2.bc -o t.o -cache-dir cache-dir \
17+
DEFINE: -dtlto-distributor=%python \
18+
DEFINE: -dtlto-distributor-arg=%llvm_src_root/utils/dtlto/mock.py,../t1.o,../t2.o \
19+
DEFINE: -r=../t1.bc,t1,px \
20+
DEFINE: -r=../t2.bc,t2,px
21+
22+
; Perform out of process ThinLTO (DTLTO).
23+
; Note: mock.py does not do any compilation, instead it simply writes
24+
; the contents of the object files supplied on the command line into the
25+
; output object files in job order.
26+
RUN: %{command}
27+
28+
; Check that the expected output files have been created.
29+
RUN: ls | count 3
30+
; Check that two native object files has been created
31+
RUN: ls | FileCheck %s --check-prefix=THINLTO
32+
; Check that DTLTO cache directory has been created
33+
RUN: ls cache-dir/* | count 2
34+
; Check that 2 cache entries are created
35+
RUN: ls cache-dir/llvmcache-* | count 2
36+
37+
; llvm-lto2 ThinLTO output files.
38+
THINLTO-DAG: {{^}}t.o.1{{$}}
39+
THINLTO-DAG: {{^}}t.o.2{{$}}
40+
41+
# Execute llvm-lto2 again and check that a fully populated cache is used correctly,
42+
# i.e., no additional cache entries are created for cache hits.
43+
44+
RUN: %{command}
45+
46+
; Check that the expected output files have been created.
47+
RUN: ls | count 3
48+
; Check that two native object files has been created
49+
RUN: ls | FileCheck %s --check-prefix=THINLTO
50+
; Check that DTLTO cache directory has been created
51+
RUN: ls cache-dir/* | count 2
52+
; Check that 2 cache entries are created
53+
RUN: ls cache-dir/llvmcache-* | count 2
54+
55+
56+
57+
58+
;--- t1.ll
59+
60+
target triple = "x86_64-unknown-linux-gnu"
61+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
62+
63+
define void @t1() {
64+
ret void
65+
}
66+
67+
;--- t2.ll
68+
69+
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
70+
target triple = "x86_64-unknown-linux-gnu"
71+
72+
define void @t2() {
73+
ret void
74+
}

0 commit comments

Comments
 (0)