3 ;; Load RemoveDIs mode in llvm-dis but write out debug intrinsics.
4 ; RUN: llvm-as --write-experimental-debuginfo-iterators-to-bitcode=true %s -o - \
5 ; RUN: | llvm-dis --load-bitcode-into-experimental-debuginfo-iterators=true --write-experimental-debuginfo=false \
8 ;; Load and write RemoveDIs mode in llvm-dis.
9 ; RUN: llvm-as --write-experimental-debuginfo-iterators-to-bitcode=true %s -o - \
10 ; RUN: | llvm-dis --load-bitcode-into-experimental-debuginfo-iterators=true --write-experimental-debuginfo=true \
11 ; RUN: | FileCheck %s --check-prefixes=RECORDS
13 ;; Load intrinsics directly into the new format (auto-upgrade).
14 ; RUN: llvm-as --write-experimental-debuginfo-iterators-to-bitcode=false %s -o - \
15 ; RUN: | llvm-dis --load-bitcode-into-experimental-debuginfo-iterators=true --write-experimental-debuginfo=true \
16 ; RUN: | FileCheck %s --check-prefixes=RECORDS
18 ;; When preserving, we should output the format the bitcode was written in
19 ;; regardless of the value of the write flag.
20 ; RUN: llvm-as --write-experimental-debuginfo-iterators-to-bitcode=true %s -o - \
21 ; RUN: | llvm-dis --preserve-input-debuginfo-format=true --write-experimental-debuginfo=false \
22 ; RUN: | FileCheck %s --check-prefixes=RECORDS
24 ; RUN: llvm-as --write-experimental-debuginfo-iterators-to-bitcode=false %s -o - \
25 ; RUN: | llvm-dis --preserve-input-debuginfo-format=true --write-experimental-debuginfo=true \
28 ;; Check that verify-uselistorder passes regardless of input format.
29 ; RUN: llvm-as %s --write-experimental-debuginfo-iterators-to-bitcode=true -o - | verify-uselistorder
30 ; RUN: verify-uselistorder %s
32 ;; Confirm we're producing RemoveDI records from various tools.
33 ; RUN: opt %s -o - --write-experimental-debuginfo-iterators-to-bitcode=true | llvm-bcanalyzer - | FileCheck %s --check-prefix=BITCODE
34 ; RUN: llvm-as %s -o - --write-experimental-debuginfo-iterators-to-bitcode=true | llvm-bcanalyzer - | FileCheck %s --check-prefix=BITCODE
35 ; BITCODE-DAG: DEBUG_RECORD_LABEL
36 ; BITCODE-DAG: DEBUG_RECORD_VALUE
37 ; BITCODE-DAG: DEBUG_RECORD_ASSIGN
38 ; BITCODE-DAG: DEBUG_RECORD_DECLARE
40 ;; Check that llvm-link doesn't explode if we give it different formats to
42 ;; NOTE: This test fails intermittently on linux if the llvm-as output is piped
43 ;; into llvm-link in the RUN lines below, unless the verify-uselistorder RUN
44 ;; lines above are removed. Write to a temporary file to avoid that weirdness.
45 ;; NOTE2: Unfortunately, the above only stopped it occuring on my machine.
46 ;; It failed again intermittently here:
47 ;; https://lab.llvm.org/buildbot/#/builders/245/builds/21930
48 ;; Allow this test to fail-over twice, until this strangeness is understood.
50 ; RUN: llvm-as %s --experimental-debuginfo-iterators=true --write-experimental-debuginfo-iterators-to-bitcode=true -o %t
51 ; RUN: llvm-link %t %s --experimental-debuginfo-iterators=false -o /dev/null
52 ; RUN: llvm-as %s --experimental-debuginfo-iterators=false -o %t
53 ; RUN: llvm-link %t %s --experimental-debuginfo-iterators=true
57 @g = internal dso_local global i32 0, align 4, !dbg !0
59 define internal dso_local noundef i32 @_Z3funv(i32 %p, ptr %storage) !dbg !13 {
61 ;; Dbg record at top of block, check dbg.value configurations.
63 ; CHECK-NEXT: dbg.value(metadata i32 %p, metadata ![[e:[0-9]+]], metadata !DIExpression()), !dbg ![[dbg:[0-9]+]]
64 ; CHECK-NEXT: dbg.value(metadata ![[empty:[0-9]+]], metadata ![[e]], metadata !DIExpression()), !dbg ![[dbg]]
65 ; CHECK-NEXT: dbg.value(metadata i32 poison, metadata ![[e]], metadata !DIExpression()), !dbg ![[dbg]]
66 ; CHECK-NEXT: dbg.value(metadata i32 1, metadata ![[f:[0-9]+]], metadata !DIExpression()), !dbg ![[dbg]]
68 ; RECORDS-NEXT: dbg_value(i32 %p, ![[e:[0-9]+]], !DIExpression(), ![[dbg:[0-9]+]])
69 ; RECORDS-NEXT: dbg_value(![[empty:[0-9]+]], ![[e]], !DIExpression(), ![[dbg]])
70 ; RECORDS-NEXT: dbg_value(i32 poison, ![[e]], !DIExpression(), ![[dbg]])
71 ; RECORDS-NEXT: dbg_value(i32 1, ![[f:[0-9]+]], !DIExpression(), ![[dbg]])
72 tail call void @llvm.dbg.value(metadata i32 %p, metadata !32, metadata !DIExpression()), !dbg !19
73 tail call void @llvm.dbg.value(metadata !29, metadata !32, metadata !DIExpression()), !dbg !19
74 tail call void @llvm.dbg.value(metadata i32 poison, metadata !32, metadata !DIExpression()), !dbg !19
75 tail call void @llvm.dbg.value(metadata i32 1, metadata !33, metadata !DIExpression()), !dbg !19
76 ;; Arglist with an argument, constant, local use before def, poison.
77 ; CHECK-NEXT: dbg.value(metadata !DIArgList(i32 %p, i32 0, i32 %0, i32 poison), metadata ![[f]], metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_LLVM_arg, 2, DW_OP_LLVM_arg, 3, DW_OP_plus, DW_OP_minus)), !dbg ![[dbg]]
78 ; RECORDS-NEXT: dbg_value(!DIArgList(i32 %p, i32 0, i32 %0, i32 poison), ![[f]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_LLVM_arg, 2, DW_OP_LLVM_arg, 3, DW_OP_plus, DW_OP_minus), ![[dbg]])
79 tail call void @llvm.dbg.value(metadata !DIArgList(i32 %p, i32 0, i32 %0, i32 poison), metadata !33, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_LLVM_arg, 2, DW_OP_LLVM_arg, 3, DW_OP_plus, DW_OP_minus)), !dbg !19
80 ;; Check dbg.assign use before def (value, addr and ID). Check expression order too.
81 ; CHECK: dbg.assign(metadata i32 %0, metadata ![[i:[0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 0),
82 ; CHECK-SAME: metadata ![[ID:[0-9]+]], metadata ptr %a, metadata !DIExpression(DW_OP_plus_uconst, 1)), !dbg ![[dbg]]
83 ; RECORDS: dbg_assign(i32 %0, ![[i:[0-9]+]], !DIExpression(DW_OP_plus_uconst, 0),
84 ; RECORDS-SAME: ![[ID:[0-9]+]], ptr %a, !DIExpression(DW_OP_plus_uconst, 1), ![[dbg]])
85 tail call void @llvm.dbg.assign(metadata i32 %0, metadata !36, metadata !DIExpression(DW_OP_plus_uconst, 0), metadata !37, metadata ptr %a, metadata !DIExpression(DW_OP_plus_uconst, 1)), !dbg !19
86 %a = alloca i32, align 4, !DIAssignID !37
87 ; CHECK: %a = alloca i32, align 4, !DIAssignID ![[ID]]
88 ;; Check dbg.declare configurations.
89 ; CHECK-NEXT: dbg.declare(metadata ptr %a, metadata ![[a:[0-9]+]], metadata !DIExpression()), !dbg ![[dbg]]
90 ; CHECK-NEXT: dbg.declare(metadata ![[empty:[0-9]+]], metadata ![[b:[0-9]+]], metadata !DIExpression()), !dbg ![[dbg]]
91 ; CHECK-NEXT: dbg.declare(metadata ptr poison, metadata ![[c:[0-9]+]], metadata !DIExpression()), !dbg ![[dbg]]
92 ; CHECK-NEXT: dbg.declare(metadata ptr null, metadata ![[d:[0-9]+]], metadata !DIExpression()), !dbg ![[dbg]]
93 ; CHECK-NEXT: dbg.declare(metadata ptr @g, metadata ![[h:[0-9]+]], metadata !DIExpression()), !dbg ![[dbg]]
94 ; RECORDS: %a = alloca i32, align 4, !DIAssignID ![[ID]]
95 ;; Check dbg.declare configurations.
96 ; RECORDS-NEXT: dbg_declare(ptr %a, ![[a:[0-9]+]], !DIExpression(), ![[dbg]])
97 ; RECORDS-NEXT: dbg_declare(![[empty:[0-9]+]], ![[b:[0-9]+]], !DIExpression(), ![[dbg]])
98 ; RECORDS-NEXT: dbg_declare(ptr poison, ![[c:[0-9]+]], !DIExpression(), ![[dbg]])
99 ; RECORDS-NEXT: dbg_declare(ptr null, ![[d:[0-9]+]], !DIExpression(), ![[dbg]])
100 ; RECORDS-NEXT: dbg_declare(ptr @g, ![[h:[0-9]+]], !DIExpression(), ![[dbg]])
101 tail call void @llvm.dbg.declare(metadata ptr %a, metadata !17, metadata !DIExpression()), !dbg !19
102 tail call void @llvm.dbg.declare(metadata !29, metadata !28, metadata !DIExpression()), !dbg !19
103 tail call void @llvm.dbg.declare(metadata ptr poison, metadata !30, metadata !DIExpression()), !dbg !19
104 tail call void @llvm.dbg.declare(metadata ptr null, metadata !31, metadata !DIExpression()), !dbg !19
105 tail call void @llvm.dbg.declare(metadata ptr @g, metadata !35, metadata !DIExpression()), !dbg !19
106 ;; Argument value dbg.declare.
107 ; CHECK: dbg.declare(metadata ptr %storage, metadata ![[g:[0-9]+]], metadata !DIExpression()), !dbg ![[dbg]]
108 ; RECORDS: dbg_declare(ptr %storage, ![[g:[0-9]+]], !DIExpression(), ![[dbg]])
109 tail call void @llvm.dbg.declare(metadata ptr %storage, metadata !34, metadata !DIExpression()), !dbg !19
110 ;; Use before def dbg.value.
111 ; CHECK: dbg.value(metadata i32 %0, metadata ![[e]], metadata !DIExpression()), !dbg ![[dbg]]
112 ; RECORDS: dbg_value(i32 %0, ![[e]], !DIExpression(), ![[dbg]])
113 tail call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !19
114 %0 = load i32, ptr @g, align 4, !dbg !20
115 ;; Non-argument local value dbg.value.
116 ; CHECK: dbg.value(metadata i32 %0, metadata ![[e]], metadata !DIExpression()), !dbg ![[dbg]]
117 ; RECORDS: dbg_value(i32 %0, ![[e]], !DIExpression(), ![[dbg]])
118 tail call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !19
119 store i32 %0, ptr %a, align 4, !dbg !19
120 %1 = load i32, ptr %a, align 4, !dbg !25
121 ; CHECK: dbg.label(metadata ![[label:[0-9]+]]), !dbg ![[dbg]]
122 ; RECORDS: dbg_label(![[label:[0-9]+]], ![[dbg]])
123 tail call void @llvm.dbg.label(metadata !38), !dbg !19
127 ; CHECK-DAG: ![[a]] = !DILocalVariable(name: "a",
128 ; CHECK-DAG: ![[b]] = !DILocalVariable(name: "b",
129 ; CHECK-DAG: ![[c]] = !DILocalVariable(name: "c",
130 ; CHECK-DAG: ![[d]] = !DILocalVariable(name: "d",
131 ; CHECK-DAG: ![[e]] = !DILocalVariable(name: "e",
132 ; CHECK-DAG: ![[f]] = !DILocalVariable(name: "f",
133 ; CHECK-DAG: ![[g]] = !DILocalVariable(name: "g",
134 ; CHECK-DAG: ![[h]] = !DILocalVariable(name: "h",
135 ; CHECK-DAG: ![[i]] = !DILocalVariable(name: "i",
136 ; CHECK-DAG: ![[empty]] = !{}
137 ; CHECK-DAG: ![[label]] = !DILabel
139 declare void @llvm.dbg.declare(metadata, metadata, metadata)
140 declare void @llvm.dbg.value(metadata, metadata, metadata)
141 declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
142 declare void @llvm.dbg.label(metadata)
145 !llvm.module.flags = !{!6, !7, !8, !9, !10, !11}
148 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
149 !1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 1, type: !5, isLocal: false, isDefinition: true)
150 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 19.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
151 !3 = !DIFile(filename: "test.cpp", directory: "/")
153 !5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
154 !6 = !{i32 7, !"Dwarf Version", i32 5}
155 !7 = !{i32 2, !"Debug Info Version", i32 3}
156 !8 = !{i32 1, !"wchar_size", i32 4}
157 !9 = !{i32 8, !"PIC Level", i32 2}
158 !10 = !{i32 7, !"PIE Level", i32 2}
159 !11 = !{i32 7, !"uwtable", i32 2}
160 !12 = !{!"clang version 19.0.0"}
161 !13 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !3, file: !3, line: 2, type: !14, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !16)
162 !14 = !DISubroutineType(types: !15)
165 !17 = !DILocalVariable(name: "a", scope: !13, file: !3, line: 3, type: !5)
166 !18 = !DILocation(line: 3, column: 3, scope: !13)
167 !19 = !DILocation(line: 3, column: 7, scope: !13)
168 !20 = !DILocation(line: 3, column: 11, scope: !13)
169 !25 = !DILocation(line: 4, column: 12, scope: !13)
170 !26 = !DILocation(line: 5, column: 1, scope: !13)
171 !27 = !DILocation(line: 4, column: 5, scope: !13)
172 !28 = !DILocalVariable(name: "b", scope: !13, file: !3, line: 3, type: !5)
174 !30 = !DILocalVariable(name: "c", scope: !13, file: !3, line: 3, type: !5)
175 !31 = !DILocalVariable(name: "d", scope: !13, file: !3, line: 3, type: !5)
176 !32 = !DILocalVariable(name: "e", scope: !13, file: !3, line: 3, type: !5)
177 !33 = !DILocalVariable(name: "f", scope: !13, file: !3, line: 3, type: !5)
178 !34 = !DILocalVariable(name: "g", scope: !13, file: !3, line: 3, type: !5)
179 !35 = !DILocalVariable(name: "h", scope: !13, file: !3, line: 3, type: !5)
180 !36 = !DILocalVariable(name: "i", scope: !13, file: !3, line: 3, type: !5)
181 !37 = distinct !DIAssignID()
182 !38 = !DILabel(scope: !13, name: "label", file: !3, line: 1)