1
+ ; Test checks debug info of basic type is preserved during LLVM IR to spirv
2
+ ; and spirv to LLVM IR translation.
3
+
4
+ ; Original .cpp source:
5
+ ; int main() {
6
+ ; return 0;
7
+ ; }
8
+
9
+ ; RUN: llvm-as %s -o %t.bc
10
+ ; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-OCL
11
+ ; RUN: llvm-spirv %t.bc -o %t.spv
12
+ ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
13
+ ; RUN: llvm-dis %t.rev.bc -o %t.rev.ll
14
+ ; RUN: FileCheck %s --input-file %t.rev.ll --check-prefix CHECK-LLVM
15
+
16
+ ; RUN: llvm-spirv %t.bc -spirv-text --spirv-debug-info-version=nonsemantic-shader-100 -o - | FileCheck %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-NONSEM
17
+ ; RUN: llvm-spirv %t.bc --spirv-debug-info-version=nonsemantic-shader-100 -o %t.spv
18
+ ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
19
+ ; RUN: llvm-dis %t.rev.bc -o %t.rev.ll
20
+ ; RUN: FileCheck %s --input-file %t.rev.ll --check-prefix CHECK-LLVM
21
+
22
+ ; CHECK-LLVM: !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
23
+
24
+ ; CHECK-SPIRV: String [[#Name:]] "int"
25
+ ; CHECK-SPIRV-NONSEM: Constant [[#]] [[#Encoding:]] 4
26
+ ; CHECK-SPIRV: Constant [[#]] [[#Size:]] 32
27
+ ; CHECK-SPIRV-OCL: DebugTypeBasic [[#Name]] [[#Size]] 4 {{$}}
28
+ ; CHECK-SPIRV-NONSEM: [[#Flags:]] [[#]] DebugInfoNone
29
+ ; CHECK-SPIRV-NONSEM: DebugTypeBasic [[#Name]] [[#Size]] [[#Encoding]] [[#Flags]] {{$}}
30
+
31
+ target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
32
+ target triple = "spir64-unknown-unknown"
33
+
34
+ ; Function Attrs: mustprogress noinline nounwind optnone uwtable
35
+ define dso_local noundef i32 @_Z3foov () #0 !dbg !10 {
36
+ ret i32 0 , !dbg !16
37
+ }
38
+
39
+ attributes #0 = { mustprogress noinline nounwind optnone uwtable "frame-pointer" ="all" "min-legal-vector-width" ="0" "no-trapping-math" ="true" "stack-protector-buffer-size" ="8" "target-cpu" ="x86-64" "target-features" ="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu" ="generic" }
40
+
41
+ !llvm.dbg.cu = !{!0 }
42
+ !llvm.module.flags = !{!2 , !3 , !4 , !5 , !6 , !7 , !8 }
43
+ !llvm.ident = !{!9 }
44
+
45
+ !0 = distinct !DICompileUnit (language: DW_LANG_C_plus_plus_14, file: !1 , producer: "clang version 17.0.0 (https://github.com/llvm/llvm-project.git b936816fb305cc16d2d1cd6d424c08c39a681a32)" , isOptimized: false , runtimeVersion: 0 , emissionKind: FullDebug, splitDebugInlining: false , nameTableKind: None)
46
+ !1 = !DIFile (filename: "/app/example.cpp" , directory: "/app" )
47
+ !2 = !{i32 7 , !"Dwarf Version" , i32 4 }
48
+ !3 = !{i32 2 , !"Debug Info Version" , i32 3 }
49
+ !4 = !{i32 1 , !"wchar_size" , i32 4 }
50
+ !5 = !{i32 8 , !"PIC Level" , i32 2 }
51
+ !6 = !{i32 7 , !"PIE Level" , i32 2 }
52
+ !7 = !{i32 7 , !"uwtable" , i32 2 }
53
+ !8 = !{i32 7 , !"frame-pointer" , i32 2 }
54
+ !9 = !{!"clang version 17.0.0 (https://github.com/llvm/llvm-project.git b936816fb305cc16d2d1cd6d424c08c39a681a32)" }
55
+ !10 = distinct !DISubprogram (name: "foo" , linkageName: "_Z3foov" , scope: !11 , file: !11 , line: 1 , type: !12 , scopeLine: 1 , flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0 , retainedNodes: !15 )
56
+ !11 = !DIFile (filename: "example.cpp" , directory: "/app" )
57
+ !12 = !DISubroutineType (types: !13 )
58
+ !13 = !{!14 }
59
+ !14 = !DIBasicType (name: "int" , size: 32 , encoding: DW_ATE_signed)
60
+ !15 = !{}
61
+ !16 = !DILocation (line: 1 , column: 13 , scope: !10 )
0 commit comments