-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang][OpenMP] Do not use feature option during packaging #111702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
@llvm/pr-subscribers-clang @llvm/pr-subscribers-backend-amdgpu Author: Saiyedul Islam (saiislam) ChangesClang-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. Full diff: https://github.com/llvm/llvm-project/pull/111702.diff 2 Files Affected:
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
|
@llvm/pr-subscribers-clang-driver Author: Saiyedul Islam (saiislam) ChangesClang-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. Full diff: https://github.com/llvm/llvm-project/pull/111702.diff 2 Files Affected:
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
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.