1 ;; Test that we can write in the new debug info format.
2 ; RUN: opt --passes=verify -S --experimental-debuginfo-iterators=false --write-experimental-debuginfo=false < %s \
3 ; RUN: | FileCheck %s --check-prefixes=CHECK,OLDDBG --implicit-check-not=llvm.dbg
4 ; RUN: opt --passes=verify -S --experimental-debuginfo-iterators=false --write-experimental-debuginfo=true < %s \
5 ; RUN: | FileCheck %s --check-prefixes=CHECK,NEWDBG --implicit-check-not=llvm.dbg
7 ;; Test also that the new flag is independent of the flag that enables use of
8 ;; these non-instruction debug info during LLVM passes.
9 ; RUN: opt --passes=verify -S --experimental-debuginfo-iterators=true --write-experimental-debuginfo=false < %s \
10 ; RUN: | FileCheck %s --check-prefixes=CHECK,OLDDBG --implicit-check-not=llvm.dbg
11 ; RUN: opt --passes=verify -S --experimental-debuginfo-iterators=true --write-experimental-debuginfo=true < %s \
12 ; RUN: | FileCheck %s --check-prefixes=CHECK,NEWDBG --implicit-check-not=llvm.dbg
14 ; CHECK: @f(i32 %[[VAL_A:[0-9a-zA-Z]+]])
16 ; OLDDBG-NEXT: call void @llvm.dbg.value(metadata i32 %[[VAL_A]], metadata ![[VAR_A:[0-9]+]], metadata !DIExpression()), !dbg ![[LOC_1:[0-9]+]]
17 ; NEWDBG-NEXT: {{^}} #dbg_value(i32 %[[VAL_A]], ![[VAR_A:[0-9]+]], !DIExpression(), ![[LOC_1:[0-9]+]])
18 ; CHECK-NEXT: {{^}} %[[VAL_B:[0-9a-zA-Z]+]] = alloca
19 ; OLDDBG-NEXT: call void @llvm.dbg.declare(metadata ptr %[[VAL_B]], metadata ![[VAR_B:[0-9]+]], metadata !DIExpression()), !dbg ![[LOC_2:[0-9]+]]
20 ; NEWDBG-NEXT: {{^}} #dbg_declare(ptr %[[VAL_B]], ![[VAR_B:[0-9]+]], !DIExpression(), ![[LOC_2:[0-9]+]])
21 ; CHECK-NEXT: {{^}} %[[VAL_ADD:[0-9a-zA-Z]+]] = add i32 %[[VAL_A]], 5
22 ; OLDDBG-NEXT: call void @llvm.dbg.value(metadata !DIArgList(i32 %[[VAL_A]], i32 %[[VAL_ADD]]), metadata ![[VAR_A]], metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus)), !dbg ![[LOC_3:[0-9]+]]
23 ; NEWDBG-NEXT: {{^}} #dbg_value(!DIArgList(i32 %[[VAL_A]], i32 %[[VAL_ADD]]), ![[VAR_A]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), ![[LOC_3:[0-9]+]])
24 ; OLDDBG-NEXT: call void @llvm.dbg.label(metadata ![[LABEL_ID:[0-9]+]]), !dbg ![[LOC_3]]
25 ; NEWDBG-NEXT: {{^}} #dbg_label(![[LABEL_ID:[0-9]+]], ![[LOC_3]])
26 ; CHECK-NEXT: {{^}} store i32 %[[VAL_ADD]]{{.+}}, !DIAssignID ![[ASSIGNID:[0-9]+]]
27 ; OLDDBG-NEXT: call void @llvm.dbg.assign(metadata i32 %[[VAL_ADD]], metadata ![[VAR_B]], metadata !DIExpression(), metadata ![[ASSIGNID]], metadata ptr %[[VAL_B]], metadata !DIExpression()), !dbg ![[LOC_4:[0-9]+]]
28 ; NEWDBG-NEXT: {{^}} #dbg_assign(i32 %[[VAL_ADD]], ![[VAR_B]], !DIExpression(), ![[ASSIGNID]], ptr %[[VAL_B]], !DIExpression(), ![[LOC_4:[0-9]+]])
29 ; OLDDBG-NEXT: call void @llvm.dbg.assign(metadata ![[EMPTY:[0-9]+]], metadata ![[VAR_B]], metadata !DIExpression(), metadata ![[ASSIGNID]], metadata ![[EMPTY]], metadata !DIExpression()), !dbg ![[LOC_4]]
30 ; NEWDBG-NEXT: {{^}} #dbg_assign(![[EMPTY:[0-9]+]], ![[VAR_B]], !DIExpression(), ![[ASSIGNID]], ![[EMPTY]], !DIExpression(), ![[LOC_4]])
31 ; CHECK-NEXT: {{^}} ret i32
33 ; OLDDBG-DAG: declare void @llvm.dbg.value
34 ; OLDDBG-DAG: declare void @llvm.dbg.declare
35 ; OLDDBG-DAG: declare void @llvm.dbg.assign
37 ; CHECK-DAG: llvm.dbg.cu
38 ; CHECK-DAG: ![[VAR_A]] = !DILocalVariable(name: "a"
39 ; CHECK-DAG: ![[VAR_B]] = !DILocalVariable(name: "b"
40 ; CHECK-DAG: ![[LOC_1]] = !DILocation(line: 3, column: 15
41 ; CHECK-DAG: ![[LOC_2]] = !DILocation(line: 3, column: 20
42 ; CHECK-DAG: ![[LOC_3]] = !DILocation(line: 3, column: 25
43 ; CHECK-DAG: ![[LOC_4]] = !DILocation(line: 3, column: 30
44 ; CHECK-DAG: ![[LABEL_ID]] = !DILabel(
45 ; CHECK-DAG: ![[EMPTY]] = !{}
47 define dso_local i32 @f(i32 %a) !dbg !7 {
49 call void @llvm.dbg.value(metadata i32 %a, metadata !20, metadata !DIExpression()), !dbg !30
50 %b = alloca i32, !dbg !30, !DIAssignID !40
51 call void @llvm.dbg.declare(metadata ptr %b, metadata !21, metadata !DIExpression()), !dbg !31
52 %add = add i32 %a, 5, !dbg !31
53 call void @llvm.dbg.value(metadata !DIArgList(i32 %a, i32 %add), metadata !20, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus)), !dbg !32
54 call void @llvm.dbg.label(metadata !50), !dbg !32
55 store i32 %add, ptr %b, !dbg !32, !DIAssignID !40
56 call void @llvm.dbg.assign(metadata i32 %add, metadata !21, metadata !DIExpression(), metadata !40, metadata ptr %b, metadata !DIExpression()), !dbg !33
57 call void @llvm.dbg.assign(metadata !2, metadata !21, metadata !DIExpression(), metadata !40, metadata !2, metadata !DIExpression()), !dbg !33
58 ret i32 %add, !dbg !33
62 declare void @llvm.dbg.value(metadata, metadata, metadata)
63 declare void @llvm.dbg.declare(metadata, metadata, metadata)
64 declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
65 declare void @llvm.dbg.label(metadata)
68 !llvm.module.flags = !{!3, !4, !5}
71 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 18.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
72 !1 = !DIFile(filename: "print.c", directory: "/tmp")
74 !3 = !{i32 2, !"Dwarf Version", i32 5}
75 !4 = !{i32 2, !"Debug Info Version", i32 3}
76 !5 = !{i32 1, !"wchar_size", i32 4}
77 !6 = !{!"clang version 18.0.0"}
78 !7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !13)
79 !8 = !DISubroutineType(types: !9)
81 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
83 !20 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 3, type: !12)
84 !21 = !DILocalVariable(name: "b", scope: !7, file: !1, line: 3, type: !12)
85 !30 = !DILocation(line: 3, column: 15, scope: !7)
86 !31 = !DILocation(line: 3, column: 20, scope: !7)
87 !32 = !DILocation(line: 3, column: 25, scope: !7)
88 !33 = !DILocation(line: 3, column: 30, scope: !7)
89 !40 = distinct !DIAssignID()
90 !50 = !DILabel(scope: !7, name: "label", file: !1, line: 3)