Skip to content

Commit 1277837

Browse files
[MLIR][LLVM] Debug info: fix DIDerivedTypeAttr relation to DIScopeAttr (#138200)
Fix `di_subprogram` references to scopes composed of `di_derived_type`s, which currently fail to parse with: ``` error: failed to parse LLVM_DISubprogramAttr parameter 'scope' which is to be a `DIScopeAttr` ```
1 parent 52c6236 commit 1277837

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ bool DINodeAttr::classof(Attribute attr) {
9090

9191
bool DIScopeAttr::classof(Attribute attr) {
9292
return llvm::isa<DICommonBlockAttr, DICompileUnitAttr, DICompositeTypeAttr,
93-
DIFileAttr, DILocalScopeAttr, DIModuleAttr, DINamespaceAttr>(
94-
attr);
93+
DIDerivedTypeAttr, DIFileAttr, DILocalScopeAttr,
94+
DIModuleAttr, DINamespaceAttr>(attr);
9595
}
9696

9797
//===----------------------------------------------------------------------===//

mlir/test/Dialect/LLVMIR/debuginfo.mlir

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@
131131
annotations = #llvm.di_annotation<name = "foo", value = "bar">
132132
>
133133

134+
// CHECK-DAG: #[[SP3:.*]] = #llvm.di_subprogram<scope = #[[PTR2]], file = #[[FILE]], type = #[[SPTYPE1]]>
135+
#sp3 = #llvm.di_subprogram<
136+
// Omit the optional parameters.
137+
scope = #ptr2, file = #file, type = #spType1
138+
>
139+
134140
// CHECK-DAG: #[[BLOCK0:.*]] = #llvm.di_lexical_block<scope = #[[SP0]], line = 1, column = 2>
135141
#block0 = #llvm.di_lexical_block<scope = #sp0, line = 1, column = 2>
136142

@@ -140,6 +146,9 @@
140146
// CHECK-DAG: #[[BLOCK2:.*]] = #llvm.di_lexical_block<scope = #[[SP2]]>
141147
#block2 = #llvm.di_lexical_block<scope = #sp2>
142148

149+
// CHECK-DAG: #[[BLOCK3:.*]] = #llvm.di_lexical_block<scope = #[[SP3]]>
150+
#block3 = #llvm.di_lexical_block<scope = #sp3>
151+
143152
// CHECK-DAG: #[[VAR0:.*]] = #llvm.di_local_variable<scope = #[[BLOCK0]], name = "alloc", file = #[[FILE]], line = 6, arg = 1, alignInBits = 32, type = #[[INT0]]>
144153
#var0 = #llvm.di_local_variable<
145154
scope = #block0, name = "alloc", file = #file,
@@ -158,6 +167,12 @@
158167
scope = #block2, name = "arg2"
159168
>
160169

170+
// CHECK-DAG: #[[VAR3:.*]] = #llvm.di_local_variable<scope = #[[BLOCK3]], name = "arg3">
171+
#var3 = #llvm.di_local_variable<
172+
// Omit the optional parameters.
173+
scope = #block3, name = "arg3"
174+
>
175+
161176
// CHECK-DAG: #[[LABEL1:.*]] = #llvm.di_label<scope = #[[BLOCK1]], name = "label", file = #[[FILE]], line = 42>
162177
#label1 = #llvm.di_label<scope = #block1, name = "label", file = #file, line = 42>
163178

@@ -194,12 +209,14 @@ llvm.func @addr(%arg: i64) {
194209
llvm.return
195210
}
196211

197-
// CHECK: llvm.func @value(%[[ARG1:.*]]: i32, %[[ARG2:.*]]: i32)
198-
llvm.func @value(%arg1: i32, %arg2: i32) {
212+
// CHECK: llvm.func @value(%[[ARG1:.*]]: i32, %[[ARG2:.*]]: i32, %[[ARG3:.*]]: i32)
213+
llvm.func @value(%arg1: i32, %arg2: i32, %arg3 : i32) {
199214
// CHECK: llvm.intr.dbg.value #[[VAR1]] #llvm.di_expression<[DW_OP_LLVM_fragment(16, 8), DW_OP_plus_uconst(2), DW_OP_deref]> = %[[ARG1]]
200215
llvm.intr.dbg.value #var1 #llvm.di_expression<[DW_OP_LLVM_fragment(16, 8), DW_OP_plus_uconst(2), DW_OP_deref]> = %arg1 : i32
201216
// CHECK: llvm.intr.dbg.value #[[VAR2]] = %[[ARG2]]
202217
llvm.intr.dbg.value #var2 = %arg2 : i32
218+
// CHECK: llvm.intr.dbg.value #[[VAR3]] = %[[ARG3]]
219+
llvm.intr.dbg.value #var3 = %arg3 : i32
203220
// CHECK: llvm.intr.dbg.label #[[LABEL1]]
204221
llvm.intr.dbg.label #label1
205222
// CHECK: llvm.intr.dbg.label #[[LABEL2]]

0 commit comments

Comments
 (0)