[llvm] [SampleProfileLoader] Fix integer overflow in generateMDProfMetadata (PR #90217)

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 29 02:23:52 PDT 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 1c8ba24da884b612125aafed98f67f41883dc24c 7f87640843b7f96f615df40478a3ed908dc6185e -- llvm/lib/Transforms/IPO/SampleProfile.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index a5ab2b5386..950458324e 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -1720,8 +1720,8 @@ void SampleProfileLoader::generateMDProfMetadata(Function &F) {
         // Weight is added by one to avoid propagation errors introduced by
         // 0 weights.
         Weights.push_back(static_cast<uint32_t>(
-          Weight == std::numeric_limits<uint32_t>::max() ? Weight : Weight + 1
-        ));
+            Weight == std::numeric_limits<uint32_t>::max() ? Weight
+                                                           : Weight + 1));
       } else {
         // Profi creates proper weights that do not require "+1" adjustments but
         // we evenly split the weight among branches with the same destination.

``````````

</details>


https://github.com/llvm/llvm-project/pull/90217


More information about the llvm-commits mailing list