[Mlir-commits] [mlir] [MLIR][LLVM] Fix memory explosion when converting global variable bodies in ModuleTranslation (PR #82708)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Feb 24 09:30:33 PST 2024
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 307409a8872ff27339d5d5c6a7e7777254972f34 7705e97055ce52b10cf53132a1c5824992bddc65 -- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index dd6482a173..32b16a4dd9 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -1066,15 +1066,15 @@ LogicalResult ModuleTranslation::convertGlobals() {
// to count the number of uses of each constant array and remove it only
// when the count becomes zero.
if (auto *agg = dyn_cast<llvm::ConstantAggregate>(cst)) {
- numConstantsHit++;
- Value result = op.getResult(0);
- int numUsers = std::distance(result.use_begin(), result.use_end());
- auto [iterator, inserted] =
- constantAggregateUseMap.try_emplace(agg, numUsers);
- if (!inserted) {
- // Key already exists, update the value
- iterator->second += numUsers;
- }
+ numConstantsHit++;
+ Value result = op.getResult(0);
+ int numUsers = std::distance(result.use_begin(), result.use_end());
+ auto [iterator, inserted] =
+ constantAggregateUseMap.try_emplace(agg, numUsers);
+ if (!inserted) {
+ // Key already exists, update the value
+ iterator->second += numUsers;
+ }
}
for (Value v : op.getOperands()) {
auto cst = dyn_cast<llvm::ConstantAggregate>(lookupValue(v));
``````````
</details>
https://github.com/llvm/llvm-project/pull/82708
More information about the Mlir-commits
mailing list