reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses the machine instruction's
# debug location metadata correctly.

--- |

  define i32 @test(i32 %x) #0 !dbg !4 {
  entry:
    %x.addr = alloca i32, align 4
    store i32 %x, i32* %x.addr, align 4
    call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !DIExpression()), !dbg !13
    %0 = load i32, i32* %x.addr, align 4, !dbg !14
    ret i32 %0, !dbg !14
  }

  define i32 @test_typed_immediates(i32 %x) #0 {
  entry:
    %x.addr = alloca i32, align 4
    store i32 %x, i32* %x.addr, align 4
    call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !DIExpression()), !dbg !13
    %0 = load i32, i32* %x.addr, align 4, !dbg !14
    ret i32 %0, !dbg !14
  }

  define i32 @test_mir_created(i32 %x) #0 !dbg !15 {
  entry:
    %x.addr = alloca i32, align 4
    store i32 %x, i32* %x.addr, align 4
    %0 = load i32, i32* %x.addr, align 4
    %1 = load i32, i32* %x.addr, align 4
    %2 = load i32, i32* %x.addr, align 4
    %3 = load i32, i32* %x.addr, align 4
    ret i32 %0, !dbg !16
  }

  declare void @llvm.dbg.declare(metadata, metadata, metadata) #1

  attributes #0 = { nounwind "no-frame-pointer-elim"="false" }
  attributes #1 = { nounwind readnone }

  !llvm.dbg.cu = !{!0}
  !llvm.module.flags = !{!9, !10}
  !llvm.ident = !{!11}

  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
  !1 = !DIFile(filename: "test.ll", directory: "")
  !2 = !{}
  !4 = distinct !DISubprogram(name: "test", scope: !5, file: !5, line: 4, type: !6, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
  !5 = !DIFile(filename: "test.c", directory: "")
  !6 = !DISubroutineType(types: !7)
  !7 = !{!8, !8}
  !8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
  !9 = !{i32 2, !"Dwarf Version", i32 4}
  !10 = !{i32 2, !"Debug Info Version", i32 3}
  !11 = !{!"clang version 3.7.0"}
  !12 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !5, line: 4, type: !8)
  !13 = !DILocation(line: 4, scope: !4)
  !14 = !DILocation(line: 8, scope: !4)
  !15 = distinct !DISubprogram(name: "test_mir_created", scope: !5, file: !5, line: 10, type: !6, isLocal: false, isDefinition: true, scopeLine: 10, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
  !16 = !DILocation(line: 20, scope: !15)

...
---
name:            test
tracksRegLiveness: true
registers:
  - { id: 0, class: gr32 }
frameInfo:
  maxAlignment:  4
stack:
  - { id: 0, name: x.addr, size: 4, alignment: 4 }
body: |
  bb.0.entry:
    liveins: $edi
    ; CHECK: DBG_VALUE $noreg, 0, !11, !DIExpression(), debug-location !12
    ; CHECK: DBG_VALUE $noreg, 0, !11, !DIExpression(), debug-location !12
    ; CHECK: $eax = COPY %0, debug-location !13
    ; CHECK: RETQ $eax, debug-location !13
    %0 = COPY $edi
    DBG_VALUE _, 0, !12, !DIExpression(), debug-location !13
    ; Test whether debug-use is still recognized for compatibility with old
    ; files.
    DBG_VALUE debug-use _, 0, !12, !DIExpression(), debug-location !13
    MOV32mr %stack.0.x.addr, 1, _, 0, _, %0
    $eax = COPY %0, debug-location !14
    RETQ $eax, debug-location !14
...
---
name:            test_typed_immediates
tracksRegLiveness: true
registers:
  - { id: 0, class: gr32 }
frameInfo:
  maxAlignment:  4
stack:
  - { id: 0, name: x.addr, size: 4, alignment: 4 }
body: |
  bb.0.entry:
    liveins: $edi

    %0 = COPY $edi
  ; CHECK:      DBG_VALUE $noreg, i32 0, !DIExpression(), !12
  ; CHECK-NEXT: DBG_VALUE $noreg, i64 -22, !DIExpression(), !12
  ; CHECK-NEXT: DBG_VALUE $noreg, i128 123492148938512984928424384934328985928, !DIExpression(), !12
    DBG_VALUE _, i32 0, !DIExpression(), !13
    DBG_VALUE _, i64 -22, !DIExpression(), !13
    DBG_VALUE _, i128 123492148938512984928424384934328985928, !DIExpression(), !13
    MOV32mr %stack.0.x.addr, 1, _, 0, _, %0
    $eax = COPY %0
    RETQ $eax
...
---
name:            test_mir_created
tracksRegLiveness: true
registers:
  - { id: 0, class: gr32 }
frameInfo:
  maxAlignment:  4
stack:
  - { id: 0, name: x.addr, size: 4, alignment: 4 }
body: |
  bb.0.entry:
    liveins: $edi

    %0 = COPY $edi
  ; CHECK-LABEL: name: test_mir_created
  ; CHECK:       MOV32mr %stack.0.x.addr, 1, $noreg, 0, $noreg, %0, debug-location !DILocation(line: 1, scope: !14)
  ; CHECK:       MOV32mr %stack.0.x.addr, 1, $noreg, 0, $noreg, %0, debug-location !DILocation(line: 2, column: 2, scope: !14)
  ; CHECK:       MOV32mr %stack.0.x.addr, 1, $noreg, 0, $noreg, %0, debug-location !DILocation(line: 3, column: 2, scope: !14, isImplicitCode: true)
  ; CHECK:       MOV32mr %stack.0.x.addr, 1, $noreg, 0, $noreg, %0, debug-location !DILocation(line: 4, scope: !14, inlinedAt: !15)
  ; CHECK:       MOV32mr %stack.0.x.addr, 1, $noreg, 0, $noreg, %0, debug-location !DILocation(line: 5, scope: !14, inlinedAt: !DILocation(line: 4, scope: !14))
    MOV32mr %stack.0.x.addr, 1, _, 0, _, %0, debug-location !DILocation(line: 1, scope: !15)
    MOV32mr %stack.0.x.addr, 1, _, 0, _, %0, debug-location !DILocation(line: 2, column: 2, scope: !15)
    MOV32mr %stack.0.x.addr, 1, _, 0, _, %0, debug-location !DILocation(line: 3, column: 2, scope: !15, isImplicitCode: true)
    MOV32mr %stack.0.x.addr, 1, _, 0, _, %0, debug-location !DILocation(line: 4, scope: !15, inlinedAt: !16)
    MOV32mr %stack.0.x.addr, 1, _, 0, _, %0, debug-location !DILocation(line: 5, scope: !15, inlinedAt: !DILocation(line: 4, scope: !15))
    $eax = COPY %0
    RETQ $eax
...