Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mlir/lib/Target/LLVMIR/DebugTranslation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ llvm::DINode *DebugTranslation::translate(DINodeAttr attr) {
DISubroutineTypeAttr>(
[&](auto attr) { return translateImpl(attr); });

attrToNode.insert({attr, node});
if (node && !node->isTemporary())
attrToNode.insert({attr, node});
return node;
}

Expand Down
8 changes: 6 additions & 2 deletions mlir/test/Target/LLVMIR/llvmir-debug.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,16 @@ llvm.mlir.global @global_variable() {dbg_expr = #di_global_variable_expression}
#di_subprogram = #llvm.di_subprogram<scope = #di_file, file = #di_file, subprogramFlags = Optimized, type = #di_subroutine_type>
#di_composite_type = #llvm.di_composite_type<tag = DW_TAG_class_type, recId = distinct[0]<>, scope = #di_subprogram>

#di_global_variable = #llvm.di_global_variable<file = #di_file, line = 1, type = #di_composite_type>
// Use the inner type standalone outside too. Ensures it's not cached wrong.
#di_var_type = #llvm.di_subroutine_type<types = #di_composite_type, #di_composite_type_inner>
#di_global_variable = #llvm.di_global_variable<file = #di_file, line = 1, type = #di_var_type>
#di_global_variable_expression = #llvm.di_global_variable_expression<var = #di_global_variable>

llvm.mlir.global @global_variable() {dbg_expr = #di_global_variable_expression} : !llvm.struct<()>

// CHECK: distinct !DIGlobalVariable({{.*}}type: ![[COMP:[0-9]+]],
// CHECK: distinct !DIGlobalVariable({{.*}}type: ![[VAR:[0-9]+]],
// CHECK: ![[VAR]] = !DISubroutineType(types: ![[COMPS:[0-9]+]])
// CHECK: ![[COMPS]] = !{![[COMP:[0-9]+]],
// CHECK: ![[COMP]] = distinct !DICompositeType({{.*}}scope: ![[SCOPE:[0-9]+]],
// CHECK: ![[SCOPE]] = !DISubprogram({{.*}}type: ![[SUBROUTINE:[0-9]+]],
// CHECK: ![[SUBROUTINE]] = !DISubroutineType(types: ![[SR_TYPES:[0-9]+]])
Expand Down