[clang] [CIR] Add support for function linkage and visibility (PR #145600)
Sirui Mu via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 25 02:54:58 PDT 2025
================
@@ -1737,25 +1737,51 @@ def GetMemberOp : CIR_Op<"get_member"> {
def FuncOp : CIR_Op<"func", [
AutomaticAllocationScope, CallableOpInterface, FunctionOpInterface,
+ DeclareOpInterfaceMethods<CIRGlobalValueInterface>,
IsolatedFromAbove
]> {
let summary = "Declare or define a function";
let description = [{
The `cir.func` operation defines a function, similar to the `mlir::FuncOp`
built-in.
+
+ The function linkage information is specified by `linkage`, as defined by
+ `GlobalLinkageKind` attribute.
+
+ Example:
+
+ ```mlir
+ // External function definitions.
+ cir.func @abort()
+
+ // A function with internal linkage.
+ cir.func internal @count(%x: i64) -> (i64)
+ return %x : i64
+
+ // Linkage information
+ cir.func linkonce_odr @some_method(...)
+ ```
}];
let arguments = (ins SymbolNameAttr:$sym_name,
+ CIR_VisibilityAttr:$global_visibility,
TypeAttrOf<CIR_FuncType>:$function_type,
+ UnitAttr:$dso_local,
----------------
Lancern wrote:
Should we elaborate `dso_local` from a simple boolean flag into something like a `RuntimePreemption` enum that could be either `NonPreemptable` or `Preemptable`?
https://github.com/llvm/llvm-project/pull/145600
More information about the cfe-commits
mailing list