[PATCH] D88550: [HIP] Fix -fgpu-allow-device-init option
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 30 03:25:59 PDT 2020
yaxunl created this revision.
yaxunl added a reviewer: tra.
yaxunl requested review of this revision.
The option needs to be passed to both host and device compilation.
https://reviews.llvm.org/D88550
Files:
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/HIP.cpp
clang/test/Driver/hip-options.hip
Index: clang/test/Driver/hip-options.hip
===================================================================
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -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
Index: clang/lib/Driver/ToolChains/HIP.cpp
===================================================================
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -263,10 +263,6 @@
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
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5476,9 +5476,14 @@
// 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(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88550.295228.patch
Type: text/x-patch
Size: 2299 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200930/6183458d/attachment.bin>
More information about the cfe-commits
mailing list