Wolfgang Pieb | dfad9b2 | 2016-08-15 18:18:26 +0000 | [diff] [blame^] | 1 | ; REQUIRES: object-emission |
| 2 | |
| 3 | ; Check that when variables are allocated on the stack we generate debug locations |
| 4 | ; for the stack location directly instead of generating a register+offset indirection. |
| 5 | |
| 6 | ; RUN: %llc_dwarf -O2 -filetype=obj -disable-post-ra < %s | llvm-dwarfdump - | FileCheck %s |
| 7 | ; |
| 8 | ; int data = 17; |
| 9 | ; int sum = 0; |
| 10 | ; int zero = 0; |
| 11 | ; int *ptr; |
| 12 | ; |
| 13 | ; extern void foo(int i, int *p); |
| 14 | ; |
| 15 | ; int main() |
| 16 | ; { |
| 17 | ; int val; |
| 18 | ; val = data; |
| 19 | ; foo(1, &val); |
| 20 | ; foo(2, &data); |
| 21 | ; return zero; |
| 22 | ; } |
| 23 | ; |
| 24 | ; CHECK: .debug_info contents |
| 25 | ; CHECK: DW_TAG_subprogram |
| 26 | ; CHECK-NOT: NULL |
| 27 | ; CHECK: DW_TAG_variable |
| 28 | ; CHECK: DW_AT_location [DW_FORM_sec_offset] ([[DEBUGLOCOFFSET:0x[0-9a-f]+]]){{[[:space:]].*}}"val" |
| 29 | |
| 30 | ; See that 'val' has at least one location entry with a DW_op_breg? operand. |
| 31 | ; The DWARF DW_op_breg* ops are encoded from 0x70 to 0x8f, but checking for an |
| 32 | ; op in the range from 0x70 to 0x7f should suffice because that range covers |
| 33 | ; all integer GPRs. |
| 34 | ; |
| 35 | ; CHECK: .debug_loc contents: |
| 36 | ; CHECK-NOT: .debug{{.*}} contents |
| 37 | ; CHECK: [[DEBUGLOCOFFSET]]: Beginning |
| 38 | ; CHECK-NOT: {{0x[0-9a-f]+}}: Beginning |
| 39 | ; CHECK: Location description: 7{{[0-9a-f] .*}} |
| 40 | |
| 41 | ; ModuleID = 'frame.c' |
| 42 | source_filename = "frame.c" |
| 43 | |
| 44 | @data = global i32 17, align 4 |
| 45 | @sum = local_unnamed_addr global i32 0, align 4 |
| 46 | @zero = local_unnamed_addr global i32 0, align 4 |
| 47 | @ptr = common local_unnamed_addr global i32* null, align 8 |
| 48 | |
| 49 | ; Function Attrs: nounwind uwtable |
| 50 | define i32 @main() local_unnamed_addr !dbg !13 { |
| 51 | entry: |
| 52 | %val = alloca i32, align 4 |
| 53 | %0 = bitcast i32* %val to i8*, !dbg !18 |
| 54 | call void @llvm.lifetime.start(i64 4, i8* %0), !dbg !18 |
| 55 | %1 = load i32, i32* @data, align 4, !dbg !19, !tbaa !20 |
| 56 | tail call void @llvm.dbg.value(metadata i32 %1, i64 0, metadata !17, metadata !24), !dbg !25 |
| 57 | store i32 %1, i32* %val, align 4, !dbg !26, !tbaa !20 |
| 58 | tail call void @llvm.dbg.value(metadata i32* %val, i64 0, metadata !17, metadata !27), !dbg !25 |
| 59 | call void @foo(i32 1, i32* nonnull %val), !dbg !28 |
| 60 | call void @foo(i32 2, i32* nonnull @data), !dbg !29 |
| 61 | %2 = load i32, i32* @zero, align 4, !dbg !30, !tbaa !20 |
| 62 | call void @llvm.lifetime.end(i64 4, i8* %0), !dbg !31 |
| 63 | ret i32 %2, !dbg !32 |
| 64 | } |
| 65 | |
| 66 | ; Function Attrs: argmemonly nounwind |
| 67 | declare void @llvm.lifetime.start(i64, i8* nocapture) |
| 68 | |
| 69 | declare void @foo(i32, i32*) local_unnamed_addr |
| 70 | |
| 71 | ; Function Attrs: argmemonly nounwind |
| 72 | declare void @llvm.lifetime.end(i64, i8* nocapture) |
| 73 | |
| 74 | ; Function Attrs: nounwind readnone |
| 75 | declare void @llvm.dbg.value(metadata, i64, metadata, metadata) |
| 76 | |
| 77 | !llvm.dbg.cu = !{!0} |
| 78 | !llvm.module.flags = !{!10, !11} |
| 79 | !llvm.ident = !{!12} |
| 80 | |
| 81 | !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 (trunk 273961)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3) |
| 82 | !1 = !DIFile(filename: "frame.c", directory: "/home/user/test") |
| 83 | !2 = !{} |
| 84 | !3 = !{!4, !6, !7, !8} |
| 85 | !4 = distinct !DIGlobalVariable(name: "data", scope: !0, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, variable: i32* @data) |
| 86 | !5 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
| 87 | !6 = distinct !DIGlobalVariable(name: "sum", scope: !0, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, variable: i32* @sum) |
| 88 | !7 = distinct !DIGlobalVariable(name: "zero", scope: !0, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, variable: i32* @zero) |
| 89 | !8 = distinct !DIGlobalVariable(name: "ptr", scope: !0, file: !1, line: 4, type: !9, isLocal: false, isDefinition: true, variable: i32** @ptr) |
| 90 | !9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64, align: 64) |
| 91 | !10 = !{i32 2, !"Dwarf Version", i32 4} |
| 92 | !11 = !{i32 2, !"Debug Info Version", i32 3} |
| 93 | !12 = !{!"clang version 3.9.0 (trunk 273961)"} |
| 94 | !13 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 8, type: !14, isLocal: false, isDefinition: true, scopeLine: 9, isOptimized: true, unit: !0, variables: !16) |
| 95 | !14 = !DISubroutineType(types: !15) |
| 96 | !15 = !{!5} |
| 97 | !16 = !{!17} |
| 98 | !17 = !DILocalVariable(name: "val", scope: !13, file: !1, line: 10, type: !5) |
| 99 | !18 = !DILocation(line: 10, column: 3, scope: !13) |
| 100 | !19 = !DILocation(line: 11, column: 9, scope: !13) |
| 101 | !20 = !{!21, !21, i64 0} |
| 102 | !21 = !{!"int", !22, i64 0} |
| 103 | !22 = !{!"omnipotent char", !23, i64 0} |
| 104 | !23 = !{!"Simple C/C++ TBAA"} |
| 105 | !24 = !DIExpression() |
| 106 | !25 = !DILocation(line: 10, column: 7, scope: !13) |
| 107 | !26 = !DILocation(line: 11, column: 7, scope: !13) |
| 108 | !27 = !DIExpression(DW_OP_deref) |
| 109 | !28 = !DILocation(line: 12, column: 3, scope: !13) |
| 110 | !29 = !DILocation(line: 13, column: 3, scope: !13) |
| 111 | !30 = !DILocation(line: 14, column: 10, scope: !13) |
| 112 | !31 = !DILocation(line: 15, column: 1, scope: !13) |
| 113 | !32 = !DILocation(line: 14, column: 3, scope: !13) |