-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[Clang][Driver] Only enable internalization for OpenMP target offloading with ThinLTO on AMDGPU #138547
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
Merged
shiltian
merged 1 commit into
main
from
users/shiltian/only-internalize-for-openmp-with-thinlto
May 5, 2025
Merged
[Clang][Driver] Only enable internalization for OpenMP target offloading with ThinLTO on AMDGPU #138547
shiltian
merged 1 commit into
main
from
users/shiltian/only-internalize-for-openmp-with-thinlto
May 5, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ing with ThinLTO on AMDGPU
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang Author: Shilei Tian (shiltian) ChangesFull diff: https://github.com/llvm/llvm-project/pull/138547.diff 3 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 093f6fe9d5c77..b2e0e5c857228 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -9284,12 +9284,6 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Args.MakeArgString(
"--device-linker=" + TC->getTripleString() + "=" + Arg));
- // Enable internalization for AMDGPU.
- if (TC->getTriple().isAMDGPU())
- CmdArgs.push_back(
- Args.MakeArgString("--device-linker=" + TC->getTripleString() +
- "=-plugin-opt=-amdgpu-internalize-symbols"));
-
// Forward the LTO mode relying on the Driver's parsing.
if (C.getDriver().getOffloadLTOMode() == LTOK_Full)
CmdArgs.push_back(Args.MakeArgString(
@@ -9304,6 +9298,11 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(
Args.MakeArgString("--device-linker=" + TC->getTripleString() +
"=-plugin-opt=-avail-extern-to-local"));
+ if (Kind == Action::OFK_OpenMP) {
+ CmdArgs.push_back(
+ Args.MakeArgString("--device-linker=" + TC->getTripleString() +
+ "=-plugin-opt=-amdgpu-internalize-symbols"));
+ }
}
}
}
diff --git a/clang/test/Driver/hip-options.hip b/clang/test/Driver/hip-options.hip
index 2a4d7d2cfd8bb..a07dca3638565 100644
--- a/clang/test/Driver/hip-options.hip
+++ b/clang/test/Driver/hip-options.hip
@@ -259,9 +259,3 @@
// RUN: --offload-arch=gfx1100 --offload-new-driver --offload-jobs=0x4 %s 2>&1 | \
// RUN: FileCheck -check-prefix=INVJOBS %s
// INVJOBS: clang: error: invalid integral value '0x4' in '--offload-jobs=0x4'
-
-// Check that internalization is enabled for offloading on AMDGPU.
-// RUN: %clang -### -Werror --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
-// RUN: --offload-arch=gfx1100 --offload-new-driver %s 2>&1 | \
-// RUN: FileCheck -check-prefix=INTERNALIZATION %s
-// INTERNALIZATION: --device-linker=amdgcn-amd-amdhsa=-plugin-opt=-amdgpu-internalize-symbols
diff --git a/clang/test/Driver/openmp-offload-gpu.c b/clang/test/Driver/openmp-offload-gpu.c
index 73dc5a7f75d5b..f67c2173cb144 100644
--- a/clang/test/Driver/openmp-offload-gpu.c
+++ b/clang/test/Driver/openmp-offload-gpu.c
@@ -388,15 +388,9 @@
// THINLTO-GFX906: --device-compiler=amdgcn-amd-amdhsa=-flto=thin
// THINLTO-GFX906-SAME: --device-linker=amdgcn-amd-amdhsa=-plugin-opt=-force-import-all
// THINLTO-GFX906-SAME: --device-linker=amdgcn-amd-amdhsa=-plugin-opt=-avail-extern-to-local
+// THINLTO-GFX906-SAME: --device-linker=amdgcn-amd-amdhsa=-plugin-opt=-amdgpu-internalize-symbols
//
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
// RUN: --offload-arch=sm_52 -foffload-lto=thin -nogpulib -nogpuinc %s 2>&1 \
// RUN: | FileCheck --check-prefix=THINLTO-SM52 %s
// THINLTO-SM52: --device-compiler=nvptx64-nvidia-cuda=-flto=thin
-
-// Check that internalization is enabled for OpenMP offloading on AMDGPU.
-//
-// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
-// RUN: --offload-arch=gfx906 -nogpulib -nogpuinc %s 2>&1 \
-// RUN: | FileCheck --check-prefix=INTERNALIZATION-GFX906 %s
-// INTERNALIZATION-GFX906: --device-linker=amdgcn-amd-amdhsa=-plugin-opt=-amdgpu-internalize-symbols
|
jhuber6
approved these changes
May 5, 2025
GeorgeARM
pushed a commit
to GeorgeARM/llvm-project
that referenced
this pull request
May 7, 2025
…ing with ThinLTO on AMDGPU (llvm#138547)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:driver
'clang' and 'clang++' user-facing binaries. Not 'clang-cl'
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.