[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 29 06:01:45 PDT 2024


================
@@ -18046,6 +18048,19 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func,
                 std::make_pair(Func, PointOfInstantiation));
             // Notify the consumer that a function was implicitly instantiated.
             Consumer.HandleCXXImplicitFunctionInstantiation(Func);
+
+            llvm::timeTraceProfilerInsert("DeferInstantiation", [&]() {
+              llvm::TimeTraceMetadata M;
+              llvm::raw_string_ostream OS(M.Detail);
+              Func->getNameForDiagnostic(OS, getPrintingPolicy(),
+                                         /*Qualified=*/true);
+              if (llvm::isTimeTraceVerbose()) {
+                auto Loc = SourceMgr.getExpansionLoc(Func->getLocation());
+                M.File = SourceMgr.getFilename(Loc);
+                M.Line = SourceMgr.getExpansionLineNumber(Loc);
+              }
+              return M;
+            });
----------------
usx95 wrote:

There would be way too many deferred instantiations (as compared to actual instantiations).
I would add these events only in verbose mode.

```
if (llvm::isTimeTraceVerbose())
  llvm::timeTraceProfilerInsert...
```


https://github.com/llvm/llvm-project/pull/103039


More information about the cfe-commits mailing list