[DTLTO][NFC] Minor cleanups and improvements to DTLTO tests (#177282)

This change makes small, non-functional improvements to the DTLTO test
suite, including:
- Tightening+Regularizing FileCheck match expressions across tests
- Simplifying `signal.test` using more lit macro features
This commit is contained in:
Ben Dunbobbin 2026-01-22 00:48:31 +00:00 committed by GitHub
parent 138910d5d5
commit 00fecbcf00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 61 additions and 56 deletions

View file

@ -23,32 +23,32 @@ RUN: -Wl,--save-temps
RUN: ls | FileCheck %s --check-prefix=OUTPUTS
# JSON jobs description.
OUTPUTS-DAG: {{^}}main.[[PID:[0-9]+]].dist-file.json
OUTPUTS-DAG: {{^}}main.[[#PID:]].dist-file.json
# Main source.
OUTPUTS-DAG: {{^}}main.{{[0-9]+}}.[[PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}main.{{[0-9]+}}.[[PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: {{^}}main.1.[[#PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}main.1.[[#PID]].native.o.thinlto.bc{{$}}
# Regular archive members.
# Filename composition: <archive>(<member> at <offset>).<task>.<pid>.<task>.<pid>.native.o[.thinlto.bc].
OUTPUTS-DAG: {{^}}archive.a(boo.o at {{[0-9]+}}).2.[[HEXPID:[a-fA-F0-9]+]].2.[[PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}archive.a(boo.o at {{[0-9]+}}).2.[[HEXPID]].2.[[PID]].native.o.thinlto.bc{{$}}
# Filename composition: <archive>(<member> at <offset>).<task>.<pid>.<task>.<pid>.native.o.
OUTPUTS-DAG: {{^}}archive.a(boo.o at [[#BOO_OFFSET:]]).2.[[#%X,HEXPID:]].2.[[#PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}archive.a(boo.o at [[#BOO_OFFSET]]).2.[[#%X,HEXPID]].2.[[#PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: {{^}}archive.a(foo.o at {{[0-9]+}}).3.[[HEXPID]].3.[[PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}archive.a(foo.o at {{[0-9]+}}).3.[[HEXPID]].3.[[PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: {{^}}archive.a(foo.o at [[#FOO_OFFSET:]]).3.[[#%X,HEXPID]].3.[[#PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}archive.a(foo.o at [[#FOO_OFFSET]]).3.[[#%X,HEXPID]].3.[[#PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: {{^}}archive.a(moo.o at {{[0-9]+}}).4.[[HEXPID]].4.[[PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}archive.a(moo.o at {{[0-9]+}}).4.[[HEXPID]].4.[[PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: {{^}}archive.a(moo.o at [[#MOO_OFFSET:]]).4.[[#%X,HEXPID]].4.[[#PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}archive.a(moo.o at [[#MOO_OFFSET]]).4.[[#%X,HEXPID]].4.[[#PID]].native.o.thinlto.bc{{$}}
# Thin archive members.
OUTPUTS-DAG: {{^}}voo.{{[0-9]+}}.[[PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}voo.{{[0-9]+}}.[[PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: {{^}}voo.5.[[#PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}voo.5.[[#PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: {{^}}loo.{{[0-9]+}}.[[PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}loo.{{[0-9]+}}.[[PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: {{^}}loo.6.[[#PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}loo.6.[[#PID]].native.o.thinlto.bc{{$}}
# Executable file.
OUTPUTS-DAG: {{^}}main.elf{{$}}
OUTPUTS-DAG: {{^}}main.elf{{$}}
#--- foo.c
volatile int foo_int;
@ -77,4 +77,3 @@ extern int voo(int x);
__attribute__((retain)) int main(int argc, char** argv) {
return boo(argc) + moo() + voo(argc + 3);
}

View file

@ -21,9 +21,11 @@ RUN: -Wl,--save-temps,--lto-partitions=2
# Show that the FullLTO modules have been prepared for distribution, this is
# not optimal but has no functional impact.
RUN: FileCheck %s --input-file=a.out.resolution.txt
CHECK: archive.a(one.o at {{.*}}).1.[[PID:[a-zA-Z0-9_]+]].o
CHECK: archive.a(two.o at {{.*}}).2.[[PID]].o
CHECK: archive.a(three.o at {{.*}}).3.[[PID]].o
# Filename composition: <archive>(<member> at <offset>).<task>.<pid>.o.
CHECK: archive.a(one.o at [[#ONE_OFFSET:]]).1.[[#%X,HEXPID:]].o
CHECK: archive.a(two.o at [[#TWO_OFFSET:]]).2.[[#%X,HEXPID]].o
CHECK: archive.a(three.o at [[#THREE_OFFSET:]]).3.[[#%X,HEXPID]].o
#--- one.c
__attribute__((retain)) void one() {}

View file

@ -32,18 +32,18 @@ RUN: -Wl,--thinlto-remote-compiler=%clang
RUN: ls | FileCheck %s --check-prefix=OUTPUTS
# JSON jobs description.
OUTPUTS-DAG: {{^}}main.[[PID:[0-9]+]].dist-file.json
OUTPUTS-DAG: {{^}}main.[[#PID:]].dist-file.json
# Sources.
OUTPUTS-DAG: {{^}}start.{{[0-9]+}}.[[PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}start.{{[0-9]+}}.[[PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: {{^}}start.1.[[#PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}start.1.[[#PID]].native.o.thinlto.bc{{$}}
# Archive members.
# Filename composition: <archive>(<member> at <offset>).<task>.<pid>.<task>.<pid>.native.o[.thinlto.bc].
OUTPUTS-DAG: {{^}}archive.a(t3.o at {{[0-9]+}}).2.[[HEXPID:[a-fA-F0-9]+]].2.[[PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}archive.a(t3.o at {{[0-9]+}}).2.[[HEXPID]].2.[[PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: {{^}}archive.a(t1.o at {{[0-9]+}}).3.[[HEXPID]].3.[[PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}archive.a(t1.o at {{[0-9]+}}).3.[[HEXPID]].3.[[PID]].native.o.thinlto.bc{{$}}
# Filename composition: <archive>(<member> at <offset>).<task>.<pid>.<task>.<pid>.native.o.
OUTPUTS-DAG: {{^}}archive.a(t3.o at [[#T3_OFFSET:]]).2.[[#%X,HEXPID:]].2.[[#PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}archive.a(t3.o at [[#T3_OFFSET]]).2.[[#%X,HEXPID]].2.[[#PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: {{^}}archive.a(t1.o at [[#T1_OFFSET:]]).3.[[#%X,HEXPID]].3.[[#PID]].native.o{{$}}
OUTPUTS-DAG: {{^}}archive.a(t1.o at [[#T1_OFFSET]]).3.[[#%X,HEXPID]].3.[[#PID]].native.o.thinlto.bc{{$}}
#--- t1.c
__attribute__((retain)) void t1() { }

View file

@ -36,19 +36,19 @@ RUN: /lldsavetemps
RUN: ls | FileCheck %s --check-prefix=OUTPUTS --implicit-check-not=cat
## JSON jobs description.
OUTPUTS-DAG: my.[[PID:[a-zA-Z0-9_]+]].dist-file.json
OUTPUTS-DAG: my.[[#PID:]].dist-file.json
## Individual summary index files.
OUTPUTS-DAG: start.1.[[PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: dog.2.[[PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: foo.3.[[PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: bar.4.[[PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: start.1.[[#PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: dog.2.[[#PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: foo.3.[[#PID]].native.o.thinlto.bc{{$}}
OUTPUTS-DAG: bar.4.[[#PID]].native.o.thinlto.bc{{$}}
## Native output object files.
OUTPUTS-DAG: start.1.[[PID]].native.o{{$}}
OUTPUTS-DAG: dog.2.[[PID]].native.o{{$}}
OUTPUTS-DAG: foo.3.[[PID]].native.o{{$}}
OUTPUTS-DAG: bar.4.[[PID]].native.o{{$}}
OUTPUTS-DAG: start.1.[[#PID]].native.o{{$}}
OUTPUTS-DAG: dog.2.[[#PID]].native.o{{$}}
OUTPUTS-DAG: foo.3.[[#PID]].native.o{{$}}
OUTPUTS-DAG: bar.4.[[#PID]].native.o{{$}}
## It is important that cross-module inlining occurs for this test to show that Clang can

View file

@ -7,36 +7,40 @@ RUN: rm -rf %t && split-file %s %t && cd %t
RUN: %clang --target=x86_64-linux-gnu -O2 t1.c t2.c -flto=thin -c
DEFINE: %{kill-dtlto} = %python killer.py %clang --target=x86_64-linux-gnu \
DEFINE: -nostdlib -O2 -flto=thin -fuse-ld=lld t1.o t2.o \
DEFINE: -fthinlto-distributor=%python \
DEFINE: -Xthinlto-distributor=local_codegen_and_wait.py
DEFINE: %{tdir} = dummy-to-make-lit-work
DEFINE: %{kill-dtlto} = rm -f send-signal && mkdir %{tdir} && \
DEFINE: %python killer.py \
DEFINE: %clang --target=x86_64-linux-gnu -nostdlib -O2 -flto=thin \
DEFINE: -fuse-ld=lld -Wl,--whole-archive t1.o t2.o -o %{tdir}/t.elf -shared \
DEFINE: -fthinlto-distributor=%python \
DEFINE: -Xthinlto-distributor=local_codegen_and_wait.py
# Check that all temporary files are removed if the process is aborted.
RUN: mkdir none
RUN: %{kill-dtlto} -o none/t.elf
RUN: ls none | FileCheck %s --allow-empty --check-prefix=EMPTY
REDEFINE: %{tdir} = empty
RUN: %{kill-dtlto}
RUN: ls %{tdir} | FileCheck %s --allow-empty --check-prefix=EMPTY
EMPTY-NOT: {{.}}
# Check that --save-temps preserves all the files.
RUN: rm send-signal && mkdir all
RUN: %{kill-dtlto} -Wl,--save-temps -o all/t.elf
RUN: ls all | sort | FileCheck %s --check-prefixes=BOOKEND,TEMPS,INDEX
# Check that --save-temps preserves temporary files if the process is aborted.
REDEFINE: %{tdir} = savetemps
RUN: %{kill-dtlto} -Wl,--save-temps
RUN: ls %{tdir} | sort | FileCheck %s --check-prefixes=BOOKEND,TEMPS,INDEX
# Check that --thinlto-emit-index-files preserves the index files.
RUN: rm send-signal && mkdir index
RUN: %{kill-dtlto} -Wl,--thinlto-emit-index-files -o index/t.elf
RUN: ls index | sort | FileCheck %s --check-prefixes=BOOKEND,INDEX
# Check that --thinlto-emit-index-files preserves the index files if the process
# is aborted.
REDEFINE: %{tdir} = index
RUN: %{kill-dtlto} -Wl,--thinlto-emit-index-files
RUN: ls %{tdir} | sort | FileCheck %s --check-prefixes=BOOKEND,INDEX
# No files are expected before.
BOOKEND-NOT: {{.}}
TEMPS: {{^}}t.[[#]].dist-file.json{{$}}
TEMPS: {{^}}t.[[#PID:]].dist-file.json{{$}}
TEMPS: {{^}}t.elf.{{.+$}}
TEMPS: {{^}}t1.1.[[#]].native.o{{$}}
INDEX: {{^}}t1.1.[[#]].native.o.thinlto.bc{{$}}
TEMPS: {{^}}t2.2.[[#]].native.o{{$}}
INDEX: {{^}}t2.2.[[#]].native.o.thinlto.bc{{$}}
TEMPS: {{^}}t1.1.[[#PID]].native.o{{$}}
INDEX: {{^}}t1.1.[[#PID:]].native.o.thinlto.bc{{$}}
TEMPS: {{^}}t2.2.[[#PID]].native.o{{$}}
INDEX: {{^}}t2.2.[[#PID]].native.o.thinlto.bc{{$}}
# No files are expected after.
BOOKEND-NOT: {{.}}