llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-static-analyzer-1 Author: Gábor Horváth (Xazax-hun) <details> <summary>Changes</summary> runCheckersForBlockEntrance created a PrettyStackTraceFormat on every block edge. It formats its message eagerly with two vsnprintf calls, and the message does not fit its inline buffer, so it also allocated each time. Use a small PrettyStackTraceEntry subclass that keeps a reference to the BlockEntrance and formats the same text only when a crash trace is printed. On some LLVM TUs (GVN, LiveVariables, RegionStore, SemaExpr) this reduces the instructions of the static analyzer by 0.6-1.0%. The cycles and peak memory changes are within noise. The diagnostics are unchanged. Assisted-by: Claude Opus 5.5 --- Full diff: https://github.com/llvm/llvm-project/pull/244841.diff 1 Files Affected: - (modified) clang/lib/StaticAnalyzer/Core/ExprEngine.cpp (+17-4) ``````````diff diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index e19be8c3a7b376..4293e175229634 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -2515,13 +2515,26 @@ ExplodedNode *ExprEngine::processCFGBlockEntrance(const BlockEntrance &BE, return nullptr; } +namespace { +class PrettyStackTraceBlockEntrance : public llvm::PrettyStackTraceEntry { + const BlockEntrance &Entrance; + +public: + PrettyStackTraceBlockEntrance(const BlockEntrance &Entrance) + : Entrance(Entrance) {} + + void print(raw_ostream &OS) const override { + OS << "Processing block entrance B" + << Entrance.getPreviousBlock()->getBlockID() << " -> B" + << Entrance.getBlock()->getBlockID() << "\n"; + } +}; +} // namespace + void ExprEngine::runCheckersForBlockEntrance(const BlockEntrance &Entrance, ExplodedNode *Pred, ExplodedNodeSet &Dst) { - llvm::PrettyStackTraceFormat CrashInfo( - "Processing block entrance B%d -> B%d", - Entrance.getPreviousBlock()->getBlockID(), - Entrance.getBlock()->getBlockID()); + PrettyStackTraceBlockEntrance CrashInfo(Entrance); getCheckerManager().runCheckersForBlockEntrance(Dst, Pred, Entrance, *this); } `````````` </details> https://github.com/llvm/llvm-project/pull/244841 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
