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

Hongren Zheng llvmlistbot at llvm.org
Wed Mar 5 07:04:08 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());
----------------
ZenithalHourlyRate wrote:

FYI, downstream I am working on now unsafely store and load back the attribute in func.call to work around this issue, with the implicit assumption that walk order is unchanged and no call op is inserted/deleted.

https://github.com/google/heir/blob/b2ab9dcaac644ab8131ed06c4767251f46cf02d8/lib/Dialect/LWE/Conversions/LWEToLattigo/LWEToLattigo.cpp#L511-L540

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


More information about the Mlir-commits mailing list