https://github.com/kashika0112 created https://github.com/llvm/llvm-project/pull/174717
his PR adds performance instrumentation to `clang::CallGraph` and `clang::AnalysisDeclContext` to aid in benchmarking the overhead of call graph construction and CFG rebuilding. Changes - `clang/include/clang/Analysis/CallGraph.h`: Added a TimeTraceScope labeled `AddToCallGraph` to instrument the discovery of function nodes and call edges across the Translation Unit. - `clang/lib/Analysis/AnalysisDeclContext.cpp`: Added a TimeTraceScope labeled `BuildCFG` inside `getCFG()`. The scope is placed within the `!builtCFG` block to measure the actual construction time. 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. >From 5081b26a0e09482911ac0d151a2fd7637d6d43e2 Mon Sep 17 00:00:00 2001 From: Kashika Akhouri <[email protected]> Date: Wed, 7 Jan 2026 09:01:48 +0000 Subject: [PATCH] Add time trace scopes to addToCallGraph & getCFG --- clang/include/clang/Analysis/CallGraph.h | 2 ++ clang/lib/Analysis/AnalysisDeclContext.cpp | 2 ++ 2 files changed, 4 insertions(+) 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/AnalysisDeclContext.cpp b/clang/lib/Analysis/AnalysisDeclContext.cpp index 6f153e7e65255..2985a6e57dc18 100644 --- a/clang/lib/Analysis/AnalysisDeclContext.cpp +++ b/clang/lib/Analysis/AnalysisDeclContext.cpp @@ -42,6 +42,7 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/SaveAndRestore.h" +#include "llvm/Support/TimeProfiler.h" #include "llvm/Support/raw_ostream.h" #include <cassert> #include <memory> @@ -218,6 +219,7 @@ CFG *AnalysisDeclContext::getCFG() { return getUnoptimizedCFG(); if (!builtCFG) { + llvm::TimeTraceScope TimeProfile("BuildCFG"); cfg = CFG::buildCFG(D, getBody(), &D->getASTContext(), cfgBuildOptions); // Even when the cfg is not successfully built, we don't // want to try building it again. _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
