[llvm] [BOLT][rewrite] warn about functions without CFG before binary analyses. (PR #197294)

Anatoly Trosinenko via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 03:30:54 PDT 2026


================
@@ -3888,8 +3888,24 @@ void RewriteInstance::runBinaryAnalyses() {
   NamedRegionTimer T("runBinaryAnalyses", "run binary analysis passes",
                      TimerGroupName, TimerGroupDesc, opts::TimeRewrite);
   BinaryFunctionPassManager Manager(*BC);
-  // FIXME: add a pass that warns about which functions do not have CFG,
-  // and therefore, analysis is most likely to be less accurate.
+
+  // Warn about functions without a reconstructed CFG: binary analyses degrade
+  // in accuracy on those and may produce false negatives.
+  uint64_t NoCFGCount = 0;
+  for (const auto &BFI : BC->getBinaryFunctions()) {
+    const BinaryFunction &BF = BFI.second;
+    if (BF.isIgnored() || BF.hasCFG())
+      continue;
+    ++NoCFGCount;
+    if (opts::Verbosity >= 1)
+      BC->errs() << "BOLT-WARNING: no CFG for " << BF
+                 << "; binary analyses may be imprecise\n";
+  }
+  if (NoCFGCount)
+    BC->errs() << "BOLT-WARNING: " << NoCFGCount
+               << " function(s) lack CFG; binary-analysis results may be"
+                  " incomplete. Re-run with -v=1 to list them.\n";
----------------
atrosinenko wrote:

[nit] `s/list them/list these functions`?

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


More information about the llvm-commits mailing list