[Clang] Remove use of 'temporary' toolchains for offload deduction (#131332)
Summary: We need a toolchain to get the GPU architectures when compiling with OpenMP. This kind of breaks the toolchain model because these are cached all over the place. Instead of making a new one, just create both of them unconditionally. It's not like this is saving any work since we still needed to create both toolchains in the earlier case. Fixes: https://github.com/llvm/llvm-project/issues/131325
This commit is contained in:
parent
999700ca47
commit
befb52db94
2 changed files with 8 additions and 18 deletions
|
|
@ -1040,23 +1040,15 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
|
|||
// We need to temporarily create these toolchains so that we can access
|
||||
// tools for inferring architectures.
|
||||
llvm::DenseSet<StringRef> Archs;
|
||||
if (NVPTXTriple) {
|
||||
auto TempTC = std::make_unique<toolchains::CudaToolChain>(
|
||||
*this, *NVPTXTriple, *HostTC, C.getInputArgs());
|
||||
for (StringRef Arch : getOffloadArchs(
|
||||
C, C.getArgs(), Action::OFK_OpenMP, &*TempTC, true))
|
||||
Archs.insert(Arch);
|
||||
}
|
||||
if (AMDTriple) {
|
||||
auto TempTC = std::make_unique<toolchains::AMDGPUOpenMPToolChain>(
|
||||
*this, *AMDTriple, *HostTC, C.getInputArgs());
|
||||
for (StringRef Arch : getOffloadArchs(
|
||||
C, C.getArgs(), Action::OFK_OpenMP, &*TempTC, true))
|
||||
Archs.insert(Arch);
|
||||
}
|
||||
if (!AMDTriple && !NVPTXTriple) {
|
||||
for (const std::optional<llvm::Triple> &TT : {NVPTXTriple, AMDTriple}) {
|
||||
if (!TT)
|
||||
continue;
|
||||
|
||||
auto &TC =
|
||||
getOffloadToolChain(C.getInputArgs(), Action::OFK_OpenMP, *TT,
|
||||
C.getDefaultToolChain().getTriple());
|
||||
for (StringRef Arch :
|
||||
getOffloadArchs(C, C.getArgs(), Action::OFK_OpenMP, nullptr, true))
|
||||
getOffloadArchs(C, C.getArgs(), Action::OFK_OpenMP, &TC, true))
|
||||
Archs.insert(Arch);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
// UNSUPPORTED: target={{.*darwin.*}}
|
||||
|
||||
// RUN: %clang --target=x86_64-unknown-linux-gnu -x cuda %s -Xarch_nvptx64 -O3 -S -nogpulib -nogpuinc -### 2>&1 | FileCheck -check-prefix=O3ONCE %s
|
||||
// RUN: %clang -x cuda %s -Xarch_device -O3 -S -nogpulib -nogpuinc -### 2>&1 | FileCheck -check-prefix=O3ONCE %s
|
||||
// RUN: %clang -x hip %s -Xarch_amdgcn -O3 -S -nogpulib -nogpuinc -### 2>&1 | FileCheck -check-prefix=O3ONCE %s
|
||||
|
|
|
|||
Loading…
Reference in a new issue