Skip to content

Commit ce86d9d

Browse files
authored
[Clang] Add TimeTraceScope to Sema::CheckConstraintSatisfaction (#170264)
Evaluating concepts can take quite a bit of time and it's not necessarily obvious what's part of that and what not. This scope makes it clear which parts are concept evaluation and where they are invoked.
1 parent 90c340a commit ce86d9d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

clang/lib/Sema/SemaConcept.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "llvm/ADT/PointerUnion.h"
3131
#include "llvm/ADT/StringExtras.h"
3232
#include "llvm/Support/SaveAndRestore.h"
33+
#include "llvm/Support/TimeProfiler.h"
3334

3435
using namespace clang;
3536
using namespace sema;
@@ -1182,6 +1183,10 @@ bool Sema::CheckConstraintSatisfaction(
11821183
const MultiLevelTemplateArgumentList &TemplateArgsLists,
11831184
SourceRange TemplateIDRange, ConstraintSatisfaction &OutSatisfaction,
11841185
const ConceptReference *TopLevelConceptId, Expr **ConvertedExpr) {
1186+
llvm::TimeTraceScope TimeScope(
1187+
"CheckConstraintSatisfaction", [TemplateIDRange, this] {
1188+
return TemplateIDRange.printToString(getSourceManager());
1189+
});
11851190
if (AssociatedConstraints.empty()) {
11861191
OutSatisfaction.IsSatisfied = true;
11871192
return false;

clang/unittests/Support/TimeProfilerTest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,14 @@ TEST(TimeProfilerTest, ClassTemplateInstantiations) {
272272
ASSERT_EQ(R"(
273273
Frontend (test.cc)
274274
| ParseClass (S)
275+
| CheckConstraintSatisfaction (<test.cc:9:21, col:29>)
275276
| InstantiateClass (S<double>, test.cc:9)
276277
| InstantiateFunction (S<double>::foo, test.cc:5)
277278
| ParseDeclarationOrFunctionDefinition (test.cc:11:5)
278279
| | ParseFunctionDefinition (user)
280+
| | | CheckConstraintSatisfaction (<test.cc:12:7, col:12>)
279281
| | | InstantiateClass (S<int>, test.cc:3)
282+
| | | CheckConstraintSatisfaction (<test.cc:13:7, col:14>)
280283
| | | InstantiateClass (S<float>, test.cc:3)
281284
| | | DeferInstantiation (S<float>::foo)
282285
| PerformPendingInstantiations

0 commit comments

Comments
 (0)