Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/18.x: [ODS][NFC] Cast range.size() to int32_t in accumulation (#85629) #86677

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

llvmbot
Copy link
Collaborator

@llvmbot llvmbot commented Mar 26, 2024

Backport bce1703

Requested by: @EugeneZelenko

@llvmbot llvmbot added this to the LLVM 18.X Release milestone Mar 26, 2024
@llvmbot
Copy link
Collaborator Author

llvmbot commented Mar 26, 2024

@joker-eph What do you think about merging this PR to the release branch?

@llvmbot
Copy link
Collaborator Author

llvmbot commented Mar 26, 2024

@llvm/pr-subscribers-mlir-core

@llvm/pr-subscribers-mlir

Author: None (llvmbot)

Changes

Backport bce1703

Requested by: @EugeneZelenko


Full diff: https://github.com/llvm/llvm-project/pull/86677.diff

1 Files Affected:

  • (modified) mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp (+1-1)
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 71326049af0579..7f748cfbd31ad4 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -3058,7 +3058,7 @@ void OpEmitter::genCodeForAddingArgAndRegionForBuilder(
         body << llvm::formatv(
             "static_cast<int32_t>(std::accumulate({0}.begin(), {0}.end(), 0, "
             "[](int32_t curSum, ::mlir::ValueRange range) {{ return curSum + "
-            "range.size(); }))",
+            "static_cast<int32_t>(range.size()); }))",
             operandName);
       } else {
         body << "static_cast<int32_t>(" << getArgumentName(op, i) << ".size())";

@tstellar
Copy link
Collaborator

Hi @EugeneZelenko (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix.

Using range.size() "as is" means we accumulate 'size_t' values into
'int32_t' variable. This may produce narrowing conversion warnings
(particularly, on MSVC). The surrounding code seems to cast <x>.size()
to 'int32_t' so following this practice seems safe enough.

Co-authored-by: Ovidiu Pintican <ovidiu.pintican@intel.com>
(cherry picked from commit bce1703)
@tstellar tstellar merged commit 7c7c3d4 into llvm:release/18.x Mar 27, 2024
3 of 4 checks passed
@EugeneZelenko
Copy link
Contributor

@andrey-golubev: Please answer @tstellar question. I just added proper cherry-pick command in issue.

@andrey-golubev
Copy link
Contributor

Hi @EugeneZelenko (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix.

hi! @tstellar I don't think it's worth it: this is a tiny narrowing conversion warnings suppression (by adding explicit static cast), so not worth it to make it into release notes.

@tstellar
Copy link
Collaborator

@andrey-golubev OK, no problem. I don't expect a release note entry for every change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure mlir
Projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants