-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[NFC][Driver][HIP] Fix mixing amdgcnspirv
and gfxXXX
via --offload-arch
#133024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NFC][Driver][HIP] Fix mixing amdgcnspirv
and gfxXXX
via --offload-arch
#133024
Conversation
… otherwise the toolchain gets confused.
@llvm/pr-subscribers-clang Author: Alex Voicu (AlexVlx) ChangesDue to Full diff: https://github.com/llvm/llvm-project/pull/133024.diff 1 Files Affected:
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 056bfcf1b739a..07e36ea2efba4 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3750,9 +3750,12 @@ class OffloadingActionBuilder final {
// compiler phases, including backend and assemble phases.
ActionList AL;
Action *BackendAction = nullptr;
- if (ToolChains.front()->getTriple().isSPIRV()) {
+ if (ToolChains.front()->getTriple().isSPIRV() ||
+ (ToolChains.front()->getTriple().isAMDGCN() &&
+ GpuArchList[I] == StringRef("amdgcnspirv"))) {
// Emit LLVM bitcode for SPIR-V targets. SPIR-V device tool chain
- // (HIPSPVToolChain) runs post-link LLVM IR passes.
+ // (HIPSPVToolChain or HIPAMDToolChain) runs post-link LLVM IR
+ // passes.
types::ID Output = Args.hasArg(options::OPT_S)
? types::TY_LLVM_IR
: types::TY_LLVM_BC;
|
@llvm/pr-subscribers-clang-driver Author: Alex Voicu (AlexVlx) ChangesDue to Full diff: https://github.com/llvm/llvm-project/pull/133024.diff 1 Files Affected:
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 056bfcf1b739a..07e36ea2efba4 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3750,9 +3750,12 @@ class OffloadingActionBuilder final {
// compiler phases, including backend and assemble phases.
ActionList AL;
Action *BackendAction = nullptr;
- if (ToolChains.front()->getTriple().isSPIRV()) {
+ if (ToolChains.front()->getTriple().isSPIRV() ||
+ (ToolChains.front()->getTriple().isAMDGCN() &&
+ GpuArchList[I] == StringRef("amdgcnspirv"))) {
// Emit LLVM bitcode for SPIR-V targets. SPIR-V device tool chain
- // (HIPSPVToolChain) runs post-link LLVM IR passes.
+ // (HIPSPVToolChain or HIPAMDToolChain) runs post-link LLVM IR
+ // passes.
types::ID Output = Args.hasArg(options::OPT_S)
? types::TY_LLVM_IR
: types::TY_LLVM_BC;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems in line with the weird workarounds we already use.
Due to
amdgcnspirv
piggybacking on the HIPAMDToolchain, it loses its immediately apparent SPIR-Vness, which makes the Driver want to go all the way to Assembly emmission. This was problematic as we were trying tollvm-link
SPIR-V, before trying to translate it. This patch ensures that we do the right thing and stop at bitcode emission if we are mixingamdgcnspirv
and concrete targets.