https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/204864
>From 78fece9dd1ed40ff00e26e8d8b73a3c608795fef Mon Sep 17 00:00:00 2001 From: Matt Arsenault <[email protected]> Date: Fri, 19 Jun 2026 17:01:05 +0200 Subject: [PATCH] clang/AMDGPU: Remove driver restriction on --gpu-max-threads-per-block Previously this flag was only handled for HIP, and would produce an unused argument warning. There is a custom warning produced by cc1 that the argument isn't supported, but practically speaking that was unreachable due to not forwarding the argument. Also add a test for the untested warning. Also use a simpler method for forwarding the flag to cc1. --- clang/lib/Driver/ToolChains/AMDGPU.cpp | 10 ++-------- clang/test/Driver/amdgpu-openmp-max-threads.c | 5 +++++ .../openmp-warn-gpu-max-threads-per-block.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 clang/test/Driver/amdgpu-openmp-max-threads.c create mode 100644 clang/test/Frontend/openmp-warn-gpu-max-threads-per-block.c diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 6611b133057f5..495f724338250 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -878,16 +878,10 @@ void AMDGPUToolChain::addClangTargetOptions( if (DriverArgs.hasArgNoClaim(options::OPT_hipstdpar)) CC1Args.append({"-mllvm", "-amdgpu-enable-hipstdpar"}); } - - // FIXME: This should not depend on HIP - StringRef MaxThreadsPerBlock = - DriverArgs.getLastArgValue(options::OPT_gpu_max_threads_per_block_EQ); - if (!MaxThreadsPerBlock.empty()) { - CC1Args.push_back(DriverArgs.MakeArgString( - Twine("--gpu-max-threads-per-block=") + MaxThreadsPerBlock)); - } } + DriverArgs.AddLastArg(CC1Args, options::OPT_gpu_max_threads_per_block_EQ); + // Default to "hidden" visibility, as object level linking will not be // supported for the foreseeable future. // TODO: remove the SPIR-V bypass once it can encode (hidden) visibility. diff --git a/clang/test/Driver/amdgpu-openmp-max-threads.c b/clang/test/Driver/amdgpu-openmp-max-threads.c new file mode 100644 index 0000000000000..52f95e0182419 --- /dev/null +++ b/clang/test/Driver/amdgpu-openmp-max-threads.c @@ -0,0 +1,5 @@ +// Test that --gpu-max-threads-per-block is not ignored by openmp. +// RUN: %clang -### -fopenmp --offload-arch=gfx906 --gpu-max-threads-per-block=256 %s 2>&1 | FileCheck %s + +// CHECK: "-cc1" "-triple" "amdgcn-amd-amdhsa" +// CHECK-SAME: "--gpu-max-threads-per-block=256" diff --git a/clang/test/Frontend/openmp-warn-gpu-max-threads-per-block.c b/clang/test/Frontend/openmp-warn-gpu-max-threads-per-block.c new file mode 100644 index 0000000000000..3efdc9ac2b5a0 --- /dev/null +++ b/clang/test/Frontend/openmp-warn-gpu-max-threads-per-block.c @@ -0,0 +1,14 @@ +// REQUIRES: amdgpu-registered-target + +// Test that --gpu-max-threads-per-block warns when used outside of HIP. +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa --gpu-max-threads-per-block=1024 \ +// RUN: -fsyntax-only -verify=warn %s + +// Test that no warning is emitted for HIP. +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -fcuda-is-device \ +// RUN: --gpu-max-threads-per-block=1024 -fsyntax-only -verify=hip %s + +// warn-warning@*{{'--gpu-max-threads-per-block=1024' is ignored since it is only supported for HIP}} +// hip-no-diagnostics + +void f(void) {} _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
