xref: /llvm-project/llvm/test/DebugInfo/WebAssembly/remove-reg-dbg-value.mir (revision 981a28f7ae2cb99f75ca234b05f2c75ad3a356d7)
1# RUN: llc -run-pass wasm-debug-fixup %s -o - | FileCheck %s
2
3# Test if '#DEBUG_VALUE' comments for target indices are printed correctly.
4
5--- |
6  target triple = "wasm32-unknown-unknown"
7
8  define void @test_remove_dangling_reg_dbg_value() !dbg !5 {
9    call void @llvm.dbg.value(metadata i32 0, metadata !9, metadata !DIExpression()), !dbg !10
10    call void @llvm.dbg.value(metadata i32 0, metadata !11, metadata !DIExpression()), !dbg !10
11    ret void
12  }
13
14  declare void @llvm.dbg.value(metadata, metadata, metadata)
15
16  !llvm.dbg.cu = !{!0}
17  !llvm.module.flags = !{!2, !3, !4}
18
19  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
20  !1 = !DIFile(filename: "test.c", directory: "")
21  !2 = !{i32 7, !"Dwarf Version", i32 5}
22  !3 = !{i32 2, !"Debug Info Version", i32 3}
23  !4 = !{i32 1, !"wchar_size", i32 4}
24  !5 = distinct !DISubprogram(name: "test_dbg_value_comment", scope: !1, file: !1, line: 1, type: !6, scopeLine: 1, unit: !0)
25  !6 = !DISubroutineType(types: !7)
26  !7 = !{!8}
27  !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
28  !9 = !DILocalVariable(name: "var0", scope: !5, file: !1, line: 2, type: !8)
29  !10 = !DILocation(line: 0, scope: !5)
30  !11 = !DILocalVariable(name: "var1", scope: !5, file: !1, line: 2, type: !8)
31...
32
33---
34# CHECK-LABEL: name: test_remove_dangling_reg_dbg_value
35name: test_remove_dangling_reg_dbg_value
36liveins:
37  - { reg: '$arguments' }
38body: |
39  ; CHECK: bb.0:
40  ; CHECK: DBG_VALUE $noreg, $noreg, !9, !DIExpression(), debug-location !10
41  ; CHECK-NEXT: DBG_VALUE target-index(wasm-local) + 1, $noreg, !11, !DIExpression(), debug-location !10
42  ; CHECK-NEXT: RETURN
43  bb.0:
44    liveins: $arguments
45    ; This %3 is a danling register and will turn to $noreg
46    DBG_VALUE %3:i32, $noreg, !9, !DIExpression(), debug-location !10
47    ; This debug info will remain the same, because it's in a local
48    DBG_VALUE target-index(wasm-local) + 1, $noreg, !11, !DIExpression(), debug-location !10
49    RETURN implicit-def dead $arguments
50...
51