LLVM Discussion Forums

LLVM dialect function attributes in MLIR

Hi all,

I want to pass attributes to the function in LLVM dialect in MLIR. Currently, I understand that those are passed as string attributes or array attributes using the passthrough attribute. So my code is like

func.setAttr("passthrough", ArrayAttr::get({someAttr}, context));

Is there a “nicer” way to do this that I missed? Also, I am wondering why the attributes are represented as strings and not Enums? For example LLVM function attributes may form LLVMFuncAttr enum.




the passthrough is a temporary workaround letting us work with any kind of function metadata that are not currently modeled otherwise, in particular backend-specific attributes that are strings in LLVM. First-class modeling of generic function attributes on the LLVMFuncOp as MLIR is a very welcome addition. The hard part of it is understanding whether and how MLIR should respect those attributes if the IR is transformed (e.g., the convergent attribute restricts control flow transformations around calls to the function marked with it). I am also not convinced that an enum is what we want, maybe at the API level only. Functions are likely to have multiple attributes simultaneously, and not all of them are unit attributes (which could be packed into a bitset of sorts).