[Mlir-commits] [mlir] [mlir][bufferization] Handle scf.if deallocs in static memory planner (PR #213634)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Aug 3 02:48:07 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- mlir/lib/Dialect/Bufferization/Transforms/StaticMemoryPlannerAnalysis.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/StaticMemoryPlannerAnalysis.cpp b/mlir/lib/Dialect/Bufferization/Transforms/StaticMemoryPlannerAnalysis.cpp
index 6087e2ff9..4ea31f7d3 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/StaticMemoryPlannerAnalysis.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/StaticMemoryPlannerAnalysis.cpp
@@ -58,16 +58,15 @@ struct AllocationCandidate {
/// - `scf.if`/`scf.for` (via RegionBranchOpInterface region/result wiring)
/// - `cf.br`/`cf.cond_br` (via BranchOpInterface block arguments)
/// - `memref.view`/subview (via ViewLikeOpInterface)
-/// `analysis.resolve(alloc)` returns the forward alias set (the alloc plus every
-/// value it may flow into); a dealloc on any of those aliases frees the alloc.
-/// For example:
+/// `analysis.resolve(alloc)` returns the forward alias set (the alloc plus
+/// every value it may flow into); a dealloc on any of those aliases frees the
+/// alloc. For example:
/// %0 = memref.alloc()
/// %2 = arith.select %c, %0, %1
/// memref.dealloc %2 <- covers %0 conditionally (via alias set)
/// %3 = scf.if %c { yield %0 } else { yield %1 }
/// memref.dealloc %3 <- also covers %0 conditionally
-static void collectDeallocs(Value alloc,
- const BufferViewFlowAnalysis &analysis,
+static void collectDeallocs(Value alloc, const BufferViewFlowAnalysis &analysis,
SmallVectorImpl<memref::DeallocOp> &deallocs) {
for (Value alias : analysis.resolve(alloc))
for (Operation *user : alias.getUsers())
@@ -154,8 +153,8 @@ static int64_t buildAllocInfos(
static LogicalResult
collectCandidates(FunctionOpInterface funcOp,
const BufferViewFlowAnalysis &analysis,
- llvm::Statistic &numSkipDynamic, llvm::Statistic &numSkipNested,
- llvm::Statistic &numEligible,
+ llvm::Statistic &numSkipDynamic,
+ llvm::Statistic &numSkipNested, llvm::Statistic &numEligible,
SmallVector<AllocationCandidate> &candidates) {
// All candidates are planned relative to the function's entry block.
if (funcOp.getFunctionBody().empty())
``````````
</details>
https://github.com/llvm/llvm-project/pull/213634
More information about the Mlir-commits
mailing list