https://github.com/kashika0112 updated 
https://github.com/llvm/llvm-project/pull/174717

>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 1/2] 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.

>From d5e2ab27ed30003a8055692ca27f8f49a5ae9e3d Mon Sep 17 00:00:00 2001
From: Kashika Akhouri <[email protected]>
Date: Wed, 7 Jan 2026 09:59:23 +0000
Subject: [PATCH 2/2] Add BuildCFG in unit tests

---
 clang/unittests/Support/TimeProfilerTest.cpp | 2 ++
 1 file changed, 2 insertions(+)

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

Reply via email to