[Mlir-commits] [mlir] [MLIR] Handle call site locations when inlining (PR #132247)

Christian Ulmann llvmlistbot at llvm.org
Thu Mar 20 10:25:56 PDT 2025


================
@@ -25,6 +25,21 @@
 
 using namespace mlir;
 
+/// Combine `callee` location with `caller` location to create a stack that
+/// represents the call chain.
+/// If `callee` location is a `CallSiteLoc`, indicating an existing stack of
+/// locations, the `caller` location is appended to the end of it, extending
+/// the chain.
+/// Otherwise, a new `CallSiteLoc` is created, representing a direct call from
+/// `caller` to `callee`.
+static LocationAttr stackLocations(Location callee, Location caller) {
+  if (auto calleeCallSite = dyn_cast<CallSiteLoc>(callee)) {
+    return CallSiteLoc::get(calleeCallSite.getCallee(),
+                            stackLocations(calleeCallSite.getCaller(), caller));
+  }
----------------
Dinistro wrote:

Nit: Recursion is a dangerous thing, can you rewrite this iteratively, if possible? 

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


More information about the Mlir-commits mailing list