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/3] 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/3] 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));

>From 241516c298b4a8479b4dda8f38b951a7aa0481d1 Mon Sep 17 00:00:00 2001
From: Kashika Akhouri <[email protected]>
Date: Wed, 7 Jan 2026 11:09:27 +0000
Subject: [PATCH 3/3] Move tracer inside buildCFG

---
 clang/lib/Analysis/AnalysisDeclContext.cpp | 2 --
 clang/lib/Analysis/CFG.cpp                 | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Analysis/AnalysisDeclContext.cpp 
b/clang/lib/Analysis/AnalysisDeclContext.cpp
index 2985a6e57dc18..6f153e7e65255 100644
--- a/clang/lib/Analysis/AnalysisDeclContext.cpp
+++ b/clang/lib/Analysis/AnalysisDeclContext.cpp
@@ -42,7 +42,6 @@
 #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>
@@ -219,7 +218,6 @@ 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.
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);
 }

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to