[clang] 8e4b90f - [clang][StaticAnalyzer] Optimize standard-library summaries for size (#202662)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 10 07:14:54 PDT 2026


Author: David Zbarsky
Date: 2026-06-10T15:14:48+01:00
New Revision: 8e4b90f8cae583e3f7212b30c2c86c5b0fcb7499

URL: https://github.com/llvm/llvm-project/commit/8e4b90f8cae583e3f7212b30c2c86c5b0fcb7499
DIFF: https://github.com/llvm/llvm-project/commit/8e4b90f8cae583e3f7212b30c2c86c5b0fcb7499.diff

LOG: [clang][StaticAnalyzer] Optimize standard-library summaries for size (#202662)

StdLibraryFunctionsChecker::initFunctionSummaries is a large one-time
initialization routine. Its initializer-list construction is cold, but
optimizing it for speed causes extensive inlining and repeated
construction code in the binary.

Mark initFunctionSummaries with LLVM_ATTRIBUTE_MINSIZE so the optimizer
keeps the existing table construction out of line and selects
size-oriented code generation. Analyzer behavior and the runtime summary
representation are unchanged.

In the LLVM 22 Bazel build, standalone clang decreases from 130,098,288
to 130,015,696 bytes (-82,592), and stripped clang decreases from
108,098,128 to 107,999,520 bytes (-98,608).

Work towards #202616

AI tool disclosure: Co-authored with OpenAI Codex.

Added: 
    

Modified: 
    clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index ae076626cbcec..50b34cb181ca5 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -851,7 +851,7 @@ class StdLibraryFunctionsChecker
   std::optional<Summary> findFunctionSummary(const CallEvent &Call,
                                              CheckerContext &C) const;
 
-  void initFunctionSummaries(CheckerContext &C) const;
+  LLVM_ATTRIBUTE_MINSIZE void initFunctionSummaries(CheckerContext &C) const;
 
   void reportBug(const CallEvent &Call, ExplodedNode *N,
                  const ValueConstraint *VC, const ValueConstraint *NegatedVC,


        


More information about the cfe-commits mailing list