[Mlir-commits] [mlir] [MLIR] Handle call site locations when inlining (PR #132247)
Johannes de Fine Licht
llvmlistbot at llvm.org
Fri Mar 21 02:22:15 PDT 2025
================
@@ -25,6 +25,31 @@
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 single `CallSiteLoc` is created, representing a direct call
+/// from `caller` to `callee`.
+static LocationAttr stackLocations(Location callee, Location caller) {
+ if (!isa<CallSiteLoc>(callee))
+ return CallSiteLoc::get(callee, caller);
+
+ SmallVector<CallSiteLoc> calleeInliningStack = {cast<CallSiteLoc>(callee)};
+ while (auto nextCallSite =
+ dyn_cast<CallSiteLoc>(calleeInliningStack.back().getCaller()))
+ calleeInliningStack.push_back(nextCallSite);
+
+ CallSiteLoc outermostCallSite =
+ CallSiteLoc::get(calleeInliningStack.back().getCaller(), caller);
+ for (auto currentCallSite : reverse(calleeInliningStack))
----------------
definelicht wrote:
```suggestion
for (CallSiteLoc currentCallSite : reverse(calleeInliningStack))
```
https://github.com/llvm/llvm-project/pull/132247
More information about the Mlir-commits
mailing list