Skip to content

Commit 7d94edf

Browse files
authored
[Driver][SYCL][FPGA] Restrict -O0 for FPGA with hardware (#3966)
When using -O0 on the command with FPGA -Xshardware, we do not want to pass along -O0 to the device compilation. We do this by stripping out the option for the device compilation under these conditions.
1 parent 33d9af3 commit 7d94edf

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,10 @@ SYCLToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
639639
}
640640
}
641641
}
642+
// Strip out -O0 for FPGA Hardware device compilation.
643+
if (!getDriver().isFPGAEmulationMode() &&
644+
getTriple().getSubArch() == llvm::Triple::SPIRSubArch_fpga)
645+
DAL->eraseArg(options::OPT_O0);
642646

643647
const OptTable &Opts = getDriver().getOpts();
644648
if (!BoundArch.empty()) {

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,12 @@
214214
// RUN: | FileCheck %s --check-prefix=CHK-FPGA-LINK-WARN-AOCX
215215
// CHK-FPGA-LINK-WARN-AOCX: warning: FPGA archive '{{.*}}_aocx.a' does not contain matching emulation/hardware expectancy
216216

217+
/// Check for implied options with emulation (-g -O0)
218+
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -g -O0 -Xs "-DFOO1 -DFOO2" %s 2>&1 \
219+
// RUN: | FileCheck -check-prefix=CHK-TOOLS-IMPLIED-OPTS %s
220+
// RUN: %clang_cl -### -fsycl -fintelfpga -Zi -Od -Xs "-DFOO1 -DFOO2" %s 2>&1 \
221+
// RUN: | FileCheck -check-prefix=CHK-TOOLS-IMPLIED-OPTS %s
222+
// CHK-TOOLS-IMPLIED-OPTS: clang{{.*}} "-fsycl-is-device"{{.*}} "-O0"
223+
// CHK-TOOLS-IMPLIED-OPTS: sycl-post-link{{.*}} "-O0"
224+
// CHK-TOOLS-IMPLIED-OPTS: opencl-aot{{.*}} "--bo=-g -cl-opt-disable" "-DFOO1" "-DFOO2"
225+

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,15 @@
403403
// RUN: | FileCheck -check-prefix=CHK-FPGA-REPORT-NAME %s
404404
// CHK-FPGA-REPORT-NAME: aoc{{.*}} "-sycl"{{.*}} "-output-report-folder={{.*}}dummy2.prj"
405405

406-
/// Check for implied options (-g -O0)
406+
/// Check for implied options with -Xshardware (-g -O0)
407+
/// Expectation is for -O0 to not be used with -Xshardware
407408
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -g -O0 -Xs "-DFOO1 -DFOO2" -Xshardware %s 2>&1 \
408409
// RUN: | FileCheck -check-prefix=CHK-TOOLS-IMPLIED-OPTS %s
409410
// RUN: %clang_cl -### -fsycl -fintelfpga -Zi -Od -Xs "-DFOO1 -DFOO2" -Xshardware %s 2>&1 \
410411
// RUN: | FileCheck -check-prefix=CHK-TOOLS-IMPLIED-OPTS %s
411-
// CHK-TOOLS-IMPLIED-OPTS: aoc{{.*}} "-g" "-cl-opt-disable" "-DFOO1" "-DFOO2"
412+
// CHK-TOOLS-IMPLIED-OPTS-NOT: clang{{.*}} "-fsycl-is-device"{{.*}} "-O0"
413+
// CHK-TOOLS-IMPLIED-OPTS: sycl-post-link{{.*}} "-O2"
414+
// CHK-TOOLS-IMPLIED-OPTS: aoc{{.*}} "-g" "-DFOO1" "-DFOO2"
412415

413416
/// Check the warning's emission for conflicting emulation/hardware (AOCX)
414417
// RUN: touch %t_aocx.a

0 commit comments

Comments
 (0)