aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Timer.cpp
diff options
context:
space:
mode:
authorAlan Zhao <ayzhao@google.com>2025-03-13 16:20:39 -0700
committerGitHub <noreply@github.com>2025-03-13 16:20:39 -0700
commit864a53b4a414d2da9b90712af196d5e4733b0eee (patch)
tree2ec6181b09e2666541371223666e6670f1892309 /llvm/lib/Support/Timer.cpp
parentd0c869521ce0b15d0d5d152d4fbfcc0f75377e91 (diff)
downloadllvm-864a53b4a414d2da9b90712af196d5e4733b0eee.zip
llvm-864a53b4a414d2da9b90712af196d5e4733b0eee.tar.gz
llvm-864a53b4a414d2da9b90712af196d5e4733b0eee.tar.bz2
Reapply "Use global TimerGroups for both new pass manager and old pass manager timers" (#131173) (#131217)
This reverts commit 31ebe6647b7f1fc7f6778a5438175b12f82357ae. The reason for the test failure is likely due to `Name2PairMap::getTimerGroup(...)` not holding a lock.
Diffstat (limited to 'llvm/lib/Support/Timer.cpp')
-rw-r--r--llvm/lib/Support/Timer.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp
index eca7268..69a1846 100644
--- a/llvm/lib/Support/Timer.cpp
+++ b/llvm/lib/Support/Timer.cpp
@@ -222,16 +222,28 @@ public:
StringRef GroupDescription) {
sys::SmartScopedLock<true> L(timerLock());
- std::pair<TimerGroup*, Name2TimerMap> &GroupEntry = Map[GroupName];
-
- if (!GroupEntry.first)
- GroupEntry.first = new TimerGroup(GroupName, GroupDescription);
-
+ std::pair<TimerGroup *, Name2TimerMap> &GroupEntry =
+ getGroupEntry(GroupName, GroupDescription);
Timer &T = GroupEntry.second[Name];
if (!T.isInitialized())
T.init(Name, Description, *GroupEntry.first);
return T;
}
+
+ TimerGroup &getTimerGroup(StringRef GroupName, StringRef GroupDescription) {
+ sys::SmartScopedLock<true> L(timerLock());
+ return *getGroupEntry(GroupName, GroupDescription).first;
+ }
+
+private:
+ std::pair<TimerGroup *, Name2TimerMap> &
+ getGroupEntry(StringRef GroupName, StringRef GroupDescription) {
+ std::pair<TimerGroup *, Name2TimerMap> &GroupEntry = Map[GroupName];
+ if (!GroupEntry.first)
+ GroupEntry.first = new TimerGroup(GroupName, GroupDescription);
+
+ return GroupEntry;
+ }
};
}
@@ -244,6 +256,11 @@ NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef Description,
: &namedGroupedTimers().get(Name, Description, GroupName,
GroupDescription)) {}
+TimerGroup &NamedRegionTimer::getNamedTimerGroup(StringRef GroupName,
+ StringRef GroupDescription) {
+ return namedGroupedTimers().getTimerGroup(GroupName, GroupDescription);
+}
+
//===----------------------------------------------------------------------===//
// TimerGroup Implementation
//===----------------------------------------------------------------------===//