Skip to content

Conversation

@boomanaiden154
Copy link
Contributor

I think this is quite a bit more readable than the nested conditionals. From review feedback that was not addressed precommitn in #167973.

I think this is quite a bit more readable than the nested conditionals.
From review feedback that was not addressed precommitn in llvm#167973.
@llvmbot
Copy link
Member

llvmbot commented Nov 14, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Aiden Grossman (boomanaiden154)

Changes

I think this is quite a bit more readable than the nested conditionals. From review feedback that was not addressed precommitn in #167973.


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

1 Files Affected:

  • (modified) llvm/lib/Transforms/Utils/ProfileVerify.cpp (+16-10)
diff --git a/llvm/lib/Transforms/Utils/ProfileVerify.cpp b/llvm/lib/Transforms/Utils/ProfileVerify.cpp
index 149c0879edcdd..c7cf8256d393c 100644
--- a/llvm/lib/Transforms/Utils/ProfileVerify.cpp
+++ b/llvm/lib/Transforms/Utils/ProfileVerify.cpp
@@ -102,11 +102,14 @@ bool ProfileInjector::inject() {
   for (auto &BB : F) {
     if (AnnotateSelect) {
       for (auto &I : BB) {
-        if (auto *SI = dyn_cast<SelectInst>(&I))
-          if (!SI->getCondition()->getType()->isVectorTy() &&
-              !I.getMetadata(LLVMContext::MD_prof))
-            setBranchWeights(I, {SelectTrueWeight, SelectFalseWeight},
-                             /*IsExpected=*/false);
+        if (auto *SI = dyn_cast<SelectInst>(&I)) {
+          if (SI->getCondition()->getType()->isVectorTy())
+            continue;
+          if (I.getMetadata(LLVMContext::MD_prof))
+            continue;
+          setBranchWeights(I, {SelectTrueWeight, SelectFalseWeight},
+                           /*IsExpected=*/false);
+        }
       }
     }
     auto *Term = getTerminatorBenefitingFromMDProf(BB);
@@ -187,11 +190,14 @@ PreservedAnalyses ProfileVerifierPass::run(Function &F,
   for (const auto &BB : F) {
     if (AnnotateSelect) {
       for (const auto &I : BB)
-        if (auto *SI = dyn_cast<SelectInst>(&I))
-          if (!SI->getCondition()->getType()->isVectorTy() &&
-              !I.getMetadata(LLVMContext::MD_prof))
-            F.getContext().emitError(
-                "Profile verification failed: select annotation missing");
+        if (auto *SI = dyn_cast<SelectInst>(&I)) {
+          if (SI->getCondition()->getType()->isVectorTy())
+            continue;
+          if (I.getMetadata(LLVMContext::MD_prof))
+            continue;
+          F.getContext().emitError(
+              "Profile verification failed: select annotation missing");
+        }
     }
     if (const auto *Term =
             ProfileInjector::getTerminatorBenefitingFromMDProf(BB))

@boomanaiden154 boomanaiden154 merged commit 4c4ffd3 into llvm:main Nov 14, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants