Skip to content

Commit 6b643f6

Browse files
mgcarrasco丹治秀樹
authored andcommitted
Reland "[clang][Driver] Support for the SPIR-V backend when compiling HIP" (llvm#169637)
This relands "[clang][Driver] Support for the SPIR-V backend when compiling HIP" llvm#167543. The only new change is a small fix for the multicall driver. For HIP, the SPIR-V backend can be optionally activated with the -use-spirv-backend flag. This option uses the SPIR-V BE instead of the SPIR-V translator. These changes also ensure that -use-spirv-backend does not require external dependencies, such as spirv-as and spirv-link
1 parent 06e4fb6 commit 6b643f6

File tree

7 files changed

+294
-17
lines changed

7 files changed

+294
-17
lines changed

clang/include/clang/Options/Options.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,16 @@ def fhip_emit_relocatable : Flag<["-"], "fhip-emit-relocatable">,
14271427
HelpText<"Compile HIP source to relocatable">;
14281428
def fno_hip_emit_relocatable : Flag<["-"], "fno-hip-emit-relocatable">,
14291429
HelpText<"Do not override toolchain to compile HIP source to relocatable">;
1430+
def use_spirv_backend
1431+
: Flag<["-"], "use-spirv-backend">,
1432+
Group<hip_Group>,
1433+
Flags<[HelpHidden]>,
1434+
HelpText<"Use the SPIRV backend for compilation ">;
1435+
def no_use_spirv_backend
1436+
: Flag<["-"], "no-use-spirv-backend">,
1437+
Group<hip_Group>,
1438+
Flags<[HelpHidden]>,
1439+
HelpText<"Do not use the SPIRV backend for compilation ">;
14301440
}
14311441

14321442
// Clang specific/exclusive options for OpenACC.

clang/lib/Driver/Driver.cpp

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4991,15 +4991,24 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
49914991
// Compiling HIP in device-only non-RDC mode requires linking each action
49924992
// individually.
49934993
for (Action *&A : DeviceActions) {
4994-
// Special handling for the HIP SPIR-V toolchain because it doesn't use
4995-
// the SPIR-V backend yet doesn't report the output as an object.
49964994
bool IsAMDGCNSPIRV = A->getOffloadingToolChain() &&
49974995
A->getOffloadingToolChain()->getTriple().getOS() ==
49984996
llvm::Triple::OSType::AMDHSA &&
49994997
A->getOffloadingToolChain()->getTriple().isSPIRV();
4998+
bool UseSPIRVBackend = Args.hasFlag(options::OPT_use_spirv_backend,
4999+
options::OPT_no_use_spirv_backend,
5000+
/*Default=*/false);
5001+
5002+
// Special handling for the HIP SPIR-V toolchain in device-only.
5003+
// The translator path has a linking step, whereas the SPIR-V backend path
5004+
// does not to avoid any external dependency such as spirv-link. The
5005+
// linking step is skipped for the SPIR-V backend path.
5006+
bool IsAMDGCNSPIRVWithBackend = IsAMDGCNSPIRV && UseSPIRVBackend;
5007+
50005008
if ((A->getType() != types::TY_Object && !IsAMDGCNSPIRV &&
50015009
A->getType() != types::TY_LTO_BC) ||
5002-
HIPRelocatableObj || !HIPNoRDC || !offloadDeviceOnly())
5010+
HIPRelocatableObj || !HIPNoRDC || !offloadDeviceOnly() ||
5011+
(IsAMDGCNSPIRVWithBackend && offloadDeviceOnly()))
50035012
continue;
50045013
ActionList LinkerInput = {A};
50055014
A = C.MakeAction<LinkJobAction>(LinkerInput, types::TY_Image);
@@ -5225,12 +5234,28 @@ Action *Driver::ConstructPhaseAction(
52255234
Args.hasArg(options::OPT_S) ? types::TY_LTO_IR : types::TY_LTO_BC;
52265235
return C.MakeAction<BackendJobAction>(Input, Output);
52275236
}
5237+
bool UseSPIRVBackend = Args.hasFlag(options::OPT_use_spirv_backend,
5238+
options::OPT_no_use_spirv_backend,
5239+
/*Default=*/false);
5240+
5241+
auto OffloadingToolChain = Input->getOffloadingToolChain();
5242+
// For AMD SPIRV, if offloadDeviceOnly(), we call the SPIRV backend unless
5243+
// LLVM bitcode was requested explicitly or RDC is set. If
5244+
// !offloadDeviceOnly, we emit LLVM bitcode, and clang-linker-wrapper will
5245+
// compile it to SPIRV.
5246+
bool UseSPIRVBackendForHipDeviceOnlyNoRDC =
5247+
TargetDeviceOffloadKind == Action::OFK_HIP && OffloadingToolChain &&
5248+
OffloadingToolChain->getTriple().isSPIRV() && UseSPIRVBackend &&
5249+
offloadDeviceOnly() &&
5250+
!Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, false);
5251+
52285252
if (Args.hasArg(options::OPT_emit_llvm) ||
52295253
TargetDeviceOffloadKind == Action::OFK_SYCL ||
52305254
(((Input->getOffloadingToolChain() &&
52315255
Input->getOffloadingToolChain()->getTriple().isAMDGPU() &&
52325256
TargetDeviceOffloadKind != Action::OFK_None) ||
52335257
TargetDeviceOffloadKind == Action::OFK_HIP) &&
5258+
!UseSPIRVBackendForHipDeviceOnlyNoRDC &&
52345259
((Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
52355260
false) ||
52365261
(Args.hasFlag(options::OPT_offload_new_driver,
@@ -5252,6 +5277,19 @@ Action *Driver::ConstructPhaseAction(
52525277
: types::TY_LLVM_BC;
52535278
return C.MakeAction<BackendJobAction>(Input, Output);
52545279
}
5280+
5281+
// The SPIRV backend compilation path for HIP must avoid external
5282+
// dependencies. The default compilation path assembles and links its
5283+
// output, but the SPIRV assembler and linker are external tools. This code
5284+
// ensures the backend emits binary SPIRV directly to bypass those steps and
5285+
// avoid failures. Without -save-temps, the compiler may already skip
5286+
// assembling and linking. With -save-temps, these steps must be explicitly
5287+
// disabled, as done here. We also force skipping these steps regardless of
5288+
// -save-temps to avoid relying on optimizations (unless -S is set).
5289+
// The current HIP bundling expects the type to be types::TY_Image
5290+
if (UseSPIRVBackendForHipDeviceOnlyNoRDC && !Args.hasArg(options::OPT_S))
5291+
return C.MakeAction<BackendJobAction>(Input, types::TY_Image);
5292+
52555293
return C.MakeAction<BackendJobAction>(Input, types::TY_PP_Asm);
52565294
}
52575295
case phases::Assemble:

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5062,6 +5062,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
50625062
Args.ClaimAllArgs(options::OPT_femit_dwarf_unwind_EQ);
50635063
}
50645064

5065+
bool IsAMDSPIRVForHIPDevice =
5066+
IsHIPDevice && getToolChain().getTriple().isSPIRV() &&
5067+
getToolChain().getTriple().getVendor() == llvm::Triple::AMD;
5068+
50655069
if (isa<AnalyzeJobAction>(JA)) {
50665070
assert(JA.getType() == types::TY_Plist && "Invalid output type.");
50675071
CmdArgs.push_back("-analyze");
@@ -5159,6 +5163,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
51595163
rewriteKind = RK_Fragile;
51605164
} else if (JA.getType() == types::TY_CIR) {
51615165
CmdArgs.push_back("-emit-cir");
5166+
} else if (JA.getType() == types::TY_Image && IsAMDSPIRVForHIPDevice) {
5167+
CmdArgs.push_back("-emit-obj");
51625168
} else {
51635169
assert(JA.getType() == types::TY_PP_Asm && "Unexpected output type!");
51645170
}
@@ -9089,7 +9095,9 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
90899095
OPT_fno_lto,
90909096
OPT_flto,
90919097
OPT_flto_partitions_EQ,
9092-
OPT_flto_EQ};
9098+
OPT_flto_EQ,
9099+
OPT_use_spirv_backend};
9100+
90939101
const llvm::DenseSet<unsigned> LinkerOptions{OPT_mllvm, OPT_Zlinker_input};
90949102
auto ShouldForwardForToolChain = [&](Arg *A, const ToolChain &TC) {
90959103
// Don't forward -mllvm to toolchains that don't support LLVM.

clang/lib/Driver/ToolChains/HIPAMD.cpp

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,9 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA,
159159

160160
// For SPIR-V the inputs for the job are device AMDGCN SPIR-V flavoured bitcode
161161
// and the output is either a compiled SPIR-V binary or bitcode (-emit-llvm). It
162-
// calls llvm-link and then the llvm-spirv translator. Once the SPIR-V BE will
163-
// be promoted from experimental, we will switch to using that. TODO: consider
164-
// if we want to run any targeted optimisations over IR here, over generic
165-
// SPIR-V.
162+
// calls llvm-link and then the llvm-spirv translator or the SPIR-V BE.
163+
// TODO: consider if we want to run any targeted optimisations over IR here,
164+
// over generic SPIR-V.
166165
void AMDGCN::Linker::constructLinkAndEmitSpirvCommand(
167166
Compilation &C, const JobAction &JA, const InputInfoList &Inputs,
168167
const InputInfo &Output, const llvm::opt::ArgList &Args) const {
@@ -173,17 +172,41 @@ void AMDGCN::Linker::constructLinkAndEmitSpirvCommand(
173172
const char *LinkedBCFilePath = HIP::getTempFile(C, LinkedBCFilePrefix, "bc");
174173
InputInfo LinkedBCFile(&JA, LinkedBCFilePath, Output.getBaseInput());
175174

175+
bool UseSPIRVBackend =
176+
Args.hasFlag(options::OPT_use_spirv_backend,
177+
options::OPT_no_use_spirv_backend, /*Default=*/false);
178+
176179
constructLlvmLinkCommand(C, JA, Inputs, LinkedBCFile, Args);
177180

178-
// Emit SPIR-V binary.
179-
llvm::opt::ArgStringList TrArgs{
180-
"--spirv-max-version=1.6",
181-
"--spirv-ext=+all",
182-
"--spirv-allow-unknown-intrinsics",
183-
"--spirv-lower-const-expr",
184-
"--spirv-preserve-auxdata",
185-
"--spirv-debug-info-version=nonsemantic-shader-200"};
186-
SPIRV::constructTranslateCommand(C, *this, JA, Output, LinkedBCFile, TrArgs);
181+
if (UseSPIRVBackend) {
182+
// This code handles the case in the new driver when --offload-device-only
183+
// is unset and clang-linker-wrapper forwards the bitcode that must be
184+
// compiled to SPIR-V.
185+
186+
llvm::opt::ArgStringList CmdArgs;
187+
const char *Triple =
188+
C.getArgs().MakeArgString("-triple=spirv64-amd-amdhsa");
189+
190+
CmdArgs.append({"-cc1", Triple, "-emit-obj", "-disable-llvm-optzns",
191+
LinkedBCFile.getFilename(), "-o", Output.getFilename()});
192+
193+
const Driver &Driver = getToolChain().getDriver();
194+
const char *Exec = Driver.getClangProgramPath();
195+
C.addCommand(std::make_unique<Command>(
196+
JA, *this, ResponseFileSupport::None(), Exec, CmdArgs, LinkedBCFile,
197+
Output, Driver.getPrependArg()));
198+
} else {
199+
// Emit SPIR-V binary using the translator
200+
llvm::opt::ArgStringList TrArgs{
201+
"--spirv-max-version=1.6",
202+
"--spirv-ext=+all",
203+
"--spirv-allow-unknown-intrinsics",
204+
"--spirv-lower-const-expr",
205+
"--spirv-preserve-auxdata",
206+
"--spirv-debug-info-version=nonsemantic-shader-200"};
207+
SPIRV::constructTranslateCommand(C, *this, JA, Output, LinkedBCFile,
208+
TrArgs);
209+
}
187210
}
188211

189212
// For amdgcn the inputs of the linker job are device bitcode and output is
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
2+
// RUN: -nogpuinc -nogpulib -x hip %s -save-temps \
3+
// RUN: -use-spirv-backend -ccc-print-bindings \
4+
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-BASE,CHECK-SPIRV
5+
6+
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
7+
// RUN: -nogpuinc -nogpulib -x hip %s -save-temps \
8+
// RUN: -use-spirv-backend -fgpu-rdc -ccc-print-bindings \
9+
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-BASE,CHECK-SPIRV-RDC
10+
11+
// CHECK-SPIRV-BASE: # "spirv64-amd-amdhsa" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[HIPI:.+\.hipi]]"
12+
// CHECK-SPIRV-BASE: # "spirv64-amd-amdhsa" - "clang", inputs: ["[[HIPI]]"], output: "[[SPV_BC:.+\.bc]]"
13+
// CHECK-SPIRV: # "spirv64-amd-amdhsa" - "Offload::Packager", inputs: ["[[SPV_BC]]"], output: "[[HIP_OUT:.+\.out]]"
14+
// CHECK-SPIRV: # "spirv64-amd-amdhsa" - "Offload::Linker", inputs: ["[[HIP_OUT]]"], output: "[[HIPFB:.+\.hipfb]]"
15+
// CHECK-SPIRV-RDC: # "x86_64-unknown-linux-gnu" - "Offload::Packager", inputs: ["[[SPV_BC]]"], output: "[[HIP_OUT:.+\.out]]"
16+
// CHECK-SPIRV-BASE: # "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT]]"], output: "[[HIPI:.+\.hipi]]"
17+
// CHECK-SPIRV: # "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[HIPI]]", "[[HIPFB]]"], output: "[[x86_BC:.+\.bc]]"
18+
// CHECK-SPIRV-RDC: # "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[HIPI]]", "[[HIP_OUT]]"], output: "[[x86_BC:.+\.bc]]"
19+
// CHECK-SPIRV-BASE: # "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[x86_BC]]"], output: "[[x86_S:.+\.s]]"
20+
// CHECK-SPIRV-BASE: # "x86_64-unknown-linux-gnu" - "clang::as", inputs: ["[[x86_S]]"], output: "[[x86_O:.+\.o]]"
21+
// CHECK-SPIRV-BASE: # "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[x86_O]]"], output: "{{.+\.out}}"
22+
23+
// CHECK-SPIRV # "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[x86_O]]"], output: "[[x86_O:.+\.o]]"
24+
// CHECK-SPIRV # "x86_64-unknown-linux-gnu" - "GNU::Linker", inputs: ["[[x86_O]]"], output: "{{.+\.out}}"
25+
26+
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
27+
// RUN: -nogpuinc -nogpulib -x hip %s -save-temps \
28+
// RUN: -use-spirv-backend --offload-device-only -ccc-print-bindings \
29+
// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-SPIRV-OFFLOAD-DEVICE-ONLY
30+
31+
// CHECK-SPIRV-OFFLOAD-DEVICE-ONLY: # "spirv64-amd-amdhsa" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[HIPI:.+\.hipi]]"
32+
// CHECK-SPIRV-OFFLOAD-DEVICE-ONLY: # "spirv64-amd-amdhsa" - "clang", inputs: ["[[HIPI]]"], output: "[[SPV_BC:.+\.bc]]"
33+
// CHECK-SPIRV-OFFLOAD-DEVICE-ONLY: # "spirv64-amd-amdhsa" - "clang", inputs: ["[[SPV_BC]]"], output: "[[SPV_OUT:.+\.out]]"
34+
// CHECK-SPIRV-OFFLOAD-DEVICE-ONLY: # "spirv64-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[SPV_OUT]]"], output: "{{.+\.hipfb}}"
35+
36+
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
37+
// RUN: -nogpuinc -nogpulib -x hip %s -save-temps \
38+
// RUN: -use-spirv-backend --offload-device-only -fgpu-rdc -ccc-print-bindings \
39+
// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-SPIRV-OFFLOAD-DEVICE-ONLY-RDC
40+
41+
// CHECK-SPIRV-OFFLOAD-DEVICE-ONLY-RDC: # "spirv64-amd-amdhsa" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[HIPI:.+\.hipi]]"
42+
// CHECK-SPIRV-OFFLOAD-DEVICE-ONLY-RDC: # "spirv64-amd-amdhsa" - "clang", inputs: ["[[HIPI]]"], output: "[[SPV_BC:.+\.bc]]"
43+
// CHECK-SPIRV-OFFLOAD-DEVICE-ONLY-RDC: # "spirv64-amd-amdhsa" - "clang", inputs: ["[[SPV_BC]]"], output: "{{.+}}"
44+
45+
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
46+
// RUN: -nogpuinc -nogpulib -x hip %s -save-temps \
47+
// RUN: -use-spirv-backend --offload-device-only -S -fgpu-rdc -ccc-print-bindings \
48+
// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-SPIRV-OFFLOAD-DEVICE-ONLY-RDC
49+
50+
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
51+
// RUN: -nogpuinc -nogpulib -x hip %s -save-temps \
52+
// RUN: -use-spirv-backend --offload-device-only -S -ccc-print-bindings \
53+
// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-SPIRV-TEXTUAL-OFFLOAD-DEVICE-ONLY
54+
55+
// CHECK-SPIRV-TEXTUAL-OFFLOAD-DEVICE-ONLY: # "spirv64-amd-amdhsa" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[HIPI:.+\.hipi]]"
56+
// CHECK-SPIRV-TEXTUAL-OFFLOAD-DEVICE-ONLY: # "spirv64-amd-amdhsa" - "clang", inputs: ["[[HIPI]]"], output: "[[SPV_BC:.+\.bc]]"
57+
// CHECK-SPIRV-TEXTUAL-OFFLOAD-DEVICE-ONLY: # "spirv64-amd-amdhsa" - "clang", inputs: ["[[SPV_BC]]"], output: "{{.+\.s}}"
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// This test case validates the behavior of -use-spirv-backend
2+
3+
// --offload-device-only is always set --- testing interactions with -S and -fgpu-rdc
4+
5+
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
6+
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
7+
// RUN: -use-spirv-backend --offload-device-only -S \
8+
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-TEXTUAL
9+
10+
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
11+
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
12+
// RUN: -use-spirv-backend --offload-device-only \
13+
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-BINARY
14+
15+
// The new driver's behavior is to emit LLVM IR for --offload-device-only and -fgpu-rdc (independently of SPIR-V).
16+
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
17+
// RUN: -### -nogpuinc -nogpulib -x hip %s -save-temps \
18+
// RUN: -use-spirv-backend --offload-device-only -S -fgpu-rdc \
19+
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-LL,CHECK-FGPU-RDC
20+
21+
// The new driver's behavior is to emit LLVM IR for --offload-device-only and -fgpu-rdc (independently of SPIR-V).
22+
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
23+
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
24+
// RUN: -use-spirv-backend --offload-device-only -fgpu-rdc \
25+
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-BC,CHECK-FGPU-RDC
26+
27+
// --offload-device-only is always unset --- testing interactions with -S and -fgpu-rdc
28+
29+
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
30+
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
31+
// RUN: -use-spirv-backend -S -fgpu-rdc \
32+
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-BC,CHECK-FGPU-RDC
33+
34+
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
35+
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
36+
// RUN: -use-spirv-backend -S \
37+
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-BC
38+
39+
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
40+
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
41+
// RUN: -use-spirv-backend -fgpu-rdc \
42+
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-BC,CHECK-CLANG-LINKER-WRAPPER
43+
44+
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
45+
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
46+
// RUN: -use-spirv-backend \
47+
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-BC,CHECK-CLANG-LINKER-WRAPPER
48+
49+
// RUN: %clang --no-offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
50+
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
51+
// RUN: -use-spirv-backend \
52+
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-BC,CHECK-SPIRV-BACKEND-BINARY-EQ-TRIPLE
53+
54+
// CHECK-SPIRV-TRANSLATOR-NOT: "{{.*llvm-spirv.*}}"
55+
// CHECK-SPIRV-BACKEND-TEXTUAL: "{{.*}}clang{{.*}}" "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}} "-S"
56+
// CHECK-SPIRV-BACKEND-BINARY: "{{.*}}clang{{.*}}" "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}} "-emit-obj"
57+
// CHECK-SPIRV-BACKEND-BC: "{{.*}}clang{{.*}}" "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}} "-emit-llvm-bc"
58+
// CHECK-SPIRV-BACKEND-LL: "{{.*}}clang{{.*}}" "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}} "-emit-llvm"
59+
// CHECK-SPIRV-BACKEND-BINARY-EQ-TRIPLE: "{{.*}}clang{{.*}}" "-cc1" {{.*}}"-triple=spirv64-amd-amdhsa" {{.*}}"-emit-obj"
60+
// CHECK-FGPU-RDC-SAME: {{.*}} "-fgpu-rdc"
61+
// CHECK-CLANG-LINKER-WRAPPER: "{{.*}}clang-linker-wrapper" "--should-extract=amdgcnspirv" {{.*}} "--device-compiler=spirv64-amd-amdhsa=-use-spirv-backend"

0 commit comments

Comments
 (0)