Skip to content

Commit ad259dc

Browse files
committed
Re-using output as the bitcode linking target does not work on Windows, so use a temporary.
1 parent 83dbc0d commit ad259dc

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

clang/lib/Driver/ToolChains/HIPAMD.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,14 @@ void AMDGCN::Linker::constructLinkAndEmitSpirvCommand(
168168
const InputInfo &Output, const llvm::opt::ArgList &Args) const {
169169
assert(!Inputs.empty() && "Must have at least one input.");
170170

171-
constructLlvmLinkCommand(C, JA, Inputs, Output, Args);
172-
173-
// Linked BC is now in Output
171+
InputInfo LinkedBC = Inputs.front();
172+
if (Inputs.size() > 1) {
173+
std::string TempPath = C.getDriver().GetTemporaryPath("pre-spirv-translate",
174+
"bc");
175+
LinkedBC = InputInfo(&JA, C.getArgs().MakeArgString(TempPath),
176+
Output.getBaseInput());
177+
constructLlvmLinkCommand(C, JA, Inputs, LinkedBC, Args);
178+
}
174179

175180
// Emit SPIR-V binary.
176181
llvm::opt::ArgStringList TrArgs{
@@ -180,7 +185,7 @@ void AMDGCN::Linker::constructLinkAndEmitSpirvCommand(
180185
"--spirv-lower-const-expr",
181186
"--spirv-preserve-auxdata",
182187
"--spirv-debug-info-version=nonsemantic-shader-200"};
183-
SPIRV::constructTranslateCommand(C, *this, JA, Output, Output, TrArgs);
188+
SPIRV::constructTranslateCommand(C, *this, JA, Output, LinkedBC, TrArgs);
184189
}
185190

186191
// For amdgcn the inputs of the linker job are device bitcode and output is

clang/test/Driver/hip-toolchain-no-rdc.hip

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@
207207
//
208208

209209
// AMDGCNSPIRV: "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}}"-emit-llvm-bc" {{.*}}"-fembed-bitcode=marker" "-disable-llvm-passes" {{.*}} "-o" "[[AMDGCNSPV_BC:.*bc]]"
210-
// AMDGCNSPIRV: {{".*llvm-link.*"}} "-o" "[[AMDGCNSPV_TMP:.*out]]" "[[AMDGCNSPV_BC]]"
211-
// AMDGCNSPIRV: {{".*llvm-spirv.*"}} "--spirv-max-version=1.6" "--spirv-ext=+all" {{.*}} "[[AMDGCNSPV_TMP]]" {{.*}}"-o" "[[AMDGCNSPV_CO:.*out]]"
210+
// AMDGCNSPIRV: {{".*llvm-spirv.*"}} "--spirv-max-version=1.6" "--spirv-ext=+all" {{.*}} "[[AMDGCNSPV_BC]]" {{.*}}"-o" "[[AMDGCNSPV_CO:.*out]]"
212211
// AMDGCNSPIRV: "-cc1" "-triple" "amdgcn-amd-amdhsa" {{.*}}"-emit-obj" {{.*}}"-target-cpu" "gfx900"{{.*}} "-o" "[[GFX900_OBJ:.*o]]"
213212
// AMDGCNSPIRV: {{".*lld.*"}} {{.*}}"-plugin-opt=mcpu=gfx900" {{.*}} "-o" "[[GFX900_CO:.*out]]" {{.*}}"[[GFX900_OBJ]]"
214213
// AMDGCNSPIRV: {{".*clang-offload-bundler.*"}} "-type=o"

clang/test/Driver/spirv-amd-toolchain.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@
1515
// RUN: %clang -### --target=spirv64-amd-amdhsa %s -nogpulib -nogpuinc 2>&1 \
1616
// RUN: | FileCheck %s --check-prefix=INVOCATION
1717
// INVOCATION: "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}}"-disable-llvm-optzns" {{.*}} "-o" "[[OUTPUT:.+]]" "-x" "c"
18-
// INVOCATION: "{{.*}}llvm-link" "-o" "a.out" "[[OUTPUT]]"
19-
// INVOCATION: "{{.*}}llvm-spirv" "--spirv-max-version=1.6" "--spirv-ext=+all" "--spirv-allow-unknown-intrinsics" "--spirv-lower-const-expr" "--spirv-preserve-auxdata" "--spirv-debug-info-version=nonsemantic-shader-200" "a.out" "-o" "a.out"
18+
// INVOCATION: "{{.*}}llvm-spirv" "--spirv-max-version=1.6" "--spirv-ext=+all" "--spirv-allow-unknown-intrinsics" "--spirv-lower-const-expr" "--spirv-preserve-auxdata" "--spirv-debug-info-version=nonsemantic-shader-200" "[[OUTPUT]]" "-o" "a.out"

0 commit comments

Comments
 (0)