From e96bec9cd8e14ee2174490c0ce09cedfcd6be79e Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Wed, 14 Jun 2023 16:58:11 -0500 Subject: [PATCH] [OpenMP] Correctly diagnose conflicting target identifierers for AMDGPU There are static checks on the target identifiers allowed in a single TU. Previously theses checks were only applied to HIP even though they should be the same for OpenMP targeting AMDGPU. Simply enable these checks for OpenMP. Reviewed By: JonChesterfield, yaxunl Differential Revision: https://reviews.llvm.org/D152965 --- clang/lib/Driver/Driver.cpp | 7 ++++--- clang/test/Driver/amdgpu-openmp-toolchain.c | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 8f92606..9fc62be 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -4313,8 +4313,8 @@ static StringRef getCanonicalArchString(Compilation &C, /// incompatible pair if a conflict occurs. static std::optional> getConflictOffloadArchCombination(const llvm::DenseSet &Archs, - Action::OffloadKind Kind) { - if (Kind != Action::OFK_HIP) + llvm::Triple Triple) { + if (!Triple.isAMDGPU()) return std::nullopt; std::set ArchSet; @@ -4399,7 +4399,8 @@ Driver::getOffloadArchs(Compilation &C, const llvm::opt::DerivedArgList &Args, } } - if (auto ConflictingArchs = getConflictOffloadArchCombination(Archs, Kind)) { + if (auto ConflictingArchs = + getConflictOffloadArchCombination(Archs, TC->getTriple())) { C.getDriver().Diag(clang::diag::err_drv_bad_offload_arch_combo) << ConflictingArchs->first << ConflictingArchs->second; C.setContainsError(); diff --git a/clang/test/Driver/amdgpu-openmp-toolchain.c b/clang/test/Driver/amdgpu-openmp-toolchain.c index 08ad3a01..9a14f45 100644 --- a/clang/test/Driver/amdgpu-openmp-toolchain.c +++ b/clang/test/Driver/amdgpu-openmp-toolchain.c @@ -66,3 +66,7 @@ // RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx90a:sramecc-:xnack+ \ // RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-ID // CHECK-TARGET-ID: clang-offload-packager{{.*}}arch=gfx90a,kind=openmp,feature=-sramecc,feature=+xnack + +// RUN: not %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx90a,gfx90a:xnack+ \ +// RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-ID-ERROR +// CHECK-TARGET-ID-ERROR: error: invalid offload arch combinations: 'gfx90a' and 'gfx90a:xnack+' -- 2.7.4