Author: Yaxun (Sam) Liu Date: 2021-09-15T13:03:57-04:00 New Revision: ab5f2b505a0751bce41f4cec9afa3c1541d485d0
URL: https://github.com/llvm/llvm-project/commit/ab5f2b505a0751bce41f4cec9afa3c1541d485d0 DIFF: https://github.com/llvm/llvm-project/commit/ab5f2b505a0751bce41f4cec9afa3c1541d485d0.diff LOG: [HIP] Diagnose -fopenmp-targets for HIP programs Diagnose -fopenmp-targets for HIP programs since dual HIP and OpenMP offloading in the same compilation is currently not supported by HIP toolchain. Reviewed by: Artem Belevich Differential Revision: https://reviews.llvm.org/D109718 Added: Modified: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/lib/Driver/Driver.cpp clang/test/Driver/hip-options.hip Removed: ################################################################################ diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index c5621ecf328d..0cf49ed397f6 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -16,6 +16,8 @@ def err_drv_unsupported_opt_with_suggestion : Error< "unsupported option '%0'; did you mean '%1'?">; def err_drv_unsupported_opt_for_target : Error< "unsupported option '%0' for target '%1'">; +def err_drv_unsupported_opt_for_language_mode : Error< + "unsupported option '%0' for language mode '%1'">; def err_drv_unsupported_option_argument : Error< "unsupported argument '%1' to option '%0'">; def err_drv_unknown_stdin_type : Error< diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 0c6b043b5255..b2fb21b7052a 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -680,6 +680,12 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, } C.addOffloadDeviceToolChain(CudaTC.get(), OFK); } else if (IsHIP) { + if (auto *OMPTargetArg = + C.getInputArgs().getLastArg(options::OPT_fopenmp_targets_EQ)) { + Diag(clang::diag::err_drv_unsupported_opt_for_language_mode) + << OMPTargetArg->getSpelling() << "HIP"; + return; + } const ToolChain *HostTC = C.getSingleOffloadToolChain<Action::OFK_Host>(); const llvm::Triple &HostTriple = HostTC->getTriple(); auto OFK = Action::OFK_HIP; diff --git a/clang/test/Driver/hip-options.hip b/clang/test/Driver/hip-options.hip index 08a821c89a19..da82410a4fcf 100644 --- a/clang/test/Driver/hip-options.hip +++ b/clang/test/Driver/hip-options.hip @@ -87,3 +87,15 @@ // THINLTO-NOT: clang{{.*}}" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fwhole-program-vtables" // THINLTO: clang{{.*}}" "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-flto=thin" {{.*}} "-fwhole-program-vtables" // THINLTO-NOT: clang{{.*}}" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fwhole-program-vtables" + +// Check -fopenmp is allowed with HIP but -fopenmp-targets= is not allowed. + +// RUN: %clang -### -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \ +// RUN: --offload-arch=gfx906 -fopenmp %s 2>&1 | FileCheck -check-prefix=OMP %s +// OMP-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fopenmp" +// OMP: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-fopenmp" + +// RUN: not %clang -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \ +// RUN: --offload-arch=gfx906 -fopenmp -fopenmp-targets=amdgcn %s 2>&1 \ +// RUN: | FileCheck -check-prefix=OMPTGT %s +// OMPTGT: unsupported option '-fopenmp-targets=' for language mode 'HIP' _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits