Skip to content

Commit 817591c

Browse files
MrSidimssys-ce-bb
authored andcommitted
Fix invalid DebugInfoNone placement for DebugFunction (#3354)
In case of missing declaration we shouldn't place DebugInfoNone for OpenCL and Shader.DebugInfo.100 instruction sets. Solves issue from KhronosGroup/SPIRV-LLVM-Translator#3275 Signed-off-by: Sidorov, Dmitry <[email protected]> Original commit: KhronosGroup/SPIRV-LLVM-Translator@fa9bc14efcd68e0
1 parent f6bb648 commit 817591c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

llvm-spirv/lib/SPIRV/LLVMToSPIRVDbgTran.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,13 +1310,14 @@ SPIRVEntry *LLVMToSPIRVDbgTran::transDbgFunction(const DISubprogram *Func) {
13101310
if (DISubprogram *FuncDecl = Func->getDeclaration())
13111311
Ops.push_back(transDbgEntry(FuncDecl)->getId());
13121312
else {
1313-
Ops.push_back(getDebugInfoNoneId());
13141313
if (BM->getDebugInfoEIS() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200) {
13151314
// Translate targetFuncName mostly for Fortran trampoline function if it
13161315
// is the case
13171316
StringRef TargetFunc = Func->getTargetFuncName();
1318-
if (!TargetFunc.empty())
1317+
if (!TargetFunc.empty()) {
1318+
Ops.push_back(getDebugInfoNoneId());
13191319
Ops.push_back(BM->getString(TargetFunc.str())->getId());
1320+
}
13201321
}
13211322
}
13221323

llvm-spirv/test/DebugInfo/DebugFunction.cl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// even if in LLVM IR it points to a DIFile instead of DICompileUnit.
66

77
// RUN: %clang_cc1 %s -cl-std=clc++ -emit-llvm-bc -triple spir -debug-info-kind=line-tables-only -O0 -o - | llvm-spirv -o %t.spv
8+
// RUN: spirv-val %t.spv
89
// RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
910
// RUN: llvm-spirv -r %t.spv -o - | llvm-dis -o - | FileCheck %s --check-prefix=CHECK-LLVM
1011

@@ -18,8 +19,8 @@ void kernel k() {
1819
// CHECK-SPIRV: String [[foo:[0-9]+]] "foo"
1920
// CHECK-SPIRV: String [[k:[0-9]+]] "k"
2021
// CHECK-SPIRV: [[CU:[0-9]+]] {{[0-9]+}} DebugCompilationUnit
21-
// CHECK-SPIRV: DebugFunction [[foo]] {{.*}} [[CU]] {{.*}} [[foo_id:[0-9]+]] {{[0-9]+}} {{$}}
22-
// CHECK-SPIRV: DebugFunction [[k]] {{.*}} [[CU]] {{.*}} [[k_id:[0-9]+]] {{[0-9]+}} {{$}}
22+
// CHECK-SPIRV: DebugFunction [[foo]] {{.*}} [[CU]] {{.*}} [[foo_id:[0-9]+]] {{$}}
23+
// CHECK-SPIRV: DebugFunction [[k]] {{.*}} [[CU]] {{.*}} [[k_id:[0-9]+]] {{$}}
2324

2425
// CHECK-SPIRV: Function {{[0-9]+}} [[foo_id]]
2526
// CHECK-LLVM: define spir_func float @_Z3fooi(i32 %i) #{{[0-9]+}} !dbg !{{[0-9]+}} {

0 commit comments

Comments
 (0)