Skip to content

Commit 4bd7952

Browse files
doru1004ronlieb
authored andcommitted
Default to new driver and default device linker pipeline
Change-Id: I64c952c9f198dfe62dc8a10275b29de3a0fadc4e
1 parent 0a9e9a8 commit 4bd7952

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,6 @@ void AMDGPUOpenMPToolChain::addClangTargetOptions(
435435
options::OPT_fno_gpu_allow_device_init, false))
436436
CC1Args.push_back("-fgpu-allow-device-init");
437437

438-
// TODO: check if flag is needed for the opaque linker case
439-
const char *UseLinkerWrapper = std::getenv("CLANG_USE_LINKER_WRAPPER");
440-
if (!UseLinkerWrapper || atoi(UseLinkerWrapper) == 0)
441-
CC1Args.push_back("-fcuda-allow-variadic-functions");
442-
443438
// Default to "hidden" visibility, as object level linking will not be
444439
// supported for the foreseeable future.
445440
if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9664,11 +9664,9 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
96649664
}
96659665

96669666
// Overwrite the default driver choice using an env var:
9667-
// CLANG_USE_LINKER_WRAPPER which can be 0 or 1.
96689667
bool UseOpaqueOffloadLinker = isAMDGPU;
96699668
if (isAMDGPU)
9670-
if (const char *UseLinkerWrapper = std::getenv("CLANG_USE_LINKER_WRAPPER"))
9671-
UseOpaqueOffloadLinker = !(atoi(UseLinkerWrapper) == 1);
9669+
UseOpaqueOffloadLinker = 0;
96729670

96739671
if (!OpenMPTCs.empty() && Args.hasFlag(options::OPT_opaque_offload_linker,
96749672
options::OPT_no_opaque_offload_linker,
@@ -9714,6 +9712,12 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
97149712
OOpt = "0";
97159713
if (!OOpt.empty())
97169714
CmdArgs.push_back(Args.MakeArgString(Twine("--opt-level=O") + OOpt));
9715+
9716+
// Ensure we default to default linking pipeline when linking on AMD GPUs:
9717+
if (!D.IsFlangMode() && isAMDGPU && OOpt != "0")
9718+
CmdArgs.push_back(Args.MakeArgString(
9719+
Twine("--device-linker=--lto-newpm-passes=default<O") + OOpt +
9720+
Twine(">")));
97179721
}
97189722

97199723
CmdArgs.push_back(

clang/test/Driver/amdgpu-openmp-toolchain.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,30 @@
114114
// LIBCXX-NOT: include/amdgcn-amd-amdhsa/c++/v1
115115

116116
// RUN: %clang -### --save-temps -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx90a:xnack+ -mamdgpu-precise-memory-op \
117-
// RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-FEATURES
117+
// RUN: -nogpulib %s --opaque-offload-linker 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-FEATURES
118118
// CHECK-TARGET-FEATURES: clang-offload-packager{{.*}} "-o" {{.*}}.out" "--image=file={{.*}}.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a:xnack+,kind=openmp"
119119
// CHECK-TARGET-FEATURES: clang-offload-packager"{{.*}}.o" "--image=file={{.*}}.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a:xnack+,kind=openmp"
120120
// CHECK-TARGET-FEATURES: opt{{.*}} "-mtriple=amdgcn-amd-amdhsa" "-o" {{.*}}.bc" "-mcpu=gfx90a" "-mattr=+xnack,+precise-memory"
121121
// CHECK-TARGET-FEATURES: llc{{.*}} "-mtriple=amdgcn-amd-amdhsa" "-filetype=asm" "-o" {{.*}}.s" "{{.*}}.bc" "-mcpu=gfx90a" "-mattr=+xnack,+precise-memory"
122122
// CHECK-TARGET-FEATURES: llc{{.*}} "-mtriple=amdgcn-amd-amdhsa" "-filetype=obj" "-o" {{.*}}.o" "{{.*}}.bc" "-mcpu=gfx90a" "-mattr=+xnack,+precise-memory"
123123
// CHECK-TARGET-FEATURES: lld{{.*}} "-flavor" "gnu" "--no-undefined" "-shared" {{.*}}.o" "-plugin-opt=mcpu=gfx90a" "-plugin-opt=-mattr=+xnack,+precise-memory" "-o" {{.*}}.out"
124+
125+
// RUN: %clang -### --save-temps -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx90a:xnack+ -mamdgpu-precise-memory-op \
126+
// RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-FEATURES-LW
127+
// CHECK-TARGET-FEATURES-LW: clang-linker-wrapper
128+
129+
// RUN: %clang -### --save-temps -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx90a:xnack+ -mamdgpu-precise-memory-op \
130+
// RUN: -nogpulib %s -O3 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-FEATURES-LW3
131+
// CHECK-TARGET-FEATURES-LW3: clang-linker-wrapper{{.*}} "--device-linker=--lto-newpm-passes=default<O3>"
132+
133+
// RUN: %clang -### --save-temps -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx90a:xnack+ -mamdgpu-precise-memory-op \
134+
// RUN: -nogpulib %s -O2 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-FEATURES-LW2
135+
// CHECK-TARGET-FEATURES-LW2: clang-linker-wrapper{{.*}} "--device-linker=--lto-newpm-passes=default<O2>"
136+
137+
// RUN: %clang -### --save-temps -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx90a:xnack+ -mamdgpu-precise-memory-op \
138+
// RUN: -nogpulib %s -O1 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-FEATURES-LW1
139+
// CHECK-TARGET-FEATURES-LW1: clang-linker-wrapper{{.*}} "--device-linker=--lto-newpm-passes=default<O1>"
140+
141+
// RUN: %clang -### --save-temps -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx90a:xnack+ -mamdgpu-precise-memory-op \
142+
// RUN: -nogpulib %s -O0 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-FEATURES-LW0
143+
// CHECK-TARGET-FEATURES-LW0-NOT: clang-linker-wrapper{{.*}} "--device-linker=--lto-newpm-passes=default<O0>"

offload/test/lit.cfg

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ if 'OMP_TARGET_OFFLOAD' in os.environ:
3434
if 'HSA_ENABLE_SDMA' in os.environ:
3535
config.environment['HSA_ENABLE_SDMA'] = os.environ['HSA_ENABLE_SDMA']
3636

37-
if 'CLANG_USE_LINKER_WRAPPER' in os.environ:
38-
config.environment['CLANG_USE_LINKER_WRAPPER'] = os.environ['CLANG_USE_LINKER_WRAPPER']
39-
else:
40-
config.environment['CLANG_USE_LINKER_WRAPPER'] = "1"
41-
4237
# Architectures like gfx942 may or may not be APUs so an additional environment
4338
# variable is required as some tests can be APU specific.
4439
if 'IS_APU' in os.environ:

0 commit comments

Comments
 (0)