mirror-llvm-project/clang/test/Driver/hipspv-no-spirv-backend.hip
Paulius Velesko 7ef0ca2b13
Reland "[HIPSPV] Add in-tree SPIR-V backend support for chipStar" (#213052)
Relands #206910 (reverted in #213088) with the fix for the breakage.

IsIntegratedBackendDefault() was tied to whether the SPIR-V backend is
registered, but it also controls whether clang collapses the compile and
backend
jobs, so builds without the SPIR-V target split every HIPSPV RDC device
compile
and failed hipspv-toolchain-rdc.hip. The default is back to the base
class value
and the translator fallback is decided in
constructLinkAndEmitSpirvCommand.
Third commit adds a test not guarded by spirv-registered-target.

Validated in X86;SPIRV and X86 only builds: driver tests pass in both,
and
non-RDC plus RDC (new driver) flows run for real emit spirv-val clean
modules
via the backend and via llvm-spirv respectively.
2026-07-31 15:23:48 -04:00

41 lines
1.7 KiB
Text

// Coverage for HIPSPV behavior that must not depend on whether the in-tree
// SPIR-V backend was built. Deliberately not guarded by the
// spirv-registered-target feature, so builders configured without the SPIR-V
// target (e.g. X86-only bots) exercise it too.
// UNSUPPORTED: system-windows
// The device compilation job layout is a property of the driver, not of the
// registered targets: an RDC device compile stays a single -cc1 invocation
// that emits the object directly, rather than being split into a separate
// -emit-llvm-bc job plus a backend job.
// RUN: %clang -### -x hip --target=x86_64-linux-gnu --offload=spirv64 \
// RUN: --no-offload-new-driver -fgpu-rdc --hip-path=%S/Inputs/hipspv \
// RUN: -nohipwrapperinc %S/Inputs/hip_multiple_inputs/a.cu \
// RUN: 2>&1 | FileCheck --check-prefix=RDC-JOB %s
// RDC-JOB: "-cc1" "-triple" "spirv64"
// RDC-JOB-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
// RDC-JOB-SAME: "-emit-obj"
// RDC-JOB-SAME: "-fcuda-is-device"
// -fno-integrated-objemitter selects the external llvm-spirv translator, and
// it is accepted in either configuration.
// RUN: touch %t.o
// RUN: %clang -### --no-default-config -o %t.img \
// RUN: --target=spirv64-unknown-chipstar %t.o --hip-path=%S/Inputs/hipspv \
// RUN: -fno-integrated-objemitter \
// RUN: 2>&1 | FileCheck --check-prefix=XTOR -DHIP_PATH=%S/Inputs/hipspv %s
// XTOR: {{".*llvm-link"}}
// XTOR-SAME: "-o" [[LINK_BC:".*bc"]] "{{[^ ]*.o}}"
// XTOR: {{".*opt"}} [[LINK_BC]] "-load-pass-plugin"
// XTOR-SAME: "[[HIP_PATH]]/lib/libLLVMHipSpvPasses.so"
// XTOR-SAME: "-passes=hip-post-link-passes" "-o" [[LOWER_BC:".*bc"]]
// XTOR: {{".*llvm-spirv.*"}} "--spirv-max-version=1.2"
// XTOR-SAME: [[LOWER_BC]] "-o" "{{.*img}}"
// XTOR-NOT: "-cc1"