diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2009-11-18 14:58:34 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2009-11-18 14:58:34 +0000 |
commit | d2e985fd323c167e20f77b045a1d99ad166e65db (patch) | |
tree | 6a111e552c75afc66228e3d8f19b6731e4013f10 /lib/Support/Timer.cpp | |
parent | ded64d5d348ce8d8c5aa42cf63f6de9dd84b7e89 (diff) | |
download | FreeBSD-src-d2e985fd323c167e20f77b045a1d99ad166e65db.zip FreeBSD-src-d2e985fd323c167e20f77b045a1d99ad166e65db.tar.gz |
Update LLVM to r89205.
Diffstat (limited to 'lib/Support/Timer.cpp')
-rw-r--r-- | lib/Support/Timer.cpp | 49 |
1 files changed, 8 insertions, 41 deletions
diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index dd58d1f..7d32ee6 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -66,7 +66,7 @@ static TimerGroup *getDefaultTimerGroup() { } llvm_release_global_lock(); } - + return tmp; } @@ -145,7 +145,7 @@ static TimeRecord getTimeRecord(bool Start) { static ManagedStatic<std::vector<Timer*> > ActiveTimers; void Timer::startTimer() { - sys::SmartScopedLock<true> L(Lock); + sys::SmartScopedLock<true> L(*TimerLock); Started = true; ActiveTimers->push_back(this); TimeRecord TR = getTimeRecord(true); @@ -157,7 +157,7 @@ void Timer::startTimer() { } void Timer::stopTimer() { - sys::SmartScopedLock<true> L(Lock); + sys::SmartScopedLock<true> L(*TimerLock); TimeRecord TR = getTimeRecord(false); Elapsed += TR.Elapsed; UserTime += TR.UserTime; @@ -175,27 +175,11 @@ void Timer::stopTimer() { } void Timer::sum(const Timer &T) { - if (&T < this) { - T.Lock.acquire(); - Lock.acquire(); - } else { - Lock.acquire(); - T.Lock.acquire(); - } - Elapsed += T.Elapsed; UserTime += T.UserTime; SystemTime += T.SystemTime; MemUsed += T.MemUsed; PeakMem += T.PeakMem; - - if (&T < this) { - T.Lock.release(); - Lock.release(); - } else { - Lock.release(); - T.Lock.release(); - } } /// addPeakMemoryMeasurement - This method should be called whenever memory @@ -203,14 +187,12 @@ void Timer::sum(const Timer &T) { /// currently active timers, which will be printed when the timer group prints /// void Timer::addPeakMemoryMeasurement() { + sys::SmartScopedLock<true> L(*TimerLock); size_t MemUsed = getMemUsage(); for (std::vector<Timer*>::iterator I = ActiveTimers->begin(), - E = ActiveTimers->end(); I != E; ++I) { - (*I)->Lock.acquire(); + E = ActiveTimers->end(); I != E; ++I) (*I)->PeakMem = std::max((*I)->PeakMem, MemUsed-(*I)->PeakMemBase); - (*I)->Lock.release(); - } } //===----------------------------------------------------------------------===// @@ -280,14 +262,7 @@ static void printVal(double Val, double Total, raw_ostream &OS) { } void Timer::print(const Timer &Total, raw_ostream &OS) { - if (&Total < this) { - Total.Lock.acquire(); - Lock.acquire(); - } else { - Lock.acquire(); - Total.Lock.acquire(); - } - + sys::SmartScopedLock<true> L(*TimerLock); if (Total.UserTime) printVal(UserTime, Total.UserTime, OS); if (Total.SystemTime) @@ -310,14 +285,6 @@ void Timer::print(const Timer &Total, raw_ostream &OS) { OS << Name << "\n"; Started = false; // Once printed, don't print again - - if (&Total < this) { - Total.Lock.release(); - Lock.release(); - } else { - Lock.release(); - Total.Lock.release(); - } } // GetLibSupportInfoOutputFile - Return a file stream to print our output on... @@ -329,13 +296,13 @@ llvm::GetLibSupportInfoOutputFile() { if (LibSupportInfoOutputFilename == "-") return &outs(); - + std::string Error; raw_ostream *Result = new raw_fd_ostream(LibSupportInfoOutputFilename.c_str(), Error, raw_fd_ostream::F_Append); if (Error.empty()) return Result; - + errs() << "Error opening info-output-file '" << LibSupportInfoOutputFilename << " for appending!\n"; delete Result; |