[llvm] [llvm][Support] Enable `TimeTraceProfiler` to accept deferred detail string (PR #74935)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 9 06:38:48 PST 2023
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 600462a2db7c044896122acfb347ce2d4d88271f 4e8f48947d59474e07e08cdc98e4a6fb2e3c80c1 -- 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 5b8af16ed4..f96b3a0fb8 100644
--- a/llvm/include/llvm/Support/TimeProfiler.h
+++ b/llvm/include/llvm/Support/TimeProfiler.h
@@ -122,9 +122,11 @@ Error timeTraceProfilerWrite(StringRef PreferredFileName,
/// Profiler copies the string data, so the pointers can be given into
/// temporaries. Time sections can be hierarchical; every Begin must have a
/// matching End pair but they can nest.
-TimeTraceProfilerEntry* timeTraceProfilerBegin(StringRef Name, StringRef Detail);
-TimeTraceProfilerEntry* timeTraceProfilerBegin(StringRef Name,
- llvm::function_ref<std::string()> Detail);
+TimeTraceProfilerEntry *timeTraceProfilerBegin(StringRef Name,
+ StringRef Detail);
+TimeTraceProfilerEntry *
+timeTraceProfilerBegin(StringRef Name,
+ llvm::function_ref<std::string()> Detail);
/// Manually end the last time section.
void timeTraceProfilerEnd();
@@ -134,18 +136,19 @@ void timeTraceProfilerEnd();
/// `timeTraceProfilerBegin`. String is handled in the same way as
/// `timeTraceProfilerBegin` does. This is useful when contents of
/// \p Detail is not (fully) known at the time trace entry is created.
-void timeTraceProfilerEntrySetDetail(TimeTraceProfilerEntry* Entry, StringRef Detail);
-void timeTraceProfilerEntrySetDetail(TimeTraceProfilerEntry* Entry, llvm::function_ref<std::string()> Detail);
+void timeTraceProfilerEntrySetDetail(TimeTraceProfilerEntry *Entry,
+ StringRef Detail);
+void timeTraceProfilerEntrySetDetail(TimeTraceProfilerEntry *Entry,
+ llvm::function_ref<std::string()> Detail);
/// The TimeTraceScope is a helper class to call the begin and end functions
/// of the time trace profiler. When the object is constructed, it begins
/// the section; and when it is destroyed, it stops it. If the time profiler
/// is not initialized, the overhead is a single branch.
class TimeTraceScope {
- TimeTraceProfilerEntry* Entry;
+ TimeTraceProfilerEntry *Entry;
public:
-
TimeTraceScope() = delete;
TimeTraceScope(const TimeTraceScope &) = delete;
TimeTraceScope &operator=(const TimeTraceScope &) = delete;
diff --git a/llvm/lib/Support/TimeProfiler.cpp b/llvm/lib/Support/TimeProfiler.cpp
index bd8a04ed89..ebf0f40efa 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -102,9 +102,10 @@ struct llvm::TimeTraceProfiler {
llvm::get_thread_name(ThreadName);
}
- llvm::TimeTraceProfilerEntry* begin(std::string Name, llvm::function_ref<std::string()> Detail) {
- return &Stack.emplace_back(ClockType::now(), TimePointType(), std::move(Name),
- Detail());
+ llvm::TimeTraceProfilerEntry *
+ begin(std::string Name, llvm::function_ref<std::string()> Detail) {
+ return &Stack.emplace_back(ClockType::now(), TimePointType(),
+ std::move(Name), Detail());
}
void end() {
@@ -341,14 +342,16 @@ Error llvm::timeTraceProfilerWrite(StringRef PreferredFileName,
return Error::success();
}
-llvm::TimeTraceProfilerEntry* llvm::timeTraceProfilerBegin(StringRef Name, StringRef Detail) {
+llvm::TimeTraceProfilerEntry *llvm::timeTraceProfilerBegin(StringRef Name,
+ StringRef Detail) {
if (TimeTraceProfilerInstance != nullptr)
- return TimeTraceProfilerInstance->begin(std::string(Name),
- [&]() { return std::string(Detail); });
+ return TimeTraceProfilerInstance->begin(
+ std::string(Name), [&]() { return std::string(Detail); });
}
-llvm::TimeTraceProfilerEntry* llvm::timeTraceProfilerBegin(StringRef Name,
- llvm::function_ref<std::string()> Detail) {
+llvm::TimeTraceProfilerEntry *
+llvm::timeTraceProfilerBegin(StringRef Name,
+ llvm::function_ref<std::string()> Detail) {
if (TimeTraceProfilerInstance != nullptr)
return TimeTraceProfilerInstance->begin(std::string(Name), Detail);
}
@@ -358,13 +361,16 @@ void llvm::timeTraceProfilerEnd() {
TimeTraceProfilerInstance->end();
}
-void llvm::timeTraceProfilerEntrySetDetail(llvm::TimeTraceProfilerEntry* Entry, StringRef Detail) {
+void llvm::timeTraceProfilerEntrySetDetail(llvm::TimeTraceProfilerEntry *Entry,
+ StringRef Detail) {
if (Entry != nullptr) {
Entry->Detail = Detail;
}
}
-void llvm::timeTraceProfilerEntrySetDetail(llvm::TimeTraceProfilerEntry* Entry, llvm::function_ref<std::string()> Detail) {
+void llvm::timeTraceProfilerEntrySetDetail(
+ llvm::TimeTraceProfilerEntry *Entry,
+ llvm::function_ref<std::string()> Detail) {
if (Entry != nullptr) {
Entry->Detail = Detail();
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/74935
More information about the llvm-commits
mailing list