[Mlir-commits] [mlir] a8291e0 - [mlir][llvm] Make DINamespace name optional

Christian Ulmann llvmlistbot at llvm.org
Wed Mar 29 03:19:19 PDT 2023


Author: Christian Ulmann
Date: 2023-03-29T10:17:27Z
New Revision: a8291e0dc55f8d1513759df63f603f709fa1c37a

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

LOG: [mlir][llvm] Make DINamespace name optional

This commit makes the name of a DINamespace optional to enable modeling
of anonymous namespaces.

Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D147125

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
    mlir/test/Dialect/LLVMIR/debuginfo.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
index 903519961efc0..937e7fc4f06fe 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
@@ -476,7 +476,7 @@ def LLVM_DISubprogramAttr : LLVM_Attr<"DISubprogram", "di_subprogram",
 def LLVM_DINamespaceAttr : LLVM_Attr<"DINamespace", "di_namespace",
                                       /*traits=*/[], "DIScopeAttr"> {
   let parameters = (ins
-    "StringAttr":$name,
+    OptionalParameter<"StringAttr">:$name,
     OptionalParameter<"DIScopeAttr">:$scope,
     "bool":$exportSymbols
   );

diff  --git a/mlir/test/Dialect/LLVMIR/debuginfo.mlir b/mlir/test/Dialect/LLVMIR/debuginfo.mlir
index f7517b2f23108..aec40ad50e92e 100644
--- a/mlir/test/Dialect/LLVMIR/debuginfo.mlir
+++ b/mlir/test/Dialect/LLVMIR/debuginfo.mlir
@@ -60,6 +60,12 @@
   name = "nested", scope = #toplevel_namespace, exportSymbols = false
 >
 
+// CHECK-DAG: #[[ANONYMOUS_NS:.*]] = #llvm.di_namespace<scope = #[[FILE]], exportSymbols = false>
+#anonymous_namespace = #llvm.di_namespace<
+  scope = #file,
+  exportSymbols = false
+>
+
 // CHECK-DAG: #[[COMP2:.*]] = #llvm.di_composite_type<tag = DW_TAG_class_type, name = "class_name", file = #[[FILE]], scope = #[[NESTED]], flags = "TypePassByReference|NonTrivial">
 #comp2 = #llvm.di_composite_type<
   tag = DW_TAG_class_type, name = "class_name", file = #file, scope = #nested_namespace,
@@ -83,9 +89,9 @@
   callingConvention = DW_CC_normal
 >
 
-// CHECK-DAG: #[[SP0:.*]] = #llvm.di_subprogram<compileUnit = #[[CU]], scope = #[[FILE]], name = "addr", linkageName = "addr", file = #[[FILE]], line = 3, scopeLine = 3, subprogramFlags = "Definition|Optimized", type = #[[SPTYPE0]]>
+// CHECK-DAG: #[[SP0:.*]] = #llvm.di_subprogram<compileUnit = #[[CU]], scope = #[[ANONYMOUS_NS]], name = "addr", linkageName = "addr", file = #[[FILE]], line = 3, scopeLine = 3, subprogramFlags = "Definition|Optimized", type = #[[SPTYPE0]]>
 #sp0 = #llvm.di_subprogram<
-  compileUnit = #cu, scope = #file, name = "addr", linkageName = "addr",
+  compileUnit = #cu, scope = #anonymous_namespace, name = "addr", linkageName = "addr",
   file = #file, line = 3, scopeLine = 3, subprogramFlags = "Definition|Optimized", type = #spType0
 >
 


        


More information about the Mlir-commits mailing list