[Mlir-commits] [mlir] [mlir][inliner] optimize self-recursive function detection [NFC] (PR #88452)

Mehdi Amini llvmlistbot at llvm.org
Fri Apr 12 02:00:37 PDT 2024


================
@@ -705,23 +713,30 @@ Inliner::Impl::inlineCallsInSCC(InlinerInterfaceImpl &inlinerIface,
   return success(inlinedAnyCalls);
 }
 
+static bool isSelfRecursiveFunction(CallGraphNode *node) {
+  return llvm::find_if(*node, [&](CallGraphNode::Edge const &edge) -> bool {
+           return edge.getTarget() == node;
+         }) != node->end();
+}
+
 /// Returns true if the given call should be inlined.
-bool Inliner::Impl::shouldInline(ResolvedCall &resolvedCall) {
+bool Inliner::Impl::shouldInline(
+    ResolvedCall &resolvedCall,
+    llvm::SmallPtrSet<Region *, 16U> const &recursiveCallRegions) {
----------------
joker-eph wrote:

```suggestion
    const llvm::SmallPtrSetImpl<Region> &recursiveCallRegions) {
```

(take the `Impl` class as argument, it's size-independent)

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


More information about the Mlir-commits mailing list