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

[BOLT][NFC] Simplify CFG validation #91977

Merged
merged 1 commit into from
May 14, 2024
Merged

Conversation

urnathan
Copy link
Contributor

I noticed this Valid local had one use, whereas the rest of the function just directly returned false on failure

@urnathan urnathan marked this pull request as ready for review May 13, 2024 17:16
@llvmbot llvmbot added the BOLT label May 13, 2024
@llvmbot
Copy link

llvmbot commented May 13, 2024

@llvm/pr-subscribers-bolt

Author: Nathan Sidwell (urnathan)

Changes

I noticed this Valid local had one use, whereas the rest of the function just directly returned false on failure


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

1 Files Affected:

  • (modified) bolt/lib/Core/BinaryFunction.cpp (+3-6)
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index de34421ebeb08..4f44ba0d970c0 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -3252,12 +3252,9 @@ bool BinaryFunction::validateCFG() const {
   if (CurrentState == State::CFG_Finalized)
     return true;
 
-  bool Valid = true;
   for (BinaryBasicBlock *BB : BasicBlocks)
-    Valid &= BB->validateSuccessorInvariants();
-
-  if (!Valid)
-    return Valid;
+    if (!BB->validateSuccessorInvariants())
+      return false;
 
   // Make sure all blocks in CFG are valid.
   auto validateBlock = [this](const BinaryBasicBlock *BB, StringRef Desc) {
@@ -3326,7 +3323,7 @@ bool BinaryFunction::validateCFG() const {
     }
   }
 
-  return Valid;
+  return true;
 }
 
 void BinaryFunction::fixBranches() {

@urnathan urnathan merged commit 725014d into llvm:main May 14, 2024
8 checks passed
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.

3 participants