Skip to content

[BOLT] Fix wrong logical-or operator, wrong parenthesis #117156

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ChuvakHome
Copy link
Contributor

Fix for some mistakes in source code found using PVS Studio.

Inspired by: https://pvs-studio.com/en/blog/posts/cpp/1188/

Fixed:

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the BOLT label Nov 21, 2024
@ChuvakHome ChuvakHome mentioned this pull request Nov 21, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 21, 2024

@llvm/pr-subscribers-bolt

Author: Chuvak (ChuvakHome)

Changes

Fix for some mistakes in source code found using PVS Studio.

Inspired by: https://pvs-studio.com/en/blog/posts/cpp/1188/

Fixed:


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

2 Files Affected:

  • (modified) bolt/lib/Passes/ShrinkWrapping.cpp (+2-2)
  • (modified) bolt/lib/Rewrite/LinuxKernelRewriter.cpp (+1-1)
diff --git a/bolt/lib/Passes/ShrinkWrapping.cpp b/bolt/lib/Passes/ShrinkWrapping.cpp
index 176321c58dc903..bc4e7e6e386a0e 100644
--- a/bolt/lib/Passes/ShrinkWrapping.cpp
+++ b/bolt/lib/Passes/ShrinkWrapping.cpp
@@ -78,8 +78,8 @@ void CalleeSavedAnalysis::analyzeSaves() {
         // probably dealing with a parameter passed in a stack -- do not mess
         // with it
         if (SRU.isStoreUsed(*FIE,
-                            Prev ? SRU.expr_begin(*Prev) : SRU.expr_begin(BB)),
-            /*IncludeLocalAccesses=*/false) {
+                            Prev ? SRU.expr_begin(*Prev) : SRU.expr_begin(BB),
+            /*IncludeLocalAccesses=*/false)) {
           BlacklistedRegs.set(FIE->RegOrImm);
           CalleeSaved.reset(FIE->RegOrImm);
           Prev = &Inst;
diff --git a/bolt/lib/Rewrite/LinuxKernelRewriter.cpp b/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
index 03b414b71caca7..39ceeffc79c165 100644
--- a/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
+++ b/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
@@ -580,7 +580,7 @@ Error LinuxKernelRewriter::readORCTables() {
       // As such, we can ignore alternative ORC entries. They will be preserved
       // in the binary, but will not get printed in the instruction stream.
       Inst = BF->getInstructionContainingOffset(Offset);
-      if (Inst || BC.MIB->hasAnnotation(*Inst, "AltInst"))
+      if (Inst && BC.MIB->hasAnnotation(*Inst, "AltInst"))
         continue;
 
       return createStringError(

Copy link

github-actions bot commented Nov 21, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@ChuvakHome ChuvakHome changed the title Fix wrong logical-or operator, wrong parenthesis [BOLT] Fix wrong logical-or operator, wrong parenthesis Nov 21, 2024
Copy link
Contributor

@maksfb maksfb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@RKSimon
Copy link
Collaborator

RKSimon commented Nov 22, 2024

It looks like some of the shrinkwrapping tests need fixing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants