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

via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 13 03:39:10 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 7088a5ed880f29129ec844c66068e8cb61ca98bf 1294a50b0da22e2904d3e43942a6be702c93d133 --extensions cpp,h -- clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/unittests/Support/TimeProfilerTest.cpp llvm/include/llvm/Support/TimeProfiler.h llvm/lib/Support/TimeProfiler.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/Support/TimeProfiler.h b/llvm/include/llvm/Support/TimeProfiler.h
index f4952b18e4..a0ab7e2ef0 100644
--- a/llvm/include/llvm/Support/TimeProfiler.h
+++ b/llvm/include/llvm/Support/TimeProfiler.h
@@ -155,8 +155,8 @@ TimeTraceProfilerEntry *timeTraceAsyncProfilerBegin(StringRef Name,
                                                     StringRef Detail);
 
 // Mark an instant event.
-TimeTraceProfilerEntry *timeTraceInstantEventProfilerBegin(StringRef Name,
-                             llvm::function_ref<TimeTraceMetadata()> Metadata);
+TimeTraceProfilerEntry *timeTraceInstantEventProfilerBegin(
+    StringRef Name, llvm::function_ref<TimeTraceMetadata()> Metadata);
 
 /// Manually end the last time section.
 void timeTraceProfilerEnd();
@@ -187,7 +187,8 @@ public:
       Entry = timeTraceProfilerBegin(Name, Detail);
   }
   TimeTraceScope(StringRef Name,
-                 llvm::function_ref<TimeTraceMetadata()> Metadata, TimeTraceEventType Et = TimeTraceEventType::CompleteEvent) {
+                 llvm::function_ref<TimeTraceMetadata()> Metadata,
+                 TimeTraceEventType Et = TimeTraceEventType::CompleteEvent) {
     if (getTimeTraceProfilerInstance() == nullptr)
       return;
     assert((Et == TimeTraceEventType::InstantEvent ||
@@ -198,7 +199,7 @@ public:
       Entry = timeTraceProfilerBegin(Name, Metadata);
     } else {
       Entry = timeTraceInstantEventProfilerBegin(Name, Metadata);
-    } 
+    }
   }
   ~TimeTraceScope() {
     if (getTimeTraceProfilerInstance() != nullptr)
diff --git a/llvm/lib/Support/TimeProfiler.cpp b/llvm/lib/Support/TimeProfiler.cpp
index 738f5f5842..958749ed11 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -115,12 +115,11 @@ struct llvm::TimeTraceProfiler {
     llvm::get_thread_name(ThreadName);
   }
 
-  TimeTraceProfilerEntry *begin(std::string Name,
-                                llvm::function_ref<std::string()> Detail,
-                                TimeTraceEventType Et = TimeTraceEventType::CompleteEvent) {
+  TimeTraceProfilerEntry *
+  begin(std::string Name, llvm::function_ref<std::string()> Detail,
+        TimeTraceEventType Et = TimeTraceEventType::CompleteEvent) {
     Stack.emplace_back(std::make_unique<TimeTraceProfilerEntry>(
-        ClockType::now(), TimePointType(), std::move(Name), Detail(),
-        Et));
+        ClockType::now(), TimePointType(), std::move(Name), Detail(), Et));
     return Stack.back().get();
   }
 
@@ -128,8 +127,7 @@ struct llvm::TimeTraceProfiler {
   begin(std::string Name, llvm::function_ref<TimeTraceMetadata()> Metadata,
         TimeTraceEventType Et = TimeTraceEventType::CompleteEvent) {
     Stack.emplace_back(std::make_unique<TimeTraceProfilerEntry>(
-        ClockType::now(), TimePointType(), std::move(Name), Metadata(),
-        Et));
+        ClockType::now(), TimePointType(), std::move(Name), Metadata(), Et));
     return Stack.back().get();
   }
 
@@ -153,7 +151,9 @@ struct llvm::TimeTraceProfiler {
     } else {
       // if the event is not included, exclude also all instant events that
       // happened during this event.
-      for (SmallVector<TimeTraceProfilerEntry, 128>::iterator it = Entries.begin(); it != Entries.end();) {
+      for (SmallVector<TimeTraceProfilerEntry, 128>::iterator it =
+               Entries.begin();
+           it != Entries.end();) {
         if (TimeTraceEventType::InstantEvent == it->EventType &&
             it->Start > E.Start && it->Start < E.End)
           it = Entries.erase(it);
@@ -422,7 +422,8 @@ TimeTraceProfilerEntry *llvm::timeTraceProfilerBegin(StringRef Name,
                                                      StringRef Detail) {
   if (TimeTraceProfilerInstance != nullptr)
     return TimeTraceProfilerInstance->begin(
-        std::string(Name), [&]() { return std::string(Detail); }, TimeTraceEventType::CompleteEvent);
+        std::string(Name), [&]() { return std::string(Detail); },
+        TimeTraceEventType::CompleteEvent);
   return nullptr;
 }
 
@@ -430,7 +431,8 @@ TimeTraceProfilerEntry *
 llvm::timeTraceProfilerBegin(StringRef Name,
                              llvm::function_ref<std::string()> Detail) {
   if (TimeTraceProfilerInstance != nullptr)
-    return TimeTraceProfilerInstance->begin(std::string(Name), Detail, TimeTraceEventType::CompleteEvent);
+    return TimeTraceProfilerInstance->begin(std::string(Name), Detail,
+                                            TimeTraceEventType::CompleteEvent);
   return nullptr;
 }
 
@@ -438,15 +440,16 @@ TimeTraceProfilerEntry *
 llvm::timeTraceProfilerBegin(StringRef Name,
                              llvm::function_ref<TimeTraceMetadata()> Metadata) {
   if (TimeTraceProfilerInstance != nullptr)
-    return TimeTraceProfilerInstance->begin(std::string(Name), Metadata, TimeTraceEventType::CompleteEvent);
+    return TimeTraceProfilerInstance->begin(std::string(Name), Metadata,
+                                            TimeTraceEventType::CompleteEvent);
   return nullptr;
 }
 
-TimeTraceProfilerEntry *
-llvm::timeTraceInstantEventProfilerBegin(StringRef Name,
-                             llvm::function_ref<TimeTraceMetadata()> Metadata) {
+TimeTraceProfilerEntry *llvm::timeTraceInstantEventProfilerBegin(
+    StringRef Name, llvm::function_ref<TimeTraceMetadata()> Metadata) {
   if (TimeTraceProfilerInstance != nullptr)
-    return TimeTraceProfilerInstance->begin(std::string(Name), Metadata, TimeTraceEventType::InstantEvent);
+    return TimeTraceProfilerInstance->begin(std::string(Name), Metadata,
+                                            TimeTraceEventType::InstantEvent);
   return nullptr;
 }
 
@@ -454,7 +457,8 @@ TimeTraceProfilerEntry *llvm::timeTraceAsyncProfilerBegin(StringRef Name,
                                                           StringRef Detail) {
   if (TimeTraceProfilerInstance != nullptr)
     return TimeTraceProfilerInstance->begin(
-        std::string(Name), [&]() { return std::string(Detail); }, TimeTraceEventType::AsyncEvent);
+        std::string(Name), [&]() { return std::string(Detail); },
+        TimeTraceEventType::AsyncEvent);
   return nullptr;
 }
 

``````````

</details>


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


More information about the cfe-commits mailing list