Skip to content

Commit

Permalink
[SYCL][DebugInfo] Switch to nonsemantic-shader-200 for non-FPGA HW on…
Browse files Browse the repository at this point in the history
… linux (intel#13107)

---------

Signed-off-by: Sidorov, Dmitry <[email protected]>
  • Loading branch information
MrSidims authored Apr 17, 2024
1 parent c02f915 commit e9befa2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
25 changes: 18 additions & 7 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10316,10 +10316,22 @@ static void getOtherSPIRVTransOpts(Compilation &C,
bool IsCPU = Triple.isSPIR() &&
Triple.getSubArch() == llvm::Triple::SPIRSubArch_x86_64;
TranslatorArgs.push_back("-spirv-max-version=1.4");
TranslatorArgs.push_back("-spirv-debug-info-version=ocl-100");
// Prevent crash in the translator if input IR contains DIExpression
// operations which don't have mapping to OpenCL.DebugInfo.100 spec.
TranslatorArgs.push_back("-spirv-allow-extra-diexpressions");
// Enable NonSemanticShaderDebugInfo.200 for CPU AOT and for non-Windows
// Enable NonSemanticShaderDebugInfo.200 for CPU AOT and for non-Windows
const bool IsWindowsMSVC =
Triple.isWindowsMSVCEnvironment() ||
C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment();
const bool EnableNonSemanticDebug =
IsCPU || (!IsWindowsMSVC && !C.getDriver().IsFPGAHWMode());
if (EnableNonSemanticDebug) {
TranslatorArgs.push_back(
"-spirv-debug-info-version=nonsemantic-shader-200");
} else {
TranslatorArgs.push_back("-spirv-debug-info-version=ocl-100");
// Prevent crash in the translator if input IR contains DIExpression
// operations which don't have mapping to OpenCL.DebugInfo.100 spec.
TranslatorArgs.push_back("-spirv-allow-extra-diexpressions");
}
std::string UnknownIntrinsics("-spirv-allow-unknown-intrinsics=llvm.genx.");
if (IsCPU)
UnknownIntrinsics += ",llvm.fpbuiltin";
Expand Down Expand Up @@ -10380,9 +10392,8 @@ static void getOtherSPIRVTransOpts(Compilation &C,
",+SPV_KHR_uniform_group_instructions"
",+SPV_INTEL_masked_gather_scatter"
",+SPV_INTEL_tensor_float32_conversion"
",+SPV_INTEL_optnone";
if (ShouldPreserveMetadata)
ExtArg += ",+SPV_KHR_non_semantic_info";
",+SPV_INTEL_optnone"
",+SPV_KHR_non_semantic_info";
if (IsCPU)
ExtArg += ",+SPV_INTEL_fp_max_error";

Expand Down
7 changes: 4 additions & 3 deletions clang/test/Driver/sycl-offload-aot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@
// CHK-TOOLS-AOT: llvm-link{{.*}} "[[OUTPUT1]]" "-o" "[[OUTPUT2:.+\.bc]]"
// CHK-TOOLS-AOT: sycl-post-link{{.*}} "-o" "[[OUTPUT2_T:.+\.table]]" "[[OUTPUT2]]"
// CHK-TOOLS-AOT: file-table-tform{{.*}} "-extract=Code" "-drop_titles" "-o" "[[OUTPUT2_1:.+\.txt]]" "[[OUTPUT2_T]]"
// CHK-TOOLS-CPU: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.4" "-spirv-debug-info-version=ocl-100" "-spirv-allow-extra-diexpressions" "-spirv-allow-unknown-intrinsics=llvm.genx.,llvm.fpbuiltin" {{.*}} "[[OUTPUT2_1]]"
// CHK-TOOLS-GEN: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.4" "-spirv-debug-info-version=ocl-100" "-spirv-allow-extra-diexpressions" "-spirv-allow-unknown-intrinsics=llvm.genx." {{.*}} "[[OUTPUT2_1]]"
// CHK-TOOLS-FPGA: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.4" "-spirv-debug-info-version=ocl-100" "-spirv-allow-extra-diexpressions" "-spirv-allow-unknown-intrinsics=llvm.genx." {{.*}} "[[OUTPUT2_1]]"
// CHK-TOOLS-CPU: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.4" "-spirv-debug-info-version=nonsemantic-shader-200" "-spirv-allow-unknown-intrinsics=llvm.genx.,llvm.fpbuiltin" {{.*}} "[[OUTPUT2_1]]"
// CHK-TOOLS-GEN: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.4" "-spirv-debug-info-version=nonsemantic-shader-200" "-spirv-allow-unknown-intrinsics=llvm.genx." {{.*}} "[[OUTPUT2_1]]"
// CHK-TOOLS-FPGA-HW: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.4" "-spirv-debug-info-version=ocl-100" "-spirv-allow-extra-diexpressions" "-spirv-allow-unknown-intrinsics=llvm.genx." {{.*}} "[[OUTPUT2_1]]"
// CHK-TOOLS-FPGA-EMU: llvm-spirv{{.*}} "-o" "[[OUTPUT3_T:.+\.txt]]" "-spirv-max-version=1.4" "-spirv-debug-info-version=nonsemantic-shader-200" "-spirv-allow-unknown-intrinsics=llvm.genx." {{.*}} "[[OUTPUT2_1]]"
// CHK-TOOLS-FPGA-HW: aoc{{.*}} "-o" "[[OUTPUT4_T:.+\.aocx]]" "[[OUTPUT3_T]]"
// CHK-TOOLS-FPGA-EMU: opencl-aot{{.*}} "-spv=[[OUTPUT3_T]]" "-ir=[[OUTPUT4_T:.+\.aocx]]"
// CHK-TOOLS-GEN: ocloc{{.*}} "-output" "[[OUTPUT4_T:.+\.out]]" {{.*}} "[[OUTPUT3_T]]"
Expand Down
4 changes: 3 additions & 1 deletion clang/test/Driver/sycl-spirv-ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
// CHECK-DEFAULT-SAME:,+SPV_KHR_uniform_group_instructions
// CHECK-DEFAULT-SAME:,+SPV_INTEL_masked_gather_scatter
// CHECK-DEFAULT-SAME:,+SPV_INTEL_tensor_float32_conversion
// CHECK-DEFAULT-SAME:,+SPV_INTEL_optnone"
// CHECK-DEFAULT-SAME:,+SPV_INTEL_optnone
// CHECK-DEFAULT-SAME:,+SPV_KHR_non_semantic_info"
// CHECK-FPGA-HW: llvm-spirv{{.*}}"-spirv-ext=-all
// CHECK-FPGA-HW-SAME:,+SPV_EXT_shader_atomic_float_add
// CHECK-FPGA-HW-SAME:,+SPV_EXT_shader_atomic_float_min_max
Expand Down Expand Up @@ -119,5 +120,6 @@
// CHECK-CPU-SAME:,+SPV_INTEL_masked_gather_scatter
// CHECK-CPU-SAME:,+SPV_INTEL_tensor_float32_conversion
// CHECK-CPU-SAME:,+SPV_INTEL_optnone
// CHECK-CPU-SAME:,+SPV_KHR_non_semantic_info
// CHECK-CPU-SAME:,+SPV_INTEL_fp_max_error"

2 changes: 0 additions & 2 deletions clang/test/Driver/sycl-spirv-metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@

// CHECK-WITHOUT: "{{.*}}llvm-spirv"
// CHECK-WITHOUT-NOT: --spirv-preserve-auxdata
// CHECK-WITHOUT:-spirv-ext=
// CHECK-WITHOUT-NOT: +SPV_KHR_non_semantic_info

0 comments on commit e9befa2

Please sign in to comment.