Skip to content

Commit 2614860

Browse files
committed
[DebugInfo] Fix instruction enumeration
These two opcodes were mistakenly swapped when they were originally added, at least according to the `DebugInfo`, `OpenCL.DebugInfo.100`, and `NonSemantic.Shader.DebugInfo.100` extended instruction sets. This might break existing third-party SPIR-V translators if they are accommodating this bug, mistakenly or otherwise.
1 parent 3770469 commit 2614860

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

lib/SPIRV/libSPIRV/SPIRV.debug.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ enum Instruction {
3434
TypePtrToMember = 13,
3535
TypeTemplate = 14,
3636
TypeTemplateParameter = 15,
37-
TypeTemplateParameterPack = 16,
38-
TypeTemplateTemplateParameter = 17,
37+
TypeTemplateTemplateParameter = 16,
38+
TypeTemplateParameterPack = 17,
3939
GlobalVariable = 18,
4040
FunctionDeclaration = 19,
4141
Function = 20,
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
; This test checks that the decoding of DebugTypeTemplateParameterPack and
2+
; DebugTypeTemplateTemplateParameter is correct.
3+
4+
; REQUIRES: spirv-as
5+
6+
; RUN: spirv-as --target-env spv1.3 %s -o %t.spv
7+
; RUN: llvm-spirv -r %t.spv -o - | llvm-dis | FileCheck %s
8+
9+
; SPIR-V
10+
; Version: 1.1
11+
; Generator: Khronos LLVM/SPIR-V Translator; 14
12+
; Bound: 16
13+
; Schema: 0
14+
OpCapability Addresses
15+
OpCapability Kernel
16+
%1 = OpExtInstImport "OpenCL.std"
17+
%2 = OpExtInstImport "OpenCL.DebugInfo.100"
18+
OpMemoryModel Physical64 OpenCL
19+
OpEntryPoint Kernel %5 "func"
20+
%8 = OpString "/tmp/test.cpp"
21+
%9 = OpString "//__CSK_MD5:18aa9ce738eaafc7b7b7181c19092815"
22+
%12 = OpString "func"
23+
%14 = OpString ""
24+
%15 = OpString "T"
25+
%16 = OpString "U"
26+
%17 = OpString "Foo"
27+
OpSource OpenCL_CPP 100000
28+
OpName %entry "entry"
29+
%void = OpTypeVoid
30+
%4 = OpTypeFunction %void
31+
%10 = OpExtInst %void %2 DebugSource %8 %9
32+
%11 = OpExtInst %void %2 DebugCompilationUnit 65536 5 %10 OpenCL_CPP
33+
%13 = OpExtInst %void %2 DebugInfoNone
34+
%20 = OpExtInst %void %2 DebugFunction %12 %13 %10 1 0 %11 %14 FlagIsDefinition|FlagPrototyped|FlagIsOptimized 2 %5 %13
35+
%18 = OpExtInst %void %2 DebugTypeTemplateParameterPack %15 %10 0 0 %13 %13
36+
%19 = OpExtInst %void %2 DebugTypeTemplateTemplateParameter %16 %17 %10 0 0
37+
%21 = OpExtInst %void %2 DebugTypeTemplate %20 %18 %19
38+
%5 = OpFunction %void None %4
39+
%entry = OpLabel
40+
OpReturn
41+
OpFunctionEnd
42+
43+
; CHECK: = distinct !DISubprogram(name: "func",
44+
; CHECK-SAME: templateParams: [[TPARAMS:![0-9]+]]{{[,)]}}
45+
46+
; CHECK-DAG: [[TPARAMS]] = !{[[PACKPARAM:![0-9]+]], [[TTPARAM:![0-9]+]]}
47+
; CHECK-DAG: [[PACKPARAM]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_parameter_pack, name: "T", value: [[PACK:![0-9]+]])
48+
; CHECK-DAG: [[PACK]] = !{null, null}
49+
; CHECK-DAG: [[TTPARAM]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_template_param, name: "U", value: !"Foo")

0 commit comments

Comments
 (0)