[Mlir-commits] [mlir] [mlir][Func] Preserve attribute when converting CallOp/ReturnOp signature (PR #127772)

Mehdi Amini llvmlistbot at llvm.org
Wed Feb 19 04:00:18 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());
----------------
joker-eph wrote:

It's not clear to me that this is always safe: can't the attribute be irrelevant or incorrect post-transformation? For example the number of operands may change but the attribute refers to them positionally.


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


More information about the Mlir-commits mailing list