Skip to content

Commit 33bc8ad

Browse files
authored
[SYCL][FPGA] Restore legacy debug info version for the hardware (#3991)
Signed-off-by: Dmitry Sidorov <[email protected]>
1 parent c56a270 commit 33bc8ad

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8608,7 +8608,11 @@ void SPIRVTranslator::ConstructJob(Compilation &C, const JobAction &JA,
86088608
TranslatorArgs.push_back(Output.getFilename());
86098609
if (getToolChain().getTriple().isSYCLDeviceEnvironment()) {
86108610
TranslatorArgs.push_back("-spirv-max-version=1.3");
8611-
TranslatorArgs.push_back("-spirv-debug-info-version=ocl-100");
8611+
// TODO: align debug info for FPGA H/W when its SPIR-V consumer is ready
8612+
if (C.getDriver().isFPGAEmulationMode())
8613+
TranslatorArgs.push_back("-spirv-debug-info-version=ocl-100");
8614+
else
8615+
TranslatorArgs.push_back("-spirv-debug-info-version=legacy");
86128616
// Prevent crash in the translator if input IR contains DIExpression
86138617
// operations which don't have mapping to OpenCL.DebugInfo.100 spec.
86148618
TranslatorArgs.push_back("-spirv-allow-extra-diexpressions");
@@ -8639,23 +8643,14 @@ void SPIRVTranslator::ConstructJob(Compilation &C, const JobAction &JA,
86398643
",+SPV_INTEL_long_constant_composite"
86408644
",+SPV_INTEL_fpga_invocation_pipelining_attributes";
86418645
ExtArg = ExtArg + DefaultExtArg + INTELExtArg;
8642-
if (getToolChain().getTriple().getSubArch() ==
8643-
llvm::Triple::SPIRSubArch_fpga) {
8644-
for (auto *A : TCArgs) {
8645-
if (A->getOption().matches(options::OPT_Xs_separate) ||
8646-
A->getOption().matches(options::OPT_Xs)) {
8647-
StringRef ArgString(A->getValue());
8648-
// Enable SPV_INTEL_usm_storage_classes only for FPGA hardware,
8649-
// since it adds new storage classes that represent global_device and
8650-
// global_host address spaces, which are not supported for all
8651-
// targets. With the extension disabled the storage classes will be
8652-
// lowered to CrossWorkgroup storage class that is mapped to just
8653-
// global address space.
8654-
if (ArgString == "hardware" || ArgString == "simulation")
8655-
ExtArg += ",+SPV_INTEL_usm_storage_classes";
8656-
}
8657-
}
8658-
}
8646+
if (!C.getDriver().isFPGAEmulationMode())
8647+
// Enable SPV_INTEL_usm_storage_classes only for FPGA hardware,
8648+
// since it adds new storage classes that represent global_device and
8649+
// global_host address spaces, which are not supported for all
8650+
// targets. With the extension disabled the storage classes will be
8651+
// lowered to CrossWorkgroup storage class that is mapped to just
8652+
// global address space.
8653+
ExtArg += ",+SPV_INTEL_usm_storage_classes";
86598654
TranslatorArgs.push_back(TCArgs.MakeArgString(ExtArg));
86608655
}
86618656
for (auto I : Inputs) {

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ const char *SYCL::Linker::constructLLVMSpirvCommand(
6666
} else {
6767
CmdArgs.push_back("-spirv-max-version=1.3");
6868
CmdArgs.push_back("-spirv-ext=+all");
69-
CmdArgs.push_back("-spirv-debug-info-version=ocl-100");
69+
if (!C.getDriver().isFPGAEmulationMode())
70+
CmdArgs.push_back("-spirv-debug-info-version=legacy");
71+
else
72+
CmdArgs.push_back("-spirv-debug-info-version=ocl-100");
7073
CmdArgs.push_back("-spirv-allow-extra-diexpressions");
7174
CmdArgs.push_back("-spirv-allow-unknown-intrinsics=llvm.genx.");
7275
CmdArgs.push_back("-o");

clang/test/Driver/sycl-offload.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,8 @@
709709
// CHK-TOOLS-AOT: file-table-tform{{.*}} "-extract=Code" "-drop_titles" "-o" "[[OUTPUT2_1:.+\.txt]]" "[[OUTPUT2_T]]"
710710
// CHK-TOOLS-CPU: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.3" "-spirv-debug-info-version=ocl-100" "-spirv-allow-extra-diexpressions" "-spirv-allow-unknown-intrinsics=llvm.genx." {{.*}} "[[OUTPUT2_1]]"
711711
// CHK-TOOLS-GEN: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.3" "-spirv-debug-info-version=ocl-100" "-spirv-allow-extra-diexpressions" "-spirv-allow-unknown-intrinsics=llvm.genx." {{.*}} "[[OUTPUT2_1]]"
712-
// CHK-TOOLS-FPGA: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.3" "-spirv-debug-info-version=ocl-100" "-spirv-allow-extra-diexpressions" "-spirv-allow-unknown-intrinsics=llvm.genx." {{.*}} "[[OUTPUT2_1]]"
712+
// CHK-TOOLS-FPGA-HW: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.3" "-spirv-debug-info-version=legacy" "-spirv-allow-extra-diexpressions" "-spirv-allow-unknown-intrinsics=llvm.genx." {{.*}} "[[OUTPUT2_1]]"
713+
// CHK-TOOLS-FPGA-EMU: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.3" "-spirv-debug-info-version=ocl-100" "-spirv-allow-extra-diexpressions" "-spirv-allow-unknown-intrinsics=llvm.genx." {{.*}} "[[OUTPUT2_1]]"
713714
// CHK-TOOLS-FPGA-HW: aoc{{.*}} "-o" "[[OUTPUT4_T:.+\.aocx]]" "[[OUTPUT3_T]]"
714715
// CHK-TOOLS-FPGA-EMU: opencl-aot{{.*}} "-spv=[[OUTPUT3_T]]" "-ir=[[OUTPUT4_T:.+\.aocx]]"
715716
// CHK-TOOLS-GEN: ocloc{{.*}} "-output" "[[OUTPUT4_T:.+\.out]]" {{.*}} "[[OUTPUT3_T]]"

0 commit comments

Comments
 (0)