https://github.com/saiislam created https://github.com/llvm/llvm-project/pull/111702
Clang-offload-packager allows packaging of images based on an arbitrary list of key-value pairs where only triple-key is mandatory. Using target features as a key during packaging is not correct, as clang does not allow packaging multiple images in one binary which only differ in a target feature. TargetID features (xnack and sramecc) anyways are handled using arch-key and not as target features. >From bb562aef3278323f7e119e9dae35d4e1bb8d8095 Mon Sep 17 00:00:00 2001 From: Saiyedul Islam <saiyedul.is...@amd.com> Date: Wed, 9 Oct 2024 10:46:34 -0500 Subject: [PATCH] [Clang][OpenMP] Do not use feature option during packaging Clang-offload-packager allows packaging of images based on an arbitrary list of key-value pairs where only triple-key is mandatory. Using target features as a key during packaging is not correct, as clang does not allow packaging multiple images in one binary which only differ in a target feature. TargetID features (xnack and sramecc) anyways are handled using arch-key and not as target features. --- clang/lib/Driver/ToolChains/Clang.cpp | 9 +-------- clang/test/Driver/amdgpu-openmp-toolchain.c | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 66ec0a7fd32f99..5b09f97c40b485 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -9107,13 +9107,6 @@ void OffloadPackager::ConstructJob(Compilation &C, const JobAction &JA, llvm::copy_if(Features, std::back_inserter(FeatureArgs), [](StringRef Arg) { return !Arg.starts_with("-target"); }); - if (TC->getTriple().isAMDGPU()) { - for (StringRef Feature : llvm::split(Arch.split(':').second, ':')) { - FeatureArgs.emplace_back( - Args.MakeArgString(Feature.take_back() + Feature.drop_back())); - } - } - // TODO: We need to pass in the full target-id and handle it properly in the // linker wrapper. SmallVector<std::string> Parts{ @@ -9123,7 +9116,7 @@ void OffloadPackager::ConstructJob(Compilation &C, const JobAction &JA, "kind=" + Kind.str(), }; - if (TC->getDriver().isUsingOffloadLTO() || TC->getTriple().isAMDGPU()) + if (TC->getDriver().isUsingOffloadLTO()) for (StringRef Feature : FeatureArgs) Parts.emplace_back("feature=" + Feature.str()); diff --git a/clang/test/Driver/amdgpu-openmp-toolchain.c b/clang/test/Driver/amdgpu-openmp-toolchain.c index 184819b790c4ff..f596708047c154 100644 --- a/clang/test/Driver/amdgpu-openmp-toolchain.c +++ b/clang/test/Driver/amdgpu-openmp-toolchain.c @@ -64,7 +64,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: "-cc1" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-target-cpu" "gfx90a" "-target-feature" "-sramecc" "-target-feature" "+xnack" -// CHECK-TARGET-ID: clang-offload-packager{{.*}}arch=gfx90a:sramecc-:xnack+,kind=openmp,feature=-sramecc,feature=+xnack +// CHECK-TARGET-ID: clang-offload-packager{{.*}}arch=gfx90a:sramecc-:xnack+,kind=openmp // 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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits