Skip to content

Commit

Permalink
[HIP] Fix -fgpu-allow-device-init option
Browse files Browse the repository at this point in the history
The option needs to be passed to both host and device compilation.

Differential Revision: https://reviews.llvm.org/D88550
  • Loading branch information
yxsamliu committed Oct 5, 2020
1 parent 5b551b7 commit e372c1d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
11 changes: 8 additions & 3 deletions clang/lib/Driver/ToolChains/Clang.cpp
Expand Up @@ -5476,9 +5476,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// Forward -cl options to -cc1
RenderOpenCLOptions(Args, CmdArgs);

if (IsHIP && Args.hasFlag(options::OPT_fhip_new_launch_api,
options::OPT_fno_hip_new_launch_api, true))
CmdArgs.push_back("-fhip-new-launch-api");
if (IsHIP) {
if (Args.hasFlag(options::OPT_fhip_new_launch_api,
options::OPT_fno_hip_new_launch_api, true))
CmdArgs.push_back("-fhip-new-launch-api");
if (Args.hasFlag(options::OPT_fgpu_allow_device_init,
options::OPT_fno_gpu_allow_device_init, false))
CmdArgs.push_back("-fgpu-allow-device-init");
}

if (Arg *A = Args.getLastArg(options::OPT_fcf_protection_EQ)) {
CmdArgs.push_back(
Expand Down
4 changes: 0 additions & 4 deletions clang/lib/Driver/ToolChains/HIP.cpp
Expand Up @@ -268,10 +268,6 @@ void HIPToolChain::addClangTargetOptions(
CC1Args.push_back(DriverArgs.MakeArgStringRef(ArgStr));
}

if (DriverArgs.hasFlag(options::OPT_fgpu_allow_device_init,
options::OPT_fno_gpu_allow_device_init, false))
CC1Args.push_back("-fgpu-allow-device-init");

CC1Args.push_back("-fcuda-allow-variadic-functions");

// Default to "hidden" visibility, as object level linking will not be
Expand Down
5 changes: 5 additions & 0 deletions clang/test/Driver/hip-options.hip
Expand Up @@ -9,6 +9,11 @@
// CHECK: clang{{.*}}" "-cc1" {{.*}} "-fcuda-is-device"
// CHECK-SAME: "--gpu-max-threads-per-block=1024"

// RUN: %clang -### -nogpuinc -nogpulib -fgpu-allow-device-init \
// RUN: %s 2>&1 | FileCheck -check-prefix=DEVINIT %s
// DEVINIT: clang{{.*}}" "-cc1" {{.*}}"-fgpu-allow-device-init"
// DEVINIT: clang{{.*}}" "-cc1" {{.*}}"-fgpu-allow-device-init"

// RUN: %clang -### -x hip -target x86_64-pc-windows-msvc -fms-extensions \
// RUN: -mllvm -amdgpu-early-inline-all=true %s 2>&1 | \
// RUN: FileCheck -check-prefix=MLLVM %s
Expand Down

0 comments on commit e372c1d

Please sign in to comment.