Skip to content

Commit 4a063b8

Browse files
committed
Replace llc with clang -cc1 for invoking the SPIRV backend.
1 parent 3906dbc commit 4a063b8

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

clang/lib/Driver/ToolChains/HIPAMD.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,20 +179,19 @@ void AMDGCN::Linker::constructLinkAndEmitSpirvCommand(
179179
options::OPT_amdgpu_use_experimental_spirv_backend,
180180
options::OPT_no_amdgpu_use_experimental_spirv_backend, /*Default=*/false);
181181

182+
// Emit SPIR-V binary either using the SPIRV backend or the translator.
182183
if (UseSPIRVBackend) {
183184
llvm::opt::ArgStringList CmdArgs;
184-
CmdArgs.push_back(LinkedBCFile.getFilename());
185-
CmdArgs.append({"-o", Output.getFilename()});
186-
const char *Exec =
187-
C.getArgs().MakeArgString(getToolChain().GetProgramPath("llc"));
188185
const char *Triple =
189-
C.getArgs().MakeArgString("-mtriple=" + getSpirvBackendTriple());
190-
CmdArgs.push_back(Triple);
186+
C.getArgs().MakeArgString("-triple=" + getSpirvBackendTriple());
187+
CmdArgs.append({"-cc1", Triple, "-emit-obj", LinkedBCFile.getFilename(),
188+
"-o", Output.getFilename()});
189+
const char *Exec = getToolChain().getDriver().getClangProgramPath();
191190
C.addCommand(std::make_unique<Command>(JA, *this,
192191
ResponseFileSupport::None(), Exec,
193192
CmdArgs, LinkedBCFile, Output));
194193
} else {
195-
// Emit SPIR-V binary.
194+
// Use the SPIRV translator for code gen.
196195
llvm::opt::ArgStringList TrArgs{
197196
"--spirv-max-version=1.6",
198197
"--spirv-ext=+all",

clang/test/Driver/amdgpu-spirv-backend-opt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// COM: This test case validates the behavior of -amdgpu-use-experimental-spirv-backend
22

3-
// COM: Test that -amdgpu-use-experimental-spirv-backend calls llc with the SPIRV triple.
3+
// COM: Test that -amdgpu-use-experimental-spirv-backend calls clang -cc1 with the SPIRV triple.
44
// RUN: %clang -x hip %s --cuda-device-only --offload-arch=amdgcnspirv -amdgpu-use-experimental-spirv-backend -nogpuinc -nogpulib -### 2>&1 | FileCheck %s --check-prefix=CHECK-SPIRV-BACKEND
5-
// CHECK-SPIRV-BACKEND: "{{.*}}llc{{.*}}" "{{-mtriple=spirv64v[0-9]+\.[0-9]+-amd-amdhsa}}"
5+
// CHECK-SPIRV-BACKEND: "{{.*}}clang{{.*}}" "-cc1" "{{.*-triple=spirv64v[0-9]+\.[0-9]+-amd-amdhsa}}"
66

77
// COM: Test that -no-amdgpu-use-experimental-spirv-backend calls the SPIRV translator
88
// RUN: %clang -x hip %s --cuda-device-only --offload-arch=amdgcnspirv -no-amdgpu-use-experimental-spirv-backend -nogpuinc -nogpulib -### 2>&1 | FileCheck %s --check-prefix=CHECK-SPIRV-TRANSLATOR

0 commit comments

Comments
 (0)