Author: Kashika Akhouri Date: 2026-01-08T22:54:19+05:30 New Revision: 11dcb756c6ddcd6593dabb6d661347aee40da6a3
URL: https://github.com/llvm/llvm-project/commit/11dcb756c6ddcd6593dabb6d661347aee40da6a3 DIFF: https://github.com/llvm/llvm-project/commit/11dcb756c6ddcd6593dabb6d661347aee40da6a3.diff LOG: Add time trace scopes to addToCallGraph & getCFG (#174717) This PR adds performance instrumentation to `clang::CallGraph` and `clang::CFG` to aid in benchmarking the overhead of call graph construction and CFG rebuilding. This aims to facilitate benchmarking on large codebases like LLVM to ensure that the performance impact of new analysis-based warnings remains within acceptable regressions. Added: Modified: clang/include/clang/Analysis/CallGraph.h clang/lib/Analysis/CFG.cpp clang/unittests/Support/TimeProfilerTest.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Analysis/CallGraph.h b/clang/include/clang/Analysis/CallGraph.h index c11d163f8fe20..f1c0d7a88643a 100644 --- a/clang/include/clang/Analysis/CallGraph.h +++ b/clang/include/clang/Analysis/CallGraph.h @@ -26,6 +26,7 @@ #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/iterator_range.h" +#include "llvm/Support/TimeProfiler.h" #include <memory> namespace clang { @@ -61,6 +62,7 @@ class CallGraph : public DynamicRecursiveASTVisitor { /// /// Recursively walks the declaration to find all the dependent Decls as well. void addToCallGraph(Decl *D) { + llvm::TimeTraceScope TimeProfile("AddToCallGraph"); TraverseDecl(D); } diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 6afbfd9bb7351..f8a2afec79700 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -52,6 +52,7 @@ #include "llvm/Support/Format.h" #include "llvm/Support/GraphWriter.h" #include "llvm/Support/SaveAndRestore.h" +#include "llvm/Support/TimeProfiler.h" #include "llvm/Support/raw_ostream.h" #include <cassert> #include <memory> @@ -5359,6 +5360,7 @@ CFGBlock *CFG::createBlock() { /// buildCFG - Constructs a CFG from an AST. std::unique_ptr<CFG> CFG::buildCFG(const Decl *D, Stmt *Statement, ASTContext *C, const BuildOptions &BO) { + llvm::TimeTraceScope TimeProfile("BuildCFG"); CFGBuilder Builder(C, BO); return Builder.buildCFG(D, Statement); } diff --git a/clang/unittests/Support/TimeProfilerTest.cpp b/clang/unittests/Support/TimeProfilerTest.cpp index e9597948dc22b..5eacae6d200eb 100644 --- a/clang/unittests/Support/TimeProfilerTest.cpp +++ b/clang/unittests/Support/TimeProfilerTest.cpp @@ -333,8 +333,10 @@ Frontend (test.cc) | | InstantiateFunction (fooA<int>, a.h:7) | | | InstantiateFunction (fooB<int>, b.h:8) | | | | DeferInstantiation (fooC<int>) +| | | | BuildCFG | | | DeferInstantiation (fooMTA<int>) | | | InstantiateFunction (fooC<int>, b.h:3) +| | | | BuildCFG | | | InstantiateFunction (fooMTA<int>, a.h:4) )", buildTraceGraph(Json)); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
