David Blaikie | 3656123 | 2013-06-24 06:47:22 +0000 | [diff] [blame] | 1 | ; REQUIRES: object-emission |
| 2 | |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 3 | ; RUN: %llc_dwarf -O0 -filetype=obj < %s > %t |
Adrian Prantl | 16aa4cf | 2017-09-11 23:05:20 +0000 | [diff] [blame] | 4 | ; RUN: llvm-dwarfdump -v %t | FileCheck %s |
David Blaikie | 3656123 | 2013-06-24 06:47:22 +0000 | [diff] [blame] | 5 | |
| 6 | ; IR generated from the following code compiled with clang -g: |
| 7 | ; enum e1 { I, J = 0xffffffffU, K = 0xf000000000000000ULL } a; |
| 8 | ; enum e2 { X }; |
| 9 | ; void func() { |
| 10 | ; int b = X; |
| 11 | ; } |
| 12 | |
| 13 | ; These values were previously being truncated to -1 and 0 respectively. |
| 14 | |
| 15 | ; CHECK: debug_info contents |
| 16 | ; CHECK: DW_TAG_enumeration_type |
| 17 | ; CHECK-NEXT: DW_AT_name{{.*}} = "e1" |
| 18 | ; CHECK-NOT: NULL |
| 19 | ; CHECK: DW_TAG_enumerator |
| 20 | ; CHECK-NOT: NULL |
| 21 | ; CHECK: DW_TAG_enumerator |
| 22 | ; CHECK-NEXT: DW_AT_name{{.*}} = "J" |
| 23 | ; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata] (4294967295) |
| 24 | ; CHECK-NOT: NULL |
| 25 | ; CHECK: DW_TAG_enumerator |
| 26 | ; CHECK-NEXT: DW_AT_name{{.*}} = "K" |
| 27 | ; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata] (-1152921504606846976) |
| 28 | |
| 29 | ; Check that we retain enums that aren't referenced by any variables, etc |
| 30 | ; CHECK: DW_TAG_enumeration_type |
| 31 | ; CHECK-NEXT: DW_AT_name{{.*}} = "e2" |
| 32 | ; CHECK-NOT: NULL |
| 33 | ; CHECK: DW_TAG_enumerator |
| 34 | ; CHECK-NEXT: DW_AT_name{{.*}} = "X" |
| 35 | |
Adrian Prantl | 1eadba1 | 2016-12-22 00:45:21 +0000 | [diff] [blame] | 36 | source_filename = "test/DebugInfo/Generic/enum.ll" |
| 37 | |
| 38 | @a = global i64 0, align 8, !dbg !0 |
David Blaikie | 3656123 | 2013-06-24 06:47:22 +0000 | [diff] [blame] | 39 | |
| 40 | ; Function Attrs: nounwind uwtable |
Adrian Prantl | 1eadba1 | 2016-12-22 00:45:21 +0000 | [diff] [blame] | 41 | define void @_Z4funcv() #0 !dbg !17 { |
David Blaikie | 3656123 | 2013-06-24 06:47:22 +0000 | [diff] [blame] | 42 | entry: |
| 43 | %b = alloca i32, align 4 |
Adrian Prantl | 1eadba1 | 2016-12-22 00:45:21 +0000 | [diff] [blame] | 44 | call void @llvm.dbg.declare(metadata i32* %b, metadata !20, metadata !22), !dbg !23 |
| 45 | store i32 0, i32* %b, align 4, !dbg !23 |
| 46 | ret void, !dbg !24 |
David Blaikie | 3656123 | 2013-06-24 06:47:22 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | ; Function Attrs: nounwind readnone |
Adrian Prantl | 87b7eb9 | 2014-10-01 18:55:02 +0000 | [diff] [blame] | 50 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 |
David Blaikie | 3656123 | 2013-06-24 06:47:22 +0000 | [diff] [blame] | 51 | |
Bill Wendling | 187d3dd | 2013-08-22 21:28:54 +0000 | [diff] [blame] | 52 | 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" } |
David Blaikie | 3656123 | 2013-06-24 06:47:22 +0000 | [diff] [blame] | 53 | attributes #1 = { nounwind readnone } |
| 54 | |
Adrian Prantl | 1eadba1 | 2016-12-22 00:45:21 +0000 | [diff] [blame] | 55 | !llvm.dbg.cu = !{!8} |
| 56 | !llvm.module.flags = !{!15, !16} |
David Blaikie | 3656123 | 2013-06-24 06:47:22 +0000 | [diff] [blame] | 57 | |
Adrian Prantl | 0578221 | 2017-08-30 18:06:51 +0000 | [diff] [blame] | 58 | !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) |
Adrian Prantl | 1eadba1 | 2016-12-22 00:45:21 +0000 | [diff] [blame] | 59 | !1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true) |
| 60 | !2 = !DIFile(filename: "enum.cpp", directory: "/tmp") |
| 61 | !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "e1", file: !2, line: 1, size: 64, align: 64, elements: !4) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 62 | !4 = !{!5, !6, !7} |
Adrian Prantl | 1eadba1 | 2016-12-22 00:45:21 +0000 | [diff] [blame] | 63 | !5 = !DIEnumerator(name: "I", value: 0) |
| 64 | !6 = !DIEnumerator(name: "J", value: 4294967295) ; [ DW_TAG_enumerator ] [I :: 0] |
| 65 | !7 = !DIEnumerator(name: "K", value: -1152921504606846976) ; [ DW_TAG_enumerator ] [J :: 4294967295] |
| 66 | !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] |
| 67 | !9 = !{!3, !10} |
| 68 | !10 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "e2", file: !2, line: 2, size: 32, align: 32, elements: !11) |
| 69 | !11 = !{!12} |
| 70 | !12 = !DIEnumerator(name: "X", value: 0) ; [ DW_TAG_enumerator ] [X :: 0] |
| 71 | !13 = !{} |
| 72 | !14 = !{!0} |
| 73 | !15 = !{i32 2, !"Dwarf Version", i32 3} |
| 74 | !16 = !{i32 1, !"Debug Info Version", i32 3} |
Shiva Chen | 2c86455 | 2018-05-09 02:40:45 +0000 | [diff] [blame] | 75 | !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) |
Adrian Prantl | 1eadba1 | 2016-12-22 00:45:21 +0000 | [diff] [blame] | 76 | !18 = !DISubroutineType(types: !19) |
| 77 | !19 = !{null} |
| 78 | !20 = !DILocalVariable(name: "b", scope: !17, file: !2, line: 4, type: !21) |
| 79 | !21 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
| 80 | !22 = !DIExpression() |
| 81 | !23 = !DILocation(line: 4, scope: !17) |
| 82 | !24 = !DILocation(line: 5, scope: !17) |
| 83 | |