[Mlir-commits] [mlir] [mlir][bufferization] Fix bug when moving dealloc operation (PR #229296)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Oct 5 19:48:20 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/OptimizeAllocationLiveness.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/OptimizeAllocationLiveness.cpp b/mlir/lib/Dialect/Bufferization/Transforms/OptimizeAllocationLiveness.cpp
index d2bebea89..ca3ddc7d0 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/OptimizeAllocationLiveness.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/OptimizeAllocationLiveness.cpp
@@ -108,31 +108,32 @@ struct OptimizeAllocationLiveness
public:
OptimizeAllocationLiveness() = default;
- static Operation* findValidInsertionPoint(Operation *allocOp, Operation *deallocOp, Operation *lastUser) {
+ static Operation *findValidInsertionPoint(Operation *allocOp,
+ Operation *deallocOp,
+ Operation *lastUser) {
auto domInfo = DominanceInfo();
auto *target = lastUser;
- for(Value operand : deallocOp->getOperands()){
+ for (Value operand : deallocOp->getOperands()) {
auto *definingOp = operand.getDefiningOp();
- if(!definingOp)
+ if (!definingOp)
continue;
- if(!target || domInfo.properlyDominates(target, definingOp))
+ if (!target || domInfo.properlyDominates(target, definingOp))
target = definingOp;
}
- if(!target)
+ if (!target)
target = allocOp;
- for(Value result : deallocOp->getResults()) {
- for(Operation* user : result.getUsers()){
- if(user == target || !domInfo.properlyDominates(target, user))
+ for (Value result : deallocOp->getResults()) {
+ for (Operation *user : result.getUsers()) {
+ if (user == target || !domInfo.properlyDominates(target, user))
return nullptr;
}
}
return target;
-
}
void runOnOperation() override {
@@ -190,8 +191,8 @@ public:
assert(lastUser->getBlock() == allocOp->getBlock());
assert(lastUser->getBlock() == deallocOp->getBlock());
- Operation* target = findValidInsertionPoint(allocOp, deallocOp, lastUser);
- if(!target){
+ Operation *target = findValidInsertionPoint(allocOp, deallocOp, lastUser);
+ if (!target) {
LDBG() << "No valid insertion point found; skipping move";
return WalkResult::advance();
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/229296
More information about the Mlir-commits
mailing list