Skip to content

Commit 22b49fc

Browse files
committed
[mlir][llvm] Make DISubprogram name optional
This commit make the name parameter of the DISubprogramAttr optional. LLVM will for example omit these subprogram names in initialization functions for globals. Reviewed By: gysit Differential Revision: https://reviews.llvm.org/D145046
1 parent 831591b commit 22b49fc

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def LLVM_DISubprogramAttr : LLVM_Attr<"DISubprogram", "di_subprogram",
444444
let parameters = (ins
445445
OptionalParameter<"DICompileUnitAttr">:$compileUnit,
446446
"DIScopeAttr":$scope,
447-
"StringAttr":$name,
447+
OptionalParameter<"StringAttr">:$name,
448448
OptionalParameter<"StringAttr">:$linkageName,
449449
"DIFileAttr":$file,
450450
OptionalParameter<"unsigned">:$line,

mlir/test/Target/LLVMIR/Import/debug-info.ll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,18 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
410410
!7 = !DILocalVariable(scope: !8)
411411
!8 = distinct !DISubprogram(name: "noname_variable", scope: !2, file: !2, unit: !1);
412412
!9 = !DILocation(line: 1, column: 2, scope: !8)
413+
414+
; // -----
415+
416+
; CHECK: #[[SUBPROGRAM:.*]] = #llvm.di_subprogram<compileUnit = #{{.*}}, scope = #{{.*}}, file = #{{.*}}, subprogramFlags = Definition>
417+
; CHECK: #[[FUNC_LOC:.*]] = loc(fused<#[[SUBPROGRAM]]>[{{.*}}])
418+
define void @noname_subprogram(ptr %arg) !dbg !8 {
419+
ret void
420+
}
421+
422+
!llvm.dbg.cu = !{!1}
423+
!llvm.module.flags = !{!0}
424+
!0 = !{i32 2, !"Debug Info Version", i32 3}
425+
!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
426+
!2 = !DIFile(filename: "debug-info.ll", directory: "/")
427+
!8 = distinct !DISubprogram(scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1);

0 commit comments

Comments
 (0)