X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FSupport%2FTimer.cpp;h=210bda754e74957db524630e2b1c18830702a707;hb=822199b9e6867c3fe94bffa6ab57be903014f98a;hp=c2ce90c85880db28360bc382d3b5548aa1247bd0;hpb=34bc6b6e787f27b5c9e05c82de4c1b4ac9b117bc;p=oota-llvm.git diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index c2ce90c8588..210bda754e7 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -15,9 +15,11 @@ #include "llvm/ADT/StringMap.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/Format.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Mutex.h" +#include "llvm/Support/MutexGuard.h" #include "llvm/Support/Process.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -83,14 +85,13 @@ static TimerGroup *getDefaultTimerGroup() { sys::MemoryFence(); if (tmp) return tmp; - llvm_acquire_global_lock(); + sys::SmartScopedLock Lock(*TimerLock); tmp = DefaultTimerGroup; if (!tmp) { tmp = new TimerGroup("Miscellaneous Ungrouped Timers"); sys::MemoryFence(); DefaultTimerGroup = tmp; } - llvm_release_global_lock(); return tmp; } @@ -100,7 +101,7 @@ static TimerGroup *getDefaultTimerGroup() { //===----------------------------------------------------------------------===// void Timer::init(StringRef N) { - assert(TG == 0 && "Timer already initialized"); + assert(!TG && "Timer already initialized"); Name.assign(N.begin(), N.end()); Started = false; TG = getDefaultTimerGroup(); @@ -108,7 +109,7 @@ void Timer::init(StringRef N) { } void Timer::init(StringRef N, TimerGroup &tg) { - assert(TG == 0 && "Timer already initialized"); + assert(!TG && "Timer already initialized"); Name.assign(N.begin(), N.end()); Started = false; TG = &tg; @@ -264,7 +265,7 @@ TimerGroup::TimerGroup(StringRef name) TimerGroup::~TimerGroup() { // If the timer group is destroyed before the timers it owns, accumulate and // print the timing data. - while (FirstTimer != nullptr) + while (FirstTimer) removeTimer(*FirstTimer); // Remove the group from the TimerGroupList. @@ -291,7 +292,7 @@ void TimerGroup::removeTimer(Timer &T) { // Print the report when all timers in this group are destroyed if some of // them were started. - if (FirstTimer != nullptr || TimersToPrint.empty()) + if (FirstTimer || TimersToPrint.empty()) return; raw_ostream *OutStream = CreateInfoOutputFile();