1 ;; Test that we can write in the old debug info format.
2 ; RUN: opt --passes=verify -S --write-experimental-debuginfo=false < %s \
3 ; RUN: | FileCheck %s --check-prefixes=CHECK,OLDDBG --implicit-check-not=llvm.dbg --implicit-check-not=#dbg
5 ;; Test that we can write in the new debug info format...
6 ; RUN: opt --passes=verify -S --write-experimental-debuginfo=true < %s \
7 ; RUN: | FileCheck %s --check-prefixes=CHECK,NEWDBG --implicit-check-not=llvm.dbg --implicit-check-not=#dbg
9 ;; ...and then read the new format and write the old format.
10 ; RUN: opt --passes=verify -S --write-experimental-debuginfo=true < %s \
11 ; RUN: | opt --passes=verify -S --write-experimental-debuginfo=false \
12 ; RUN: | FileCheck %s --check-prefixes=CHECK,OLDDBG --implicit-check-not=llvm.dbg --implicit-check-not=#dbg
14 ;; Test also that the new flag is independent of the flag that enables use of
15 ;; these non-instruction debug info during LLVM passes.
16 ; RUN: opt --passes=verify -S --try-experimental-debuginfo-iterators --write-experimental-debuginfo=false < %s \
17 ; RUN: | FileCheck %s --check-prefixes=CHECK,OLDDBG --implicit-check-not=llvm.dbg --implicit-check-not=#dbg
18 ; RUN: opt --passes=verify -S --try-experimental-debuginfo-iterators --write-experimental-debuginfo=true < %s \
19 ; RUN: | FileCheck %s --check-prefixes=CHECK,NEWDBG --implicit-check-not=llvm.dbg --implicit-check-not=#dbg
21 ;; Test that the preserving flag overrides the write flag.
22 ; RUN: opt --passes=verify -S --preserve-input-debuginfo-format=true --write-experimental-debuginfo=true < %s \
23 ; RUN: | FileCheck %s --check-prefixes=CHECK,OLDDBG --implicit-check-not=llvm.dbg --implicit-check-not=#dbg
25 ; RUN: opt --passes=verify -S --write-experimental-debuginfo=true < %s \
26 ; RUN: | opt --passes=verify -S --preserve-input-debuginfo-format=true --write-experimental-debuginfo=false \
27 ; RUN: | FileCheck %s --check-prefixes=CHECK,NEWDBG --implicit-check-not=llvm.dbg --implicit-check-not=#dbg
29 ; CHECK: @f(i32 %[[VAL_A:[0-9a-zA-Z]+]])
31 ; OLDDBG-NEXT: call void @llvm.dbg.value(metadata i32 %[[VAL_A]], metadata ![[VAR_A:[0-9]+]], metadata !DIExpression()), !dbg ![[LOC_1:[0-9]+]]
32 ; NEWDBG-NEXT: {{^}} #dbg_value(i32 %[[VAL_A]], ![[VAR_A:[0-9]+]], !DIExpression(), ![[LOC_1:[0-9]+]])
33 ; CHECK-NEXT: {{^}} %[[VAL_B:[0-9a-zA-Z]+]] = alloca
34 ; OLDDBG-NEXT: call void @llvm.dbg.declare(metadata ptr %[[VAL_B]], metadata ![[VAR_B:[0-9]+]], metadata !DIExpression()), !dbg ![[LOC_2:[0-9]+]]
35 ; NEWDBG-NEXT: {{^}} #dbg_declare(ptr %[[VAL_B]], ![[VAR_B:[0-9]+]], !DIExpression(), ![[LOC_2:[0-9]+]])
36 ; CHECK-NEXT: {{^}} %[[VAL_ADD:[0-9a-zA-Z]+]] = add i32 %[[VAL_A]], 5
37 ; 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]+]]
38 ; 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]+]])
39 ; OLDDBG-NEXT: call void @llvm.dbg.label(metadata ![[LABEL_ID:[0-9]+]]), !dbg ![[LOC_3]]
40 ; NEWDBG-NEXT: {{^}} #dbg_label(![[LABEL_ID:[0-9]+]], ![[LOC_3]])
41 ; CHECK-NEXT: {{^}} store i32 %[[VAL_ADD]]{{.+}}, !DIAssignID ![[ASSIGNID:[0-9]+]]
42 ; 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]+]]
43 ; NEWDBG-NEXT: {{^}} #dbg_assign(i32 %[[VAL_ADD]], ![[VAR_B]], !DIExpression(), ![[ASSIGNID]], ptr %[[VAL_B]], !DIExpression(), ![[LOC_4:[0-9]+]])
44 ; CHECK-NEXT: {{^}} ret i32
46 ; OLDDBG-DAG: declare void @llvm.dbg.value
47 ; OLDDBG-DAG: declare void @llvm.dbg.declare
48 ; OLDDBG-DAG: declare void @llvm.dbg.assign
49 ; OLDDBG-DAG: declare void @llvm.dbg.label
51 ; CHECK-DAG: llvm.dbg.cu
52 ; CHECK-DAG: ![[VAR_A]] = !DILocalVariable(name: "a"
53 ; CHECK-DAG: ![[VAR_B]] = !DILocalVariable(name: "b"
54 ; CHECK-DAG: ![[LOC_1]] = !DILocation(line: 3, column: 15
55 ; CHECK-DAG: ![[LOC_2]] = !DILocation(line: 3, column: 20
56 ; CHECK-DAG: ![[LOC_3]] = !DILocation(line: 3, column: 25
57 ; CHECK-DAG: ![[LOC_4]] = !DILocation(line: 3, column: 30
58 ; CHECK-DAG: ![[LABEL_ID]] = !DILabel(
60 define dso_local i32 @f(i32 %a) !dbg !7 {
62 call void @llvm.dbg.value(metadata i32 %a, metadata !20, metadata !DIExpression()), !dbg !30
63 %b = alloca i32, !dbg !30, !DIAssignID !40
64 call void @llvm.dbg.declare(metadata ptr %b, metadata !21, metadata !DIExpression()), !dbg !31
65 %add = add i32 %a, 5, !dbg !31
66 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
67 call void @llvm.dbg.label(metadata !50), !dbg !32
68 store i32 %add, ptr %b, !dbg !32, !DIAssignID !40
69 call void @llvm.dbg.assign(metadata i32 %add, metadata !21, metadata !DIExpression(), metadata !40, metadata ptr %b, metadata !DIExpression()), !dbg !33
70 ret i32 %add, !dbg !33
74 declare void @llvm.dbg.value(metadata, metadata, metadata)
75 declare void @llvm.dbg.declare(metadata, metadata, metadata)
76 declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
77 declare void @llvm.dbg.label(metadata)
80 !llvm.module.flags = !{!3, !4, !5}
83 !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)
84 !1 = !DIFile(filename: "print.c", directory: "/tmp")
86 !3 = !{i32 2, !"Dwarf Version", i32 5}
87 !4 = !{i32 2, !"Debug Info Version", i32 3}
88 !5 = !{i32 1, !"wchar_size", i32 4}
89 !6 = !{!"clang version 18.0.0"}
90 !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)
91 !8 = !DISubroutineType(types: !9)
93 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
95 !20 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 3, type: !12)
96 !21 = !DILocalVariable(name: "b", scope: !7, file: !1, line: 3, type: !12)
97 !30 = !DILocation(line: 3, column: 15, scope: !7)
98 !31 = !DILocation(line: 3, column: 20, scope: !7)
99 !32 = !DILocation(line: 3, column: 25, scope: !7)
100 !33 = !DILocation(line: 3, column: 30, scope: !7)
101 !40 = distinct !DIAssignID()
102 !50 = !DILabel(scope: !7, name: "label", file: !1, line: 3)