[Mlir-commits] [mlir] 22b49fc - [mlir][llvm] Make DISubprogram name optional

Christian Ulmann llvmlistbot at llvm.org
Wed Mar 1 03:27:23 PST 2023


Author: Christian Ulmann
Date: 2023-03-01T12:26:52+01:00
New Revision: 22b49fccbbf11a41b76c44b7b8ba61b25a2d6308

URL: https://github.com/llvm/llvm-project/commit/22b49fccbbf11a41b76c44b7b8ba61b25a2d6308
DIFF: https://github.com/llvm/llvm-project/commit/22b49fccbbf11a41b76c44b7b8ba61b25a2d6308.diff

LOG: [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

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
    mlir/test/Target/LLVMIR/Import/debug-info.ll

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
index e75fd8c911828..903519961efc0 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
@@ -444,7 +444,7 @@ def LLVM_DISubprogramAttr : LLVM_Attr<"DISubprogram", "di_subprogram",
   let parameters = (ins
     OptionalParameter<"DICompileUnitAttr">:$compileUnit,
     "DIScopeAttr":$scope,
-    "StringAttr":$name,
+    OptionalParameter<"StringAttr">:$name,
     OptionalParameter<"StringAttr">:$linkageName,
     "DIFileAttr":$file,
     OptionalParameter<"unsigned">:$line,

diff  --git a/mlir/test/Target/LLVMIR/Import/debug-info.ll b/mlir/test/Target/LLVMIR/Import/debug-info.ll
index a8aae4573e9af..fc0b7579bcfb6 100644
--- a/mlir/test/Target/LLVMIR/Import/debug-info.ll
+++ b/mlir/test/Target/LLVMIR/Import/debug-info.ll
@@ -410,3 +410,18 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
 !7 = !DILocalVariable(scope: !8)
 !8 = distinct !DISubprogram(name: "noname_variable", scope: !2, file: !2, unit: !1);
 !9 = !DILocation(line: 1, column: 2, scope: !8)
+
+; // -----
+
+; CHECK: #[[SUBPROGRAM:.*]] = #llvm.di_subprogram<compileUnit = #{{.*}}, scope = #{{.*}}, file = #{{.*}}, subprogramFlags = Definition>
+; CHECK: #[[FUNC_LOC:.*]] = loc(fused<#[[SUBPROGRAM]]>[{{.*}}])
+define void @noname_subprogram(ptr %arg) !dbg !8 {
+  ret void
+}
+
+!llvm.dbg.cu = !{!1}
+!llvm.module.flags = !{!0}
+!0 = !{i32 2, !"Debug Info Version", i32 3}
+!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
+!2 = !DIFile(filename: "debug-info.ll", directory: "/")
+!8 = distinct !DISubprogram(scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1);


        


More information about the Mlir-commits mailing list