[Mlir-commits] [mlir] [mlir][func] Account for named attributes without a dialect prefix in `FuncToLLVM` lowering pass (PR #182987)
Mehdi Amini
llvmlistbot at llvm.org
Tue Feb 24 02:07:03 PST 2026
================
@@ -52,10 +52,15 @@ static constexpr StringRef varargsAttrName = "func.varargs";
static constexpr StringRef linkageAttrName = "llvm.linkage";
static constexpr StringRef barePtrAttrName = "llvm.bareptr";
+static constexpr StringRef varargsAttrNameNoPrefix = "varargs";
+static constexpr StringRef linkageAttrNameNoPrefix = "linkage";
+static constexpr StringRef barePtrAttrNameNoPrefix = "bareptr";
+
/// Return `true` if the `op` should use bare pointer calling convention.
static bool shouldUseBarePtrCallConv(Operation *op,
const LLVMTypeConverter *typeConverter) {
- return (op && op->hasAttr(barePtrAttrName)) ||
+ return (op && (op->hasAttr(barePtrAttrName) ||
+ op->hasAttr(barePtrAttrNameNoPrefix))) ||
----------------
joker-eph wrote:
Yes the design is messy.
This part is already hardcoding some of the LLVM func op attributes in a way that is really not good:
```
/// Only retain those attributes that are not constructed by
/// `LLVMFuncOp::build`.
static void filterFuncAttributes(FunctionOpInterface func,
SmallVectorImpl<NamedAttribute> &result) {
for (const NamedAttribute &attr : func->getDiscardableAttrs()) {
if (attr.getName() == linkageAttrName ||
attr.getName() == varargsAttrName ||
attr.getName() == LLVM::LLVMDialect::getReadnoneAttrName())
continue;
result.push_back(attr);
}
}
```
> I do not know of any mechanism to enumerate all ODS-defined attribute names
Actually there is: ` static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() {`.
We could update the `filterFuncAttributes` to use `LLVMFuncOp::getAttributeNames()` instead of these three hardcoded names?
https://github.com/llvm/llvm-project/pull/182987
More information about the Mlir-commits
mailing list