locations-and-values.mir 2.49 KB
# RUN: llc -run-pass=mir-debugify -o - %s | FileCheck --check-prefixes=ALL,VALUE %s
# RUN: llc -run-pass=mir-debugify -debugify-level=locations -o - %s | FileCheck --check-prefixes=ALL --implicit-check-not=dbg.value %s
# RUN: llc -run-pass=mir-debugify,mir-strip-debug,mir-debugify -o - %s | FileCheck --check-prefixes=ALL,VALUE %s
--- |
  ; ModuleID = 'loc-only.ll'
  source_filename = "loc-only.ll"
  
  ; ALL-LABEL: @test
  define i32 @test(i32 %a, i32 %b) {
    %add = add i32 %a, 2
  ; ALL-NEXT:  %add = add i32 %a, 2, !dbg [[L1:![0-9]+]]
  ; VALUE-NEXT: call void @llvm.dbg.value(metadata i32 %add, metadata [[add:![0-9]+]], metadata !DIExpression()), !dbg [[L1]]
    %sub = sub i32 %add, %b
  ; ALL-NEXT: %sub = sub i32 %add, %b, !dbg [[L2:![0-9]+]]
  ; VALUE-NEXT: call void @llvm.dbg.value(metadata i32 %sub, metadata [[sub:![0-9]+]], metadata !DIExpression()), !dbg [[L2]]
  ; ALL-NEXT: ret i32 %sub, !dbg [[L3:![0-9]+]]
    ret i32 %sub
  }

  ; ALL: !llvm.dbg.cu = !{!0}
  ; ALL: !llvm.debugify =
  ; ALL: !llvm.module.flags = !{![[VERSION:[0-9]+]]}
  ; ALL: !0 = distinct !DICompileUnit(
  ; ALL: ![[VERSION]] = !{i32 2, !"Debug Info Version", i32 3}
  ; VALUE: [[VAR1:![0-9]+]] = !DILocalVariable(name: "1"
  ; VALUE: [[VAR2:![0-9]+]] = !DILocalVariable(name: "2"

...
---
name:            test
body:             |
  bb.1 (%ir-block.0):
    %0:_(s32) = IMPLICIT_DEF
    %1:_(s32) = IMPLICIT_DEF
    %2:_(s32) = G_CONSTANT i32 2
    %3:_(s32) = G_ADD %0, %2
    %4:_(s32) = G_SUB %3, %1
    ; There's no attempt to have the locations make sense as it's an imaginary
    ; source file anyway. These first three coincide with IR-level information
    ; and therefore use metadata references.
    ; ALL: %0:_(s32) = IMPLICIT_DEF debug-location [[L1]]
    ; VALUE: DBG_VALUE %0(s32), $noreg, [[VAR1]], !DIExpression(), debug-location [[L1]]
    ; ALL: %1:_(s32) = IMPLICIT_DEF debug-location [[L2]]
    ; VALUE: DBG_VALUE %1(s32), $noreg, [[VAR2]], !DIExpression(), debug-location [[L2]]
    ; ALL: %2:_(s32) = G_CONSTANT i32 2, debug-location [[L3]]
    ; VALUE: DBG_VALUE %2(s32), $noreg, [[VAR1]], !DIExpression(), debug-location [[L3]]
    ; ALL: %3:_(s32) = G_ADD %0, %2, debug-location !DILocation(line: 4, column: 1, scope: !6)
    ; VALUE: DBG_VALUE %3(s32), $noreg, [[VAR1]], !DIExpression(), debug-location !DILocation(line: 4
    ; ALL: %4:_(s32) = G_SUB %3, %1, debug-location !DILocation(line: 5, column: 1, scope: !6)
    ; VALUE: DBG_VALUE %4(s32), $noreg, [[VAR1]], !DIExpression(), debug-location !DILocation(line: 5
...