[Mlir-commits] [mlir] [mlir][llvm] Improve alloca handling during inlining (PR #75961)

Tobias Gysi llvmlistbot at llvm.org
Wed Dec 20 01:38:03 PST 2023


================
@@ -50,11 +50,29 @@ static bool hasLifetimeMarkers(LLVM::AllocaOp allocaOp) {
 static void
 handleInlinedAllocas(Operation *call,
                      iterator_range<Region::iterator> inlinedBlocks) {
+  // The traversal's objective is to locate the entry block of the closest call
+  // site ancestor that has the automatic allocation scope trait. In pure LLVM
+  // dialect programs, this is the LLVM function containing the call site.
+  // However, mixed dialect programs may have other allocation scopes.
+  assert(call->getParentWithTrait<OpTrait::AutomaticAllocationScope>() &&
+         "expected call site to be in an automatic allocation scope");
----------------
gysit wrote:

I can drop the assertion since the code below will conservatively not relocate the allocas in this case. I think the LLVM dialect interface is selected based on the call operation. So the call itself may indeed be nested inside a function operation that does not have the AutomaticAllocationScope trait.

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


More information about the Mlir-commits mailing list