Skip to content

Commit 8ae9a20

Browse files
authored
[Clang][Driver] Only enable internalization for OpenMP target offloading with ThinLTO on AMDGPU (#138547)
1 parent cdc9a4b commit 8ae9a20

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9284,12 +9284,6 @@ 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-
92939287
// Forward the LTO mode relying on the Driver's parsing.
92949288
if (C.getDriver().getOffloadLTOMode() == LTOK_Full)
92959289
CmdArgs.push_back(Args.MakeArgString(
@@ -9304,6 +9298,11 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
93049298
CmdArgs.push_back(
93059299
Args.MakeArgString("--device-linker=" + TC->getTripleString() +
93069300
"=-plugin-opt=-avail-extern-to-local"));
9301+
if (Kind == Action::OFK_OpenMP) {
9302+
CmdArgs.push_back(
9303+
Args.MakeArgString("--device-linker=" + TC->getTripleString() +
9304+
"=-plugin-opt=-amdgpu-internalize-symbols"));
9305+
}
93079306
}
93089307
}
93099308
}

clang/test/Driver/hip-options.hip

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,3 @@
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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,9 @@
388388
// THINLTO-GFX906: --device-compiler=amdgcn-amd-amdhsa=-flto=thin
389389
// THINLTO-GFX906-SAME: --device-linker=amdgcn-amd-amdhsa=-plugin-opt=-force-import-all
390390
// THINLTO-GFX906-SAME: --device-linker=amdgcn-amd-amdhsa=-plugin-opt=-avail-extern-to-local
391+
// THINLTO-GFX906-SAME: --device-linker=amdgcn-amd-amdhsa=-plugin-opt=-amdgpu-internalize-symbols
391392
//
392393
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
393394
// RUN: --offload-arch=sm_52 -foffload-lto=thin -nogpulib -nogpuinc %s 2>&1 \
394395
// RUN: | FileCheck --check-prefix=THINLTO-SM52 %s
395396
// 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)