1; RUN: %llc_dwarf -O0 -filetype=obj < %s > %t
2; RUN: llvm-dwarfdump -v %t | FileCheck %s
3
4; IR generated from the following code compiled with clang -g:
5; enum e1 { I, J = 0xffffffffU, K = 0xf000000000000000ULL } a;
6; enum e2 { X };
7; void func() {
8;   int b = X;
9; }
10
11; These values were previously being truncated to -1 and 0 respectively.
12
13; CHECK: debug_info contents
14; CHECK: DW_TAG_enumeration_type
15; CHECK-NEXT: DW_AT_name{{.*}} = "e1"
16; CHECK-NOT: NULL
17; CHECK: DW_TAG_enumerator
18; CHECK-NOT: NULL
19; CHECK: DW_TAG_enumerator
20; CHECK-NEXT: DW_AT_name{{.*}} = "J"
21; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata]     (4294967295)
22; CHECK-NOT: NULL
23; CHECK: DW_TAG_enumerator
24; CHECK-NEXT: DW_AT_name{{.*}} = "K"
25; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata]     (-1152921504606846976)
26
27; Check that we retain enums that aren't referenced by any variables, etc
28; CHECK: DW_TAG_enumeration_type
29; CHECK-NEXT: DW_AT_name{{.*}} = "e2"
30; CHECK-NOT: NULL
31; CHECK: DW_TAG_enumerator
32; CHECK-NEXT: DW_AT_name{{.*}} = "X"
33
34source_filename = "test/DebugInfo/Generic/enum.ll"
35
36@a = global i64 0, align 8, !dbg !0
37
38; Function Attrs: nounwind uwtable
39define void @_Z4funcv() #0 !dbg !17 {
40entry:
41  %b = alloca i32, align 4
42  call void @llvm.dbg.declare(metadata i32* %b, metadata !20, metadata !22), !dbg !23
43  store i32 0, i32* %b, align 4, !dbg !23
44  ret void, !dbg !24
45}
46
47; Function Attrs: nounwind readnone
48declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
49
50attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
51attributes #1 = { nounwind readnone }
52
53!llvm.dbg.cu = !{!8}
54!llvm.module.flags = !{!15, !16}
55
56!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
57!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
58!2 = !DIFile(filename: "enum.cpp", directory: "/tmp")
59!3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "e1", file: !2, line: 1, size: 64, align: 64, elements: !4)
60!4 = !{!5, !6, !7}
61!5 = !DIEnumerator(name: "I", value: 0)
62!6 = !DIEnumerator(name: "J", value: 4294967295) ; [ DW_TAG_enumerator ] [I :: 0]
63!7 = !DIEnumerator(name: "K", value: -1152921504606846976) ; [ DW_TAG_enumerator ] [J :: 4294967295]
64!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]
65!9 = !{!3, !10}
66!10 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "e2", file: !2, line: 2, size: 32, align: 32, elements: !11)
67!11 = !{!12}
68!12 = !DIEnumerator(name: "X", value: 0) ; [ DW_TAG_enumerator ] [X :: 0]
69!13 = !{}
70!14 = !{!0}
71!15 = !{i32 2, !"Dwarf Version", i32 3}
72!16 = !{i32 1, !"Debug Info Version", i32 3}
73!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)
74!18 = !DISubroutineType(types: !19)
75!19 = !{null}
76!20 = !DILocalVariable(name: "b", scope: !17, file: !2, line: 4, type: !21)
77!21 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
78!22 = !DIExpression()
79!23 = !DILocation(line: 4, scope: !17)
80!24 = !DILocation(line: 5, scope: !17)
81
82