[flang-commits] [flang] [flang] fix a dangling else in allOtherUsesAreSafeForAssociate (PR #189748)
via flang-commits
flang-commits at lists.llvm.org
Tue Mar 31 13:54:39 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: yebinchon
<details>
<summary>Changes</summary>
Fix a dangling if condition in allOtherUsesAreSafeForAssociate that caused isBeforeInBlock to be called even when instructions were known to not be in the same block, triggering an assertion. The condition was changed to else if and added brackets.
---
Full diff: https://github.com/llvm/llvm-project/pull/189748.diff
1 Files Affected:
- (modified) flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp (+3-2)
``````````diff
diff --git a/flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp b/flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp
index 53ff13f5a9d28..35cbdd59cf5d8 100644
--- a/flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp
+++ b/flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp
@@ -382,11 +382,12 @@ static bool allOtherUsesAreSafeForAssociate(mlir::Value value,
if (!endAssociate)
continue;
// If useOp dominates the endAssociate, then it is definitely safe.
- if (useOp->getBlock() != endAssociate->getBlock())
+ if (useOp->getBlock() != endAssociate->getBlock()) {
if (mlir::DominanceInfo{}.dominates(useOp, endAssociate))
continue;
- if (useOp->isBeforeInBlock(endAssociate))
+ } else if (useOp->isBeforeInBlock(endAssociate)) {
continue;
+ }
}
return false;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/189748
More information about the flang-commits
mailing list