[clang] [CIR] Add support for global linkage and visibility (PR #141973)

Henrich Lauko via cfe-commits cfe-commits at lists.llvm.org
Fri May 30 01:07:57 PDT 2025


================
@@ -1643,17 +1644,31 @@ def GlobalOp : CIR_Op<"global"> {
     described by the type of the variable.
 
     The `linkage` tracks C/C++ linkage types, currently very similar to LLVM's.
+    Symbol visibility in `sym_visibility` is defined in terms of MLIR's visibility
+    and verified to be in accordance to `linkage`.
   }];
 
+  // Note that both sym_name and sym_visibility are tied to Symbol trait.
+  // TODO: sym_visibility can possibly be represented by implementing the
+  // necessary Symbol's interface in terms of linkage instead.
   let arguments = (ins SymbolNameAttr:$sym_name,
+                       DefaultValuedAttr<
+                        VisibilityAttr,
----------------
xlauko wrote:

```suggestion
                        CIR_VisibilityAttr,
```

https://github.com/llvm/llvm-project/pull/141973


More information about the cfe-commits mailing list