Skip to content

Commit 2b62a31

Browse files
authored
[Clang][Driver] Enable internalization by default for AMDGPU (llvm#138365)
1 parent 659f5ac commit 2b62a31

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -9284,6 +9284,12 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
92849284
CmdArgs.push_back(Args.MakeArgString(
92859285
"--device-linker=" + TC->getTripleString() + "=" + Arg));
92869286

9287+
// Enable internalization for AMDGPU.
9288+
if (TC->getTriple().isAMDGPU())
9289+
CmdArgs.push_back(
9290+
Args.MakeArgString("--device-linker=" + TC->getTripleString() +
9291+
"=-plugin-opt=-amdgpu-internalize-symbols"));
9292+
92879293
// Forward the LTO mode relying on the Driver's parsing.
92889294
if (C.getDriver().getOffloadLTOMode() == LTOK_Full)
92899295
CmdArgs.push_back(Args.MakeArgString(

clang/test/Driver/hip-options.hip

+6
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,9 @@
259259
// RUN: --offload-arch=gfx1100 --offload-new-driver --offload-jobs=0x4 %s 2>&1 | \
260260
// RUN: FileCheck -check-prefix=INVJOBS %s
261261
// INVJOBS: clang: error: invalid integral value '0x4' in '--offload-jobs=0x4'
262+
263+
// Check that internalization is enabled for offloading on AMDGPU.
264+
// RUN: %clang -### -Werror --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
265+
// RUN: --offload-arch=gfx1100 --offload-new-driver %s 2>&1 | \
266+
// RUN: FileCheck -check-prefix=INTERNALIZATION %s
267+
// INTERNALIZATION: --device-linker=amdgcn-amd-amdhsa=-plugin-opt=-amdgpu-internalize-symbols

clang/test/Driver/openmp-offload-gpu.c

+7
Original file line numberDiff line numberDiff line change
@@ -393,3 +393,10 @@
393393
// RUN: --offload-arch=sm_52 -foffload-lto=thin -nogpulib -nogpuinc %s 2>&1 \
394394
// RUN: | FileCheck --check-prefix=THINLTO-SM52 %s
395395
// THINLTO-SM52: --device-compiler=nvptx64-nvidia-cuda=-flto=thin
396+
397+
// Check that internalization is enabled for OpenMP offloading on AMDGPU.
398+
//
399+
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
400+
// RUN: --offload-arch=gfx906 -nogpulib -nogpuinc %s 2>&1 \
401+
// RUN: | FileCheck --check-prefix=INTERNALIZATION-GFX906 %s
402+
// INTERNALIZATION-GFX906: --device-linker=amdgcn-amd-amdhsa=-plugin-opt=-amdgpu-internalize-symbols

0 commit comments

Comments
 (0)