[Mlir-commits] [mlir] [mlir][Func] Preserve attribute when converting CallOp/ReturnOp signature (PR #127772)
Hongren Zheng
llvmlistbot at llvm.org
Wed Feb 19 04:50:10 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:
Or more conversatively we can preserve some dialect attribute?
```cpp
newOp->setDialectAttrs(op->getDialectAttrs())
```
> transformations should discard them when they don't "understand" them (through interfaces or other mechanism).
I have not seen some mechanism for the transformation to query that. For dialect attribute the transformation could query the dialect `namedAttr.getName().getDialect()` but I have not found dialect interface / attribute interface that describe such information.
https://github.com/llvm/llvm-project/pull/127772
More information about the Mlir-commits
mailing list