[Mlir-commits] [mlir] [mlir][memref] Avoid overflow in mem2reg alloca checks (PR #205245)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Jun 22 23:02:32 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/MemRef/IR/MemRefMemorySlot.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/MemRef/IR/MemRefMemorySlot.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefMemorySlot.cpp
index 69cffde01..d3b62a90a 100644
--- a/mlir/lib/Dialect/MemRef/IR/MemRefMemorySlot.cpp
+++ b/mlir/lib/Dialect/MemRef/IR/MemRefMemorySlot.cpp
@@ -67,7 +67,8 @@ SmallVector<MemorySlot> memref::AllocaOp::getPromotableSlots() {
if (!type.hasStaticShape())
return {};
// Make sure the memref contains only a single element.
- std::optional<int64_t> numElements = ShapedType::tryGetNumElements(type.getShape());
+ std::optional<int64_t> numElements =
+ ShapedType::tryGetNumElements(type.getShape());
if (!numElements || *numElements != 1)
return {};
@@ -293,8 +294,10 @@ struct MemRefDestructurableTypeExternalModel
constexpr int64_t maxMemrefSizeForDestructuring = 16;
if (!memrefType.hasStaticShape())
return {};
- std::optional<int64_t> numElements = ShapedType::tryGetNumElements(memrefType.getShape());
- if (!numElements || *numElements > maxMemrefSizeForDestructuring || *numElements == 1)
+ std::optional<int64_t> numElements =
+ ShapedType::tryGetNumElements(memrefType.getShape());
+ if (!numElements || *numElements > maxMemrefSizeForDestructuring ||
+ *numElements == 1)
return {};
DenseMap<Attribute, Type> destructured;
``````````
</details>
https://github.com/llvm/llvm-project/pull/205245
More information about the Mlir-commits
mailing list