mirror-llvm-project/llvm/test/ThinLTO/X86/dtlto/json.ll
Ben Dunbobbin 49d568a8d6
[DTLTO] Forward loop interchange to DTLTO remote compilations (#208591)
Recent upstream LLVM changes enabled `LoopInterchangePass` by default
through `PipelineTuningOptions`. TLTO observes that state directly from
the LTO config, but DTLTO was not forwarding the equivalent Clang option
to the remote compiler. As a result, TLTO could run loop interchange
pass while DTLTO did not, producing codegen differences for
configurations that exposed profitable/legally interchangeable loops.
Note that this was a pre-existing issue, the change in default has
simply exposed it.

Forward `C.PTO.LoopInterchange` as `-floop-interchange` when
constructing the common DTLTO remote compiler options. Extend the
testing to check that the SN-DBS remote command line includes the
forwarded option.

The code for forwarding such options is only intended as a temporary
measure. A more comprehensive solution is in discussion here:
https://discourse.llvm.org/t/synchronizing-lto-code-generation-configuration-between-clang-and-lld-dtlto
2026-07-21 19:27:15 +01:00

97 lines
2.8 KiB
LLVM

; Check that the JSON output from DTLTO is as expected. Note that validate.py
; checks the JSON structure so we just check the field contents in this test.
RUN: rm -rf %t && split-file %s %t && cd %t
; Generate bitcode files with summary.
RUN: opt -thinlto-bc t1.ll -o t1.bc
RUN: opt -thinlto-bc t2.ll -o t2.bc
; Perform DTLTO with clang.
RUN: not llvm-lto2 run t1.bc t2.bc -o my.output \
RUN: -r=t1.bc,t1,px -r=t2.bc,t2,px \
RUN: -dtlto-distributor=%python \
RUN: -dtlto-distributor-arg=%llvm_src_root/utils/dtlto/validate.py,--da1=10,--da2=10 \
RUN: -dtlto-compiler=my_clang.exe \
RUN: -dtlto-compiler-arg=--rota1=10,--rota2=20 \
RUN: 2>&1 | FileCheck --check-prefixes=CHECK,CLANG %s
; Perform DTLTO with LLVM driver.
RUN: not llvm-lto2 run t1.bc t2.bc -o my.output \
RUN: -r=t1.bc,t1,px -r=t2.bc,t2,px \
RUN: -dtlto-distributor=%python \
RUN: -dtlto-distributor-arg=%llvm_src_root/utils/dtlto/validate.py,--da1=10,--da2=10 \
RUN: -dtlto-compiler=llvm \
RUN: -dtlto-compiler-prepend-arg=clang \
RUN: -dtlto-compiler-arg=--rota1=10,--rota2=20 \
RUN: 2>&1 | FileCheck --check-prefixes=CHECK,LLVM %s
CHECK: distributor_args=['--da1=10', '--da2=10']
; Check the common object.
CHECK: "linker_output": "my.output"
CHECK: "args":
CLANG-NEXT: "my_clang.exe"
LLVM-NEXT: "llvm"
LLVM-NEXT: "clang"
CHECK-NEXT: "-c"
CHECK-NEXT: "--target=x86_64-unknown-linux-gnu"
CHECK-NEXT: "-O2"
CHECK-NEXT: "-floop-interchange"
CHECK-NEXT: "-fpic"
CHECK-NEXT: "-Wno-unused-command-line-argument"
CHECK-NEXT: "--rota1=10"
CHECK-NEXT: "--rota2=20"
CHECK-NEXT: ]
CHECK: "inputs": []
; Check the first job entry.
CHECK: "args":
CHECK-NEXT: "t1.bc"
CHECK-NEXT: "-fthinlto-index=t1.1.[[#]].native.o.thinlto.bc"
CHECK-NEXT: "-o"
CHECK-NEXT: "t1.1.[[#]].native.o"
CHECK-NEXT: ]
CHECK: "inputs": [
CHECK-NEXT: "t1.bc"
CHECK-NEXT: "t1.1.[[#]].native.o.thinlto.bc"
CHECK-NEXT: ]
CHECK: "outputs": [
CHECK-NEXT: "t1.1.[[#]].native.o"
CHECK-NEXT: ]
; Check the second job entry.
CHECK: "args": [
CHECK-NEXT: "t2.bc"
CHECK-NEXT: "-fthinlto-index=t2.2.[[#]].native.o.thinlto.bc"
CHECK-NEXT: "-o"
CHECK-NEXT: "t2.2.[[#]].native.o"
CHECK-NEXT: ]
CHECK-NEXT: "inputs": [
CHECK-NEXT: "t2.bc"
CHECK-NEXT: "t2.2.[[#]].native.o.thinlto.bc"
CHECK-NEXT: ]
CHECK-NEXT: "outputs": [
CHECK-NEXT: "t2.2.[[#]].native.o"
CHECK-NEXT: ]
; This check ensures that we have failed for the expected reason.
CHECK: failed: DTLTO backend compilation: cannot open native object file:
;--- t1.ll
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define void @t1() {
entry:
ret void
}
;--- t2.ll
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define void @t2() {
entry:
ret void
}