Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/DebugInfo/X86/constant-aggregate.ll

raw
1 ; RUN: llvm-as < %s -o %t.bc
2 ; RUN: llvm-spirv %t.bc -o %t.spv
3 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o - | llvm-dis -o %t.ll
4
5 ; RUN: llc -mtriple=%triple %t.ll -filetype=obj -o %t.o
6 ; RUN: llvm-dwarfdump -v -debug-info %t.o | FileCheck %s
7 ; Test emitting a constant for an aggregate type.
8 ;
9 ; clang -S -O1 -emit-llvm
10 ;
11 ; typedef struct { unsigned i; } S;
12 ;
13 ; unsigned foo(S s) {
14 ; s.i = 1;
15 ; return s.i;
16 ; }
17 ;
18 ; class C { public: unsigned i; };
19 ;
20 ; unsigned foo(C c) {
21 ; c.i = 2;
22 ; return c.i;
23 ; }
24 ;
25 ; unsigned bar() {
26 ; int a[1] = { 3 };
27 ; return a[0];
28 ; }
29 ;
30 ; CHECK: DW_TAG_formal_parameter
31 ; CHECK-NEXT: DW_AT_const_value [DW_FORM_udata] (1)
32 ; CHECK-NEXT: DW_AT_name {{.*}} "s"
33 ;
34 ; CHECK: DW_TAG_formal_parameter
35 ; CHECK-NEXT: DW_AT_const_value [DW_FORM_udata] (2)
36 ; CHECK-NEXT: DW_AT_name {{.*}} "c"
37 ;
38 ; CHECK: DW_TAG_variable
39 ; CHECK-NEXT: DW_AT_const_value [DW_FORM_udata] (3)
40 ; CHECK-NEXT: DW_AT_name {{.*}} "a"
41
42 ; ModuleID = 'sroasplit-4.cpp'
43 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
44 target triple = "spir64-unknown-unknown"
45
46 ; Function Attrs: nounwind readnone ssp uwtable
47 define i32 @_Z3foo1S(i32 %s.coerce) #0 !dbg !12 {
48 entry:
49 tail call void @llvm.dbg.value(metadata i32 %s.coerce, metadata !18, metadata !37), !dbg !38
50 tail call void @llvm.dbg.value(metadata i32 1, metadata !18, metadata !37), !dbg !38
51 ret i32 1, !dbg !39
52 }
53
54 ; Function Attrs: nounwind readnone ssp uwtable
55 define i32 @_Z3foo1C(i32 %c.coerce) #0 !dbg !19 {
56 entry:
57 tail call void @llvm.dbg.value(metadata i32 %c.coerce, metadata !23, metadata !37), !dbg !40
58 tail call void @llvm.dbg.value(metadata i32 2, metadata !23, metadata !37), !dbg !40
59 ret i32 2, !dbg !41
60 }
61
62 ; Function Attrs: nounwind readnone ssp uwtable
63 define i32 @_Z3barv() #0 !dbg !24 {
64 entry:
65 tail call void @llvm.dbg.value(metadata i32 3, metadata !28, metadata !37), !dbg !42
66 ret i32 3, !dbg !43
67 }
68
69 ; Function Attrs: nounwind readnone
70 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
71
72 attributes #0 = { nounwind readnone ssp uwtable }
73 attributes #1 = { nounwind readnone }
74
75 !llvm.dbg.cu = !{!0}
76 !llvm.module.flags = !{!33, !34, !35}
77 !llvm.ident = !{!36}
78
79 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.6.0 (trunk 225364) (llvm/trunk 225366)", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !2, imports: !2)
80 !1 = !DIFile(filename: "sroasplit-4.cpp", directory: "")
81 !2 = !{}
82 !3 = !{!4, !8}
83 !4 = !DICompositeType(tag: DW_TAG_structure_type, line: 1, size: 32, align: 32, file: !1, elements: !5, identifier: "_ZTS1S")
84 !5 = !{!6}
85 !6 = !DIDerivedType(tag: DW_TAG_member, name: "i", line: 1, size: 32, align: 32, file: !1, scope: !4, baseType: !7)
86 !7 = !DIBasicType(tag: DW_TAG_base_type, name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned)
87 !8 = !DICompositeType(tag: DW_TAG_class_type, name: "C", line: 8, size: 32, align: 32, file: !1, elements: !9, identifier: "_ZTS1C")
88 !9 = !{!10}
89 !10 = !DIDerivedType(tag: DW_TAG_member, name: "i", line: 8, size: 32, align: 32, flags: DIFlagPublic, file: !1, scope: !8, baseType: !7)
90 !12 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foo1S", line: 3, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 3, file: !1, scope: !13, type: !14, retainedNodes: !17)
91 !13 = !DIFile(filename: "sroasplit-4.cpp", directory: "")
92 !14 = !DISubroutineType(types: !15)
93 !15 = !{!7, !16}
94 !16 = !DIDerivedType(tag: DW_TAG_typedef, name: "S", line: 1, file: !1, baseType: !4)
95 !17 = !{!18}
96 !18 = !DILocalVariable(name: "s", line: 3, arg: 1, scope: !12, file: !13, type: !16)
97 !19 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foo1C", line: 10, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 10, file: !1, scope: !13, type: !20, retainedNodes: !22)
98 !20 = !DISubroutineType(types: !21)
99 !21 = !{!7, !8}
100 !22 = !{!23}
101 !23 = !DILocalVariable(name: "c", line: 10, arg: 1, scope: !19, file: !13, type: !8)
102 !24 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", line: 15, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 15, file: !1, scope: !13, type: !25, retainedNodes: !27)
103 !25 = !DISubroutineType(types: !26)
104 !26 = !{!7}
105 !27 = !{!28}
106 !28 = !DILocalVariable(name: "a", line: 16, scope: !24, file: !13, type: !29)
107 !29 = !DICompositeType(tag: DW_TAG_array_type, size: 32, align: 32, baseType: !30, elements: !31)
108 !30 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
109 !31 = !{!32}
110 !32 = !DISubrange(count: 1)
111 !33 = !{i32 2, !"Dwarf Version", i32 2}
112 !34 = !{i32 2, !"Debug Info Version", i32 3}
113 !35 = !{i32 1, !"PIC Level", i32 2}
114 !36 = !{!"clang version 3.6.0 (trunk 225364) (llvm/trunk 225366)"}
115 !37 = !DIExpression()
116 !38 = !DILocation(line: 3, column: 16, scope: !12)
117 !39 = !DILocation(line: 5, column: 3, scope: !12)
118 !40 = !DILocation(line: 10, column: 16, scope: !19)
119 !41 = !DILocation(line: 12, column: 3, scope: !19)
120 !42 = !DILocation(line: 16, column: 6, scope: !24)
121 !43 = !DILocation(line: 17, column: 3, scope: !24)