|
| 1 | +; RUN: llc -stop-before=finalize-isel -o - %s -mtriple=i386-- | FileCheck %s --check-prefix=MIR |
| 2 | +; RUN: llc -o - %s -mtriple=i386-- --filetype=obj | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF --implicit-check-not=DW_TAG_subprogram |
| 3 | +; REQUIRES: object-emission |
| 4 | +; |
| 5 | +; Test that, when arguments are passed on the stack (such as i386), |
| 6 | +; variable location dereferences occur in the right place. When referring to |
| 7 | +; argument stack slots a deref must be used to load the slot first. |
| 8 | + |
| 9 | +; MIR: ![[FOOVAR:[0-9]+]] = !DILocalVariable(name: "foovar" |
| 10 | +; MIR: ![[BARVAR:[0-9]+]] = !DILocalVariable(name: "barvar" |
| 11 | +; MIR: ![[BAZVAR:[0-9]+]] = !DILocalVariable(name: "bazvar" |
| 12 | + |
| 13 | +; Plain i32 on the stack. |
| 14 | +; MIR-LABEL: name: foo |
| 15 | +; MIR: DBG_VALUE %fixed-stack.0, $noreg, ![[FOOVAR]], |
| 16 | +; MIR-SAME: !DIExpression(DW_OP_deref) |
| 17 | +; DWARF: DW_TAG_subprogram |
| 18 | +; DWARF-LABEL: DW_AT_name ("cheese") |
| 19 | +; DWARF: DW_TAG_variable |
| 20 | +; DWARF-NEXT: DW_AT_location (DW_OP_fbreg +4) |
| 21 | +; DWARF-NEXT: DW_AT_name ("foovar") |
| 22 | +define i8 @foo(i32 %blah) !dbg !20 { |
| 23 | +entry: |
| 24 | + call void @llvm.dbg.value(metadata i32 %blah, metadata !23, metadata !DIExpression()), !dbg !21 |
| 25 | + ret i8 0, !dbg !21 |
| 26 | +} |
| 27 | + |
| 28 | +; Pointer on the stack that we fiddle with. |
| 29 | +; MIR-LABEL: name: bar |
| 30 | +; MIR: DBG_VALUE %fixed-stack.0, $noreg, ![[BARVAR]], |
| 31 | +; MIR-SAME: !DIExpression(DW_OP_deref_size, 4, DW_OP_plus_uconst, 4, DW_OP_stack_value) |
| 32 | +; DWARF: DW_TAG_subprogram |
| 33 | +; DWARF-LABEL: DW_AT_name ("nope") |
| 34 | +; DWARF: DW_TAG_variable |
| 35 | +; DWARF-NEXT: DW_AT_location (DW_OP_fbreg +4, DW_OP_deref_size 0x4, DW_OP_plus_uconst 0x4, DW_OP_stack_value) |
| 36 | +; DWARF-NEXT: DW_AT_name ("barvar") |
| 37 | +define i8 @bar(i32 *%blah) !dbg !30 { |
| 38 | +entry: |
| 39 | + call void @llvm.dbg.value(metadata i32* %blah, metadata !33, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value)), !dbg !31 |
| 40 | + ret i8 0, !dbg !31 |
| 41 | +} |
| 42 | + |
| 43 | +; Pointer that we use as a dbg.declare variable location, after fiddling with |
| 44 | +; the pointer value. |
| 45 | +; MIR-LABEL: name: baz |
| 46 | +; MIR: DBG_VALUE %fixed-stack.0, $noreg, ![[BAZVAR]], |
| 47 | +; MIR-SAME: !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 4, DW_OP_deref) |
| 48 | +; DWARF: DW_TAG_subprogram |
| 49 | +; DWARF-LABEL: DW_AT_name ("brains") |
| 50 | +; DWARF: DW_TAG_variable |
| 51 | +; DWARF-NEXT: DW_AT_location (DW_OP_fbreg +4, DW_OP_deref, DW_OP_plus_uconst 0x4) |
| 52 | +; DWARF-NEXT: DW_AT_name ("bazvar") |
| 53 | +define i8 @baz(i32 *%blah) !dbg !40 { |
| 54 | +entry: |
| 55 | + call void @llvm.dbg.declare(metadata i32* %blah, metadata !43, metadata !DIExpression(DW_OP_plus_uconst, 4)), !dbg !41 |
| 56 | + ret i8 0, !dbg !41 |
| 57 | +} |
| 58 | + |
| 59 | +declare void @llvm.dbg.value(metadata, metadata, metadata) |
| 60 | +declare void @llvm.dbg.declare(metadata, metadata, metadata) |
| 61 | + |
| 62 | +!llvm.dbg.cu = !{!0} |
| 63 | +!llvm.module.flags = !{!5} |
| 64 | + |
| 65 | +!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "asdf", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) |
| 66 | +!1 = !DIFile(filename: "nil", directory: "/") |
| 67 | +!2 = !{} |
| 68 | +!5 = !{i32 2, !"Debug Info Version", i32 3} |
| 69 | +!7 = !DISubroutineType(types: !2) |
| 70 | +!8 = !DIBasicType(name: "i32", size: 32, encoding: DW_ATE_signed) |
| 71 | + |
| 72 | +!20 = distinct !DISubprogram(name: "cheese", linkageName: "cheese", scope: null, file: !1, line: 12, type: !7, isLocal: false, isDefinition: true, scopeLine: 12, isOptimized: true, unit: !0, retainedNodes: !22) |
| 73 | +!21 = !DILocation(line: 1, column: 1, scope: !20) |
| 74 | +!22 = !{!23} |
| 75 | +!23 = !DILocalVariable(name: "foovar", scope: !20, file: !1, line: 14, type: !8) |
| 76 | + |
| 77 | +!30 = distinct !DISubprogram(name: "nope", linkageName: "nope", scope: null, file: !1, line: 12, type: !7, isLocal: false, isDefinition: true, scopeLine: 12, isOptimized: true, unit: !0, retainedNodes: !32) |
| 78 | +!31 = !DILocation(line: 1, column: 1, scope: !30) |
| 79 | +!32 = !{!33} |
| 80 | +!33 = !DILocalVariable(name: "barvar", scope: !30, file: !1, line: 14, type: !8) |
| 81 | + |
| 82 | +!40 = distinct !DISubprogram(name: "brains", linkageName: "brains", scope: null, file: !1, line: 12, type: !7, isLocal: false, isDefinition: true, scopeLine: 12, isOptimized: true, unit: !0, retainedNodes: !42) |
| 83 | +!41 = !DILocation(line: 1, column: 1, scope: !40) |
| 84 | +!42 = !{!43} |
| 85 | +!43 = !DILocalVariable(name: "bazvar", scope: !40, file: !1, line: 14, type: !8) |
0 commit comments