Skip to content

Commit 5ffb2ee

Browse files
authored
[Driver][SYCL] Imply -fno-discard-value-names for FPGA (#6270)
When compiling for FPGA AOT targets, we want to be sure that -fno-discard-value-names is the default.
1 parent c0e36bd commit 5ffb2ee

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4720,6 +4720,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
47204720

47214721
bool IsUsingLTO = D.isUsingLTO(IsDeviceOffloadAction);
47224722
auto LTOMode = D.getLTOMode(IsDeviceOffloadAction);
4723+
bool IsFPGASYCLOffloadDevice =
4724+
IsSYCLOffloadDevice &&
4725+
Triple.getSubArch() == llvm::Triple::SPIRSubArch_fpga;
47234726

47244727
// Perform the SYCL host compilation using an external compiler if the user
47254728
// requested.
@@ -4871,7 +4874,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
48714874
// Default value for FPGA is false, for all other targets is true.
48724875
if (!Args.hasFlag(options::OPT_fsycl_early_optimizations,
48734876
options::OPT_fno_sycl_early_optimizations,
4874-
Triple.getSubArch() != llvm::Triple::SPIRSubArch_fpga))
4877+
!IsFPGASYCLOffloadDevice))
48754878
CmdArgs.push_back("-fno-sycl-early-optimizations");
48764879
else if (RawTriple.isSPIR()) {
48774880
// Set `sycl-opt` option to configure LLVM passes for SPIR target
@@ -5355,7 +5358,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
53555358

53565359
// Discard value names in assert builds unless otherwise specified.
53575360
if (Args.hasFlag(options::OPT_fdiscard_value_names,
5358-
options::OPT_fno_discard_value_names, !IsAssertBuild)) {
5361+
options::OPT_fno_discard_value_names,
5362+
!IsAssertBuild && !IsFPGASYCLOffloadDevice)) {
53595363
if (Args.hasArg(options::OPT_fdiscard_value_names) &&
53605364
llvm::any_of(Inputs, [](const clang::driver::InputInfo &II) {
53615365
return types::isLLVMIR(II.getType());

clang/test/Driver/sycl-offload-intelfpga.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,3 +517,10 @@
517517
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -Xssimulation %S/Inputs/SYCL/liblin64.a %s 2>&1 \
518518
// RUN: | FileCheck -check-prefix IMPLIED_DEVICE_HARDWARE -DBEOPT=simulation %s
519519
// IMPLIED_DEVICE_HARDWARE: aoc{{.*}} "-[[BEOPT]]"
520+
521+
/// -fno-discard-value-names is default for FPGA
522+
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga %s 2>&1 \
523+
// RUN: | FileCheck -check-prefix=CHK-DISCARD-VALUE-NAMES %s
524+
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64_fpga-unknown-unknown %s 2>&1 \
525+
// RUN: | FileCheck -check-prefix=CHK-DISCARD-VALUE-NAMES %s
526+
// CHK-DISCARD-VALUE-NAMES-NOT: clang{{.*}} "-fsycl-is-device"{{.*}} "-discard-value-names"

0 commit comments

Comments
 (0)