[llvm] [PGOVerify] Add end-to-end IPGOVerifier infrastructure, validations, and function filtering (PR #196295)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 7 05:16:36 PDT 2026


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 origin/main HEAD --extensions h,cpp -- llvm/include/llvm/Transforms/IPO/PGOVerify.h llvm/lib/Transforms/IPO/PGOVerify.cpp llvm/unittests/Transforms/IPO/PGOVerifyTest.cpp llvm/include/llvm/Passes/StandardInstrumentations.h llvm/lib/Passes/StandardInstrumentations.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
diff --git a/llvm/include/llvm/Transforms/IPO/PGOVerify.h b/llvm/include/llvm/Transforms/IPO/PGOVerify.h
index 0e5bdf1c1..e6c6e073e 100644
--- a/llvm/include/llvm/Transforms/IPO/PGOVerify.h
+++ b/llvm/include/llvm/Transforms/IPO/PGOVerify.h
@@ -98,7 +98,8 @@ private:
   ///
   /// \return `true` if a possible overflow is detected for \p F, otherwise
   ///         `false`.
-  bool hasFunctionLocalCountOverflow(const Function *F, const llvm::BlockFrequencyInfo&) const;
+  bool hasFunctionLocalCountOverflow(const Function *F,
+                                     const llvm::BlockFrequencyInfo &) const;
 
   /// Check whether a module carries an instrumentation-profile use summary.
   ///
diff --git a/llvm/lib/Transforms/IPO/PGOVerify.cpp b/llvm/lib/Transforms/IPO/PGOVerify.cpp
index 6dedf0093..57e776fd6 100644
--- a/llvm/lib/Transforms/IPO/PGOVerify.cpp
+++ b/llvm/lib/Transforms/IPO/PGOVerify.cpp
@@ -42,8 +42,8 @@ static cl::opt<bool>
                cl::desc("Enable Instrumented PGO verification"));
 
 static cl::list<std::string>
-  VerifyIPGOFuncList("verify-ipgo-funcs", cl::Hidden,
-             cl::desc("Comma-separated list of functions to verify"));
+    VerifyIPGOFuncList("verify-ipgo-funcs", cl::Hidden,
+                       cl::desc("Comma-separated list of functions to verify"));
 
 /// Emit PGO verification diagnostics with structured formatting.
 ///
@@ -400,15 +400,14 @@ IPGOVerifier::getCachedBlockFreqInfo(const Function *F) const {
   return &It->second;
 }
 
-bool IPGOVerifier::hasFunctionLocalCountOverflow(const Function *F,
-                                           const BlockFrequencyInfo &BFI) const {
+bool IPGOVerifier::hasFunctionLocalCountOverflow(
+    const Function *F, const BlockFrequencyInfo &BFI) const {
   constexpr uint64_t UInt32Max = std::numeric_limits<uint32_t>::max();
 
   if (auto EntryCount = F->getEntryCount();
       EntryCount && EntryCount->getCount() > UInt32Max)
     return true;
 
-
   bool HasUnknownBlockCount = false;
   for (const BasicBlock &BB : *F) {
     if (&BB == &F->getEntryBlock())
@@ -538,8 +537,8 @@ void IPGOVerifier::validateBlockFrequencies(const Function *F) {
       if (VerifyIPGOPrintDiagnostics)
         errs() << "PGOVerify# Block frequency mismatch in function "
                << F->getName() << ", block " << BB.getName()
-               << ":  Incoming=" << Info.sumIn
-               << ":  Outgoing=" << Info.sumOut << "\n";
+               << ":  Incoming=" << Info.sumIn << ":  Outgoing=" << Info.sumOut
+               << "\n";
       LLVM_DEBUG(dbgs() << "PGOVerify# Block frequency mismatch in function "
                         << F->getName() << ", block " << BB.getName()
                         << ":  Incoming=" << Info.sumIn
@@ -627,18 +626,17 @@ void IPGOVerifier::validateEntryCountAgainstCallerSum(const Function *F) {
                       << F->getName() << " Entry=" << EntryCount
                       << " CallerSiteSum=" << Sum
                       << " (unreliable for recursion)\n");
-    emitPGOVerifyDiagnostic(
-        F, "EntryCountMismatch",
-        "EntryCount mismatch (recursive function): entry=" +
-            std::to_string(EntryCount) + " vs caller-sum=" +
-            std::to_string(Sum));
+    emitPGOVerifyDiagnostic(F, "EntryCountMismatch",
+                            "EntryCount mismatch (recursive function): entry=" +
+                                std::to_string(EntryCount) +
+                                " vs caller-sum=" + std::to_string(Sum));
   } else {
     LLVM_DEBUG(dbgs() << "PGOVerify# Entry count mismatch in function "
                       << F->getName() << ":  Entry=" << EntryCount
                       << ":  CallerSum=" << Sum << "\n");
-    emitPGOVerifyDiagnostic(F, "EntryCountMismatch",
-                            "Entry count mismatch: entry=" +
-                                std::to_string(EntryCount) +
-                                " vs caller-sum=" + std::to_string(Sum));
+    emitPGOVerifyDiagnostic(
+        F, "EntryCountMismatch",
+        "Entry count mismatch: entry=" + std::to_string(EntryCount) +
+            " vs caller-sum=" + std::to_string(Sum));
   }
 }

``````````

</details>


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


More information about the llvm-commits mailing list