[Mlir-commits] [mlir] [mlir][Func] Preserve attribute when converting CallOp/ReturnOp signature (PR #127772)
Matthias Springer
llvmlistbot at llvm.org
Wed Mar 5 06:59:47 PST 2025
================
@@ -126,8 +127,9 @@ class ReturnOpTypeConversion : public OpConversionPattern<ReturnOp> {
LogicalResult
matchAndRewrite(ReturnOp op, OneToNOpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const final {
- rewriter.replaceOpWithNewOp<ReturnOp>(op,
- flattenValues(adaptor.getOperands()));
+ rewriter
+ .replaceOpWithNewOp<ReturnOp>(op, flattenValues(adaptor.getOperands()))
+ ->setAttrs(op->getAttrs());
----------------
matthias-springer wrote:
It wouldn't work with any upstream MLIR passes. This can only be done in a downstream project. E.g., there's no way to inject attribute conversion rules into the upstream `-canonicalize` pass. (Unless we expose it as a pass option that can only be set from C++ but not from the command line.)
Instead, users would write their own canonicalizer pass that has a custom greedy config with these conversion rules.
Interestingly, so far, this issue has only come up with patterns.
https://github.com/llvm/llvm-project/pull/127772
More information about the Mlir-commits
mailing list