[Mlir-commits] [mlir] [MLIR][Transform] Don't error when a structurally inlinable call exists (PR #195770)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon May 4 18:21:20 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: William Moses (wsmoses)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/195770.diff
1 Files Affected:
- (modified) mlir/lib/Dialect/Transform/IR/Utils.cpp (+29-1)
``````````diff
diff --git a/mlir/lib/Dialect/Transform/IR/Utils.cpp b/mlir/lib/Dialect/Transform/IR/Utils.cpp
index e9e07692b1ef3..9cdb9edebf17d 100644
--- a/mlir/lib/Dialect/Transform/IR/Utils.cpp
+++ b/mlir/lib/Dialect/Transform/IR/Utils.cpp
@@ -120,6 +120,33 @@ transform::detail::mergeSymbolsInto(Operation *target,
"requires target to implement the 'SymbolTable' trait");
SymbolTable targetSymbolTable(target);
+
+ // Collect all the functions that are called in `target` that cannot be
+ // inlined into `target`.
+ SmallPtrSet<Operation *, 1> noInlineCalls;
+ target->walk([&](CallOpInterface call) {
+ Operation *callable = nullptr;
+ CallInterfaceCallable callee = call.getCallableForCallee();
+ if (auto symRef = dyn_cast<SymbolRefAttr>(callee)) {
+ // Fall back to full resolution for nested symbols, the table is
+ // one-level only.
+ if (isa<FlatSymbolRefAttr>(symRef))
+ callable = targetSymbolTable.lookup(symRef.getLeafReference());
+ else
+ callable = SymbolTable::lookupNearestSymbolFrom(call, symRef);
+ } else if (auto value = dyn_cast<Value>(callee)) {
+ callable = value.getDefiningOp();
+ }
+
+ if (!callable)
+ return;
+
+ if (!inliner.isLegalToInline(call, callable, /*wouldBeCloned=*/false)) {
+ noInlineCalls.insert(callable);
+ }
+ return;
+ });
+
SymbolTable otherSymbolTable(*other);
// Step 1:
@@ -308,7 +335,8 @@ transform::detail::mergeSymbolsInto(Operation *target,
if (!callable)
return WalkResult::advance();
- if (!inliner.isLegalToInline(call, callable, /*wouldBeCloned=*/false)) {
+ if (!noInlineCalls.contains(callable) &&
+ !inliner.isLegalToInline(call, callable, /*wouldBeCloned=*/false)) {
InFlightDiagnostic diag =
call->emitError()
<< "merged call is not legal to inline into its caller";
``````````
</details>
https://github.com/llvm/llvm-project/pull/195770
More information about the Mlir-commits
mailing list