Skip to content

Commit 366d63f

Browse files
committed
repair #121663
Created using spr 1.3.5-bogner
1 parent cc49050 commit 366d63f

File tree

3 files changed

+15
-30
lines changed

3 files changed

+15
-30
lines changed

clang/tools/driver/driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) {
439439
if (!UseNewCC1Process && IsCrash) {
440440
// When crashing in -fintegrated-cc1 mode, bury the timer pointers, because
441441
// the internal linked list might point to already released stack frames.
442-
llvm::BuryPointer(llvm::TimerGroup::aquireDefaultGroup());
442+
llvm::BuryPointer(llvm::TimerGroup::acquireTimerGlobals());
443443
} else {
444444
// If any timers were active but haven't been destroyed yet, print their
445445
// results now. This happens in -disable-free mode.

llvm/include/llvm/Support/Timer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ class TimerGroup {
240240
/// global constructors and destructors.
241241
static void constructForStatistics();
242242

243-
/// This makes the default group unmanaged, and lets the user manage the
244-
/// group's lifetime.
245-
static std::unique_ptr<TimerGroup> aquireDefaultGroup();
243+
/// This makes the timer globals unmanaged, and lets the user manage the
244+
/// lifetime.
245+
static void *acquireTimerGlobals();
246246

247247
private:
248248
friend class Timer;

llvm/lib/Support/Timer.cpp

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ static bool sortTimers();
5656
static SignpostEmitter &signposts();
5757
static sys::SmartMutex<true> &timerLock();
5858
static TimerGroup &defaultTimerGroup();
59-
static TimerGroup *claimDefaultTimerGroup();
6059
static Name2PairMap &namedGroupedTimers();
6160

6261
//===----------------------------------------------------------------------===//
@@ -467,10 +466,6 @@ void TimerGroup::constructForStatistics() {
467466
namedGroupedTimers();
468467
}
469468

470-
std::unique_ptr<TimerGroup> TimerGroup::aquireDefaultGroup() {
471-
return std::unique_ptr<TimerGroup>(claimDefaultTimerGroup());
472-
}
473-
474469
//===----------------------------------------------------------------------===//
475470
// Timer Globals
476471
//
@@ -495,36 +490,27 @@ class llvm::TimerGlobals {
495490
cl::opt<std::string, true> InfoOutputFilename;
496491
cl::opt<bool> TrackSpace;
497492
cl::opt<bool> SortTimers;
493+
sys::SmartMutex<true> TimerLock;
494+
TimerGroup DefaultTimerGroup{"misc", "Miscellaneous Ungrouped Timers",
495+
TimerLock};
496+
SignpostEmitter Signposts;
498497

499498
private:
500499
// Order of these members and initialization below is important. For example
501500
// the defaultTimerGroup uses the timerLock. Most of these also depend on the
502501
// options above.
503502
std::once_flag InitDeferredFlag;
504-
std::optional<SignpostEmitter> SignpostsPtr;
505-
std::optional<sys::SmartMutex<true>> TimerLockPtr;
506-
std::unique_ptr<TimerGroup> DefaultTimerGroupPtr;
507503
std::optional<Name2PairMap> NamedGroupedTimersPtr;
508504
TimerGlobals &initDeferred() {
509-
std::call_once(InitDeferredFlag, [this]() {
510-
SignpostsPtr.emplace();
511-
TimerLockPtr.emplace();
512-
DefaultTimerGroupPtr.reset(new TimerGroup(
513-
"misc", "Miscellaneous Ungrouped Timers", *TimerLockPtr));
514-
NamedGroupedTimersPtr.emplace();
515-
});
505+
std::call_once(InitDeferredFlag,
506+
[this]() { NamedGroupedTimersPtr.emplace(); });
516507
return *this;
517508
}
518509

519510
public:
520-
SignpostEmitter &signposts() { return *initDeferred().SignpostsPtr; }
521-
sys::SmartMutex<true> &timerLock() { return *initDeferred().TimerLockPtr; }
522-
TimerGroup &defaultTimerGroup() {
523-
return *initDeferred().DefaultTimerGroupPtr;
524-
}
525-
TimerGroup *claimDefaultTimerGroup() {
526-
return initDeferred().DefaultTimerGroupPtr.release();
527-
}
511+
SignpostEmitter &signposts() { return Signposts; }
512+
sys::SmartMutex<true> &timerLock() { return TimerLock; }
513+
TimerGroup &defaultTimerGroup() { return DefaultTimerGroup; }
528514
Name2PairMap &namedGroupedTimers() {
529515
return *initDeferred().NamedGroupedTimersPtr;
530516
}
@@ -561,11 +547,10 @@ static sys::SmartMutex<true> &timerLock() {
561547
static TimerGroup &defaultTimerGroup() {
562548
return ManagedTimerGlobals->defaultTimerGroup();
563549
}
564-
static TimerGroup *claimDefaultTimerGroup() {
565-
return ManagedTimerGlobals->claimDefaultTimerGroup();
566-
}
567550
static Name2PairMap &namedGroupedTimers() {
568551
return ManagedTimerGlobals->namedGroupedTimers();
569552
}
570553

571554
void llvm::initTimerOptions() { *ManagedTimerGlobals; }
555+
556+
void *TimerGroup::acquireTimerGlobals() { return ManagedTimerGlobals.claim(); }

0 commit comments

Comments
 (0)