Skip to content

Commit 22a99e0

Browse files
LU-JOHNsys-ce-bb
authored andcommitted
Test Value field in SPIRV TypeMember (#2289)
Signed-off-by: Lu, John <[email protected]> Original commit: KhronosGroup/SPIRV-LLVM-Translator@42788c2
1 parent e1b0fd9 commit 22a99e0

File tree

2 files changed

+81
-2
lines changed

2 files changed

+81
-2
lines changed

llvm-spirv/lib/SPIRV/LLVMToSPIRVDbgTran.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,6 @@ LLVMToSPIRVDbgTran::transDbgMemberTypeOpenCL(const DIDerivedType *MT) {
10191019
Ops.push_back(Val->getId());
10201020
}
10211021
}
1022-
if (isNonSemanticDebugInfo())
1023-
transformToConstant(Ops, {LineIdx, ColumnIdx, FlagsIdx});
10241022
return BM->addDebugInfo(SPIRVDebug::TypeMember, getVoidTy(), Ops);
10251023
}
10261024

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
; Exercise Value field in SPIRV TypeMember.
2+
; It is used to preserve DIDerivedType's extraData argument in
3+
; LLVM IR when a DIFlagStaticMember is present.
4+
5+
; Original *.cpp source
6+
;
7+
; namespace {
8+
; struct anon_static_decl_struct {
9+
; static const int anon_static_decl_var = 117 + 234;
10+
; };
11+
; }
12+
; int ref() {
13+
; return anon_static_decl_struct::anon_static_decl_var;
14+
; }
15+
16+
; RUN: llvm-as %s -o %t.bc
17+
18+
; RUN: llvm-spirv -o %t.spt %t.bc -spirv-text
19+
; RUN: FileCheck %s --input-file %t.spt --check-prefix CHECK-SPIRV
20+
; RUN: llvm-spirv -o %t.spv %t.bc
21+
; RUN: llvm-spirv -r -o %t.rev.bc %t.spv
22+
; RUN: llvm-dis %t.rev.bc -o %t.rev.ll
23+
; RUN: FileCheck %s --input-file %t.rev.ll --check-prefix CHECK-LLVM
24+
25+
; RUN: llvm-spirv -o %t.100.spt %t.bc --spirv-debug-info-version=nonsemantic-shader-100 -spirv-text
26+
; RUN: FileCheck %s --input-file %t.100.spt --check-prefix CHECK-SPIRV-NONSEMANTIC
27+
; RUN: llvm-spirv -o %t.100.spv %t.bc --spirv-debug-info-version=nonsemantic-shader-100
28+
; RUN: llvm-spirv -r -o %t.100.rev.bc %t.100.spv
29+
; RUN: llvm-dis %t.100.rev.bc -o %t.100.rev.ll
30+
; RUN: FileCheck %s --input-file %t.100.rev.ll --check-prefix CHECK-LLVM
31+
32+
; RUN: llvm-spirv -o %t.200.spt %t.bc --spirv-debug-info-version=nonsemantic-shader-200 -spirv-text
33+
; RUN: FileCheck %s --input-file %t.200.spt --check-prefix CHECK-SPIRV-NONSEMANTIC
34+
; RUN: llvm-spirv -o %t.200.spv %t.bc --spirv-debug-info-version=nonsemantic-shader-200
35+
; RUN: llvm-spirv -r -o %t.200.rev.bc %t.200.spv
36+
; RUN: llvm-dis %t.200.rev.bc -o %t.200.rev.ll
37+
; RUN: FileCheck %s --input-file %t.200.rev.ll --check-prefix CHECK-LLVM
38+
39+
; CHECK-SPIRV: Constant [[#]] [[#VALUE:]] 351
40+
; CHECK-SPIRV: DebugTypeMember [[#NAME:]] [[#TYPE:]] [[#SOURCE:]] [[#LINE:]] [[#COLUMN:]] [[#PARENT:]] [[#OFFSET:]] [[#SIZE:]] [[#FLAGS:]] [[#VALUE:]] {{$}}
41+
42+
; CHECK-SPIRV-NONSEMANTIC: Constant [[#]] [[#VALUE:]] 351
43+
; CHECK-SPIRV-NONSEMANTIC: DebugTypeMember [[#NAME:]] [[#TYPE:]] [[#SOURCE:]] [[#LINE:]] [[#COLUMN:]] [[#OFFSET:]] [[#SIZE:]] [[#FLAGS:]] [[#VALUE:]] {{$}}
44+
45+
; CHECK-LLVM: !DIDerivedType(tag: DW_TAG_member, name: "anon_static_decl_var", scope: ![[#]], file: ![[#]], line: 5, baseType: ![[#]], flags: {{.*}}DIFlagStaticMember{{.*}}, extraData: i32 351)
46+
47+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
48+
target triple = "spirv-unknown-unknown"
49+
50+
; Function Attrs: mustprogress noinline nounwind optnone uwtable
51+
define dso_local noundef i32 @_Z3refv() !dbg !18 {
52+
entry:
53+
ret i32 351, !dbg !21
54+
}
55+
56+
!llvm.dbg.cu = !{!0}
57+
!llvm.module.flags = !{!12, !13, !14, !15, !16}
58+
!llvm.ident = !{!17}
59+
60+
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang based Intel(R) oneAPI DPC++/C++ Compiler 2024.1.0 (2024.x.0.YYYYMMDD)", isOptimized: false, flags: " --driver-mode=g++ --intel -g -emit-llvm test.cpp -c -fveclib=SVML -faltmathlib=SVML -fheinous-gnu-extensions", runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !2, globals: !9, splitDebugInlining: false, nameTableKind: None)
61+
!1 = !DIFile(filename: "test.cpp", directory: "/testdir")
62+
!2 = !{!3}
63+
!3 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "anon_static_decl_struct", scope: !4, file: !1, line: 4, size: 8, flags: DIFlagTypePassByValue, elements: !5)
64+
!4 = !DINamespace(scope: null)
65+
!5 = !{!6}
66+
!6 = !DIDerivedType(tag: DW_TAG_member, name: "anon_static_decl_var", scope: !3, file: !1, line: 5, baseType: !7, flags: DIFlagStaticMember, extraData: i32 351)
67+
!7 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)
68+
!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
69+
!9 = !{!10}
70+
!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression(DW_OP_constu, 351, DW_OP_stack_value))
71+
!11 = distinct !DIGlobalVariable(name: "anon_static_decl_var", scope: !0, file: !1, line: 5, type: !7, isLocal: true, isDefinition: true, declaration: !6)
72+
!12 = !{i32 7, !"Dwarf Version", i32 4}
73+
!13 = !{i32 2, !"Debug Info Version", i32 3}
74+
!14 = !{i32 1, !"wchar_size", i32 4}
75+
!15 = !{i32 7, !"uwtable", i32 2}
76+
!16 = !{i32 7, !"frame-pointer", i32 2}
77+
!17 = !{!"Intel(R) oneAPI DPC++/C++ Compiler 2024.1.0 (2024.x.0.YYYYMMDD)"}
78+
!18 = distinct !DISubprogram(name: "ref", linkageName: "_Z3refv", scope: !1, file: !1, line: 11, type: !19, scopeLine: 11, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
79+
!19 = !DISubroutineType(types: !20)
80+
!20 = !{!8}
81+
!21 = !DILocation(line: 12, column: 3, scope: !18)

0 commit comments

Comments
 (0)