[flang-commits] [flang] [mlir] [MLIR][ODS] Add support for overloading interface methods (PR #161828)
Quinn Dawkins via flang-commits
flang-commits at lists.llvm.org
Mon Nov 3 12:57:45 PST 2025
qedawkins wrote:
This change is causing stale `.h.inc` build failures when adding an interface method with default impl, rebuilding, then removing the interface method. For example, if I apply
```
diff --git a/compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/UKernelOps.td b/compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/UKernelOps.td
index ce14b80d83..410043752b 100644
--- a/compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/UKernelOps.td
+++ b/compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/UKernelOps.td
@@ -93,6 +93,7 @@ def IREECodegen_UKernelGenericOp :
// the `strided_dims` attribute is null.
// - Returns the corresponding dim list in `strided_dims` for ShapedType
// operands if `strided_dims` is not null.
+ //
SmallVector<int64_t> getOperandStridedDims(int64_t operandIdx);
}];
}
diff --git a/compiler/src/iree/compiler/Codegen/Interfaces/UKernelOpInterface.td b/compiler/src/iree/compiler/Codegen/Interfaces/UKernelOpInterface.td
index f5667c996e..eb4d218487 100644
--- a/compiler/src/iree/compiler/Codegen/Interfaces/UKernelOpInterface.td
+++ b/compiler/src/iree/compiler/Codegen/Interfaces/UKernelOpInterface.td
@@ -24,7 +24,17 @@ def UKernelOpInterface : OpInterface<"UKernelOpInterface"> {
/*methodName=*/"lowerToFunctionCall",
/*args=*/(ins "RewriterBase &":$rewriter),
/*methodBody=*/"",
/*defautImplementation=*/"return failure();"
+ >,
+ InterfaceMethod<
+ /*desc=*/[{
+ Copy of the above.
+ }],
+ /*retType=*/"FailureOr<mlir::CallOpInterface>",
+ /*methodName=*/"lowerToFunctionCall2",
+ /*args=*/(ins "RewriterBase &":$rewriter),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/"return failure();"
>,
];
}
```
downstream in IREE, rebuild, then remove the new interface method and rebuild again I get something like
```
/home/quinn/iree-build/compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/UKernelOps.h.inc:219:92: error: no member named 'lowerToFunctionCall2' in 'mlir::iree_compiler::IREE::Codegen::UKernelOpInterface::Trait<mlir::iree_compiler::IREE::Codegen::UKernelGenericOp>';
```
due to the `using` lines added here https://github.com/llvm/llvm-project/pull/161828/files#diff-9185f7f3f3628467e62e1712b01efc482eecc3643b67746c1eae73f5fd272138R3688.
I was able to repro this with TilingInterface + Linalg as well. The problem is that when a new interface method is added to the interface but NOT added to `Declare*InterfaceMethods`, these `using` lines are generated only when the interface implementer's tablegen changes because deps between `.h.inc` files appear to be order only.
https://github.com/llvm/llvm-project/pull/161828
More information about the flang-commits
mailing list