Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/DebugInfo/Generic/enum.ll

raw
1 ; REQUIRES: object-emission
2
3 ; RUN: llvm-as < %s -o %t.bc
4 ; RUN: llvm-spirv %t.bc -o %t.spv
5 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o - | llvm-dis -o %t.ll
6
7 ; RUN: llc -mtriple=%triple -O0 -filetype=obj < %t.ll > %t
8 ; RUN: llvm-dwarfdump -v %t | FileCheck %s
9
10 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
11 target triple = "spir64-unknown-unknown"
12
13 ; IR generated from the following code compiled with clang -g:
14 ; enum e1 { I, J = 0xffffffffU, K = 0xf000000000000000ULL } a;
15 ; enum e2 { X };
16 ; void func() {
17 ; int b = X;
18 ; }
19
20 ; These values were previously being truncated to -1 and 0 respectively.
21
22 ; CHECK: debug_info contents
23 ; CHECK: DW_TAG_enumeration_type
24 ; CHECK-NEXT: DW_AT_name{{.*}} = "e1"
25 ; CHECK-NOT: NULL
26 ; CHECK: DW_TAG_enumerator
27 ; CHECK-NOT: NULL
28 ; CHECK: DW_TAG_enumerator
29 ; CHECK-NEXT: DW_AT_name{{.*}} = "J"
30 ; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata] (4294967295)
31 ; CHECK-NOT: NULL
32 ; CHECK: DW_TAG_enumerator
33 ; CHECK-NEXT: DW_AT_name{{.*}} = "K"
34 ; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata] (-1152921504606846976)
35
36 ; Check that we retain enums that aren't referenced by any variables, etc
37 ; CHECK: DW_TAG_enumeration_type
38 ; CHECK-NEXT: DW_AT_name{{.*}} = "e2"
39 ; CHECK-NOT: NULL
40 ; CHECK: DW_TAG_enumerator
41 ; CHECK-NEXT: DW_AT_name{{.*}} = "X"
42
43 source_filename = "test/DebugInfo/Generic/enum.ll"
44
45 @a = global i64 0, align 8, !dbg !0
46
47 ; Function Attrs: nounwind uwtable
48 define void @_Z4funcv() #0 !dbg !17 {
49 entry:
50 %b = alloca i32, align 4
51 call void @llvm.dbg.declare(metadata i32* %b, metadata !20, metadata !22), !dbg !23
52 store i32 0, i32* %b, align 4, !dbg !23
53 ret void, !dbg !24
54 }
55
56 ; Function Attrs: nounwind readnone
57 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
58
59 attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
60 attributes #1 = { nounwind readnone }
61
62 !llvm.dbg.cu = !{!8}
63 !llvm.module.flags = !{!15, !16}
64
65 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
66 !1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
67 !2 = !DIFile(filename: "enum.cpp", directory: "/tmp")
68 !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "e1", file: !2, line: 1, size: 64, align: 64, elements: !4)
69 !4 = !{!5, !6, !7}
70 !5 = !DIEnumerator(name: "I", value: 0)
71 !6 = !DIEnumerator(name: "J", value: 4294967295) ; [ DW_TAG_enumerator ] [I :: 0]
72 !7 = !DIEnumerator(name: "K", value: -1152921504606846976) ; [ DW_TAG_enumerator ] [J :: 4294967295]
73 !8 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "clang version 3.4 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !9, retainedTypes: !13, globals: !14, imports: !13) ; [ DW_TAG_enumerator ] [K :: 17293822569102704640]
74 !9 = !{!3, !10}
75 !10 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "e2", file: !2, line: 2, size: 32, align: 32, elements: !11)
76 !11 = !{!12}
77 !12 = !DIEnumerator(name: "X", value: 0) ; [ DW_TAG_enumerator ] [X :: 0]
78 !13 = !{}
79 !14 = !{!0}
80 !15 = !{i32 2, !"Dwarf Version", i32 3}
81 !16 = !{i32 1, !"Debug Info Version", i32 3}
82 !17 = distinct !DISubprogram(name: "func", linkageName: "_Z4funcv", scope: !2, file: !2, line: 3, type: !18, isLocal: false, isDefinition: true, scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !8, retainedNodes: !13)
83 !18 = !DISubroutineType(types: !19)
84 !19 = !{null}
85 !20 = !DILocalVariable(name: "b", scope: !17, file: !2, line: 4, type: !21)
86 !21 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
87 !22 = !DIExpression()
88 !23 = !DILocation(line: 4, scope: !17)
89 !24 = !DILocation(line: 5, scope: !17)
90