https://github.com/philnik777 updated 
https://github.com/llvm/llvm-project/pull/218112

>From aff516a3e11121dc071476264a33982a5009d453 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <[email protected]>
Date: Sat, 22 Aug 2026 10:12:52 +0200
Subject: [PATCH 1/3] [Clang] Add TimeTraceScopes to DeduceTemplateArguments

---
 clang/lib/Sema/SemaTemplateDeduction.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 3c45806c47a6e..e13de97c802b2 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -55,6 +55,7 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/SaveAndRestore.h"
+#include "llvm/Support/TimeProfiler.h"
 #include <algorithm>
 #include <cassert>
 #include <optional>
@@ -4489,6 +4490,10 @@ TemplateDeductionResult Sema::DeduceTemplateArguments(
   if (FunctionTemplate->isInvalidDecl())
     return TemplateDeductionResult::Invalid;
 
+  llvm::TimeTraceScope TimeScope("DeduceTemplateArguments", [&] {
+    return FunctionTemplate->getLocation().printToString(SourceMgr);
+  });
+
   FunctionDecl *Function = FunctionTemplate->getTemplatedDecl();
   unsigned NumParams = Function->getNumParams();
   bool HasExplicitObject = false;
@@ -4772,6 +4777,10 @@ TemplateDeductionResult Sema::DeduceTemplateArguments(
   if (FunctionTemplate->isInvalidDecl())
     return TemplateDeductionResult::Invalid;
 
+  llvm::TimeTraceScope TimeScope("DeduceTemplateArguments", [&] {
+    return FunctionTemplate->getLocation().printToString(SourceMgr);
+  });
+
   FunctionDecl *Function = FunctionTemplate->getTemplatedDecl();
   TemplateParameterList *TemplateParams
     = FunctionTemplate->getTemplateParameters();

>From d5eb098c0348fd7525d9c89865b75a01888c713f Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <[email protected]>
Date: Mon, 24 Aug 2026 09:08:42 +0200
Subject: [PATCH 2/3] Fix test

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

diff --git a/clang/unittests/Support/TimeProfilerTest.cpp 
b/clang/unittests/Support/TimeProfilerTest.cpp
index ae6b16a7377d6..a2d68e4b983f4 100644
--- a/clang/unittests/Support/TimeProfilerTest.cpp
+++ b/clang/unittests/Support/TimeProfilerTest.cpp
@@ -406,12 +406,16 @@ ExecuteCompiler
 | | ParseFunctionDefinition (fooA)
 | | ParseDeclarationOrFunctionDefinition (test.cc:3:5)
 | | | ParseFunctionDefinition (user)
+| | | | DeduceTemplateArguments (./a.h:7:10)
 | | | | DeferInstantiation (fooA<int>)
 | PerformPendingInstantiations
 | | InstantiateFunction (fooA<int>, a.h:7)
+| | | DeduceTemplateArguments (./b.h:8:17)
 | | | InstantiateFunction (fooB<int>, b.h:8)
+| | | | DeduceTemplateArguments (./b.h:3:7)
 | | | | DeferInstantiation (fooC<int>)
 | | | | BuildCFG
+| | | DeduceTemplateArguments (./a.h:4:5 <Spelling=<scratch space>:4:1>)
 | | | DeferInstantiation (fooMTA<int>)
 | | | InstantiateFunction (fooC<int>, b.h:3)
 | | | | BuildCFG

>From bea4f099a3f3775e714f28b19a74e352103e35c1 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <[email protected]>
Date: Mon, 24 Aug 2026 11:27:49 +0200
Subject: [PATCH 3/3] Use ifdef

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

diff --git a/clang/unittests/Support/TimeProfilerTest.cpp 
b/clang/unittests/Support/TimeProfilerTest.cpp
index a2d68e4b983f4..b4228f623e0bb 100644
--- a/clang/unittests/Support/TimeProfilerTest.cpp
+++ b/clang/unittests/Support/TimeProfilerTest.cpp
@@ -397,6 +397,7 @@ TEST(TimeProfilerTest, TemplateInstantiations) {
   ASSERT_TRUE(compileFromString(Code, "-std=c++20", "test.cc",
                                 /*Headers=*/{{"a.h", A_H}, {"b.h", B_H}}));
   std::string Json = teardownProfiler();
+#ifdef _WIN32
   ASSERT_EQ(R"(
 ExecuteCompiler
 | Frontend (test.cc)
@@ -422,6 +423,33 @@ ExecuteCompiler
 | | | InstantiateFunction (fooMTA<int>, a.h:4)
 )",
             buildTraceGraph(Json));
+#else
+  ASSERT_EQ(R"(
+ExecuteCompiler
+| Frontend (test.cc)
+| | ParseFunctionDefinition (fooC)
+| | ParseFunctionDefinition (fooB)
+| | ParseFunctionDefinition (fooMTA)
+| | ParseFunctionDefinition (fooA)
+| | ParseDeclarationOrFunctionDefinition (test.cc:3:5)
+| | | ParseFunctionDefinition (user)
+| | | | DeduceTemplateArguments (.\\a.h:7:10)
+| | | | DeferInstantiation (fooA<int>)
+| PerformPendingInstantiations
+| | InstantiateFunction (fooA<int>, a.h:7)
+| | | DeduceTemplateArguments (.\\b.h:8:17)
+| | | InstantiateFunction (fooB<int>, b.h:8)
+| | | | DeduceTemplateArguments (.\\b.h:3:7)
+| | | | DeferInstantiation (fooC<int>)
+| | | | BuildCFG
+| | | DeduceTemplateArguments (.\\a.h:4:5 <Spelling=<scratch space>:4:1>)
+| | | DeferInstantiation (fooMTA<int>)
+| | | InstantiateFunction (fooC<int>, b.h:3)
+| | | | BuildCFG
+| | | InstantiateFunction (fooMTA<int>, a.h:4)
+)",
+            buildTraceGraph(Json));
+#endif
 }
 
 static SpecializationCounts

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

Reply via email to