[llvm-commits] [llvm] r73957 - in /llvm/trunk: include/llvm/Support/Timer.h lib/Support/Timer.cpp
Owen Anderson
resistor at mac.com
Tue Jun 23 09:36:12 PDT 2009
Author: resistor
Date: Tue Jun 23 11:36:10 2009
New Revision: 73957
URL: http://llvm.org/viewvc/llvm-project?rev=73957&view=rev
Log:
Revert r73923, which broke clang.
Modified:
llvm/trunk/include/llvm/Support/Timer.h
llvm/trunk/lib/Support/Timer.cpp
Modified: llvm/trunk/include/llvm/Support/Timer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Timer.h?rev=73957&r1=73956&r2=73957&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Timer.h (original)
+++ llvm/trunk/include/llvm/Support/Timer.h Tue Jun 23 11:36:10 2009
@@ -152,7 +152,6 @@
unsigned NumTimers;
std::vector<Timer> TimersToPrint;
public:
- TimerGroup() : Name("Miscellaneous Ungrouped Timers"), NumTimers(0) {}
explicit TimerGroup(const std::string &name) : Name(name), NumTimers(0) {}
~TimerGroup() {
assert(NumTimers == 0 &&
Modified: llvm/trunk/lib/Support/Timer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=73957&r1=73956&r2=73957&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Timer.cpp (original)
+++ llvm/trunk/lib/Support/Timer.cpp Tue Jun 23 11:36:10 2009
@@ -15,7 +15,6 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Streams.h"
-#include "llvm/System/Mutex.h"
#include "llvm/System/Process.h"
#include <algorithm>
#include <fstream>
@@ -51,28 +50,25 @@
cl::Hidden, cl::location(getLibSupportInfoOutputFilename()));
}
-static ManagedStatic<sys::SmartMutex<true> > TimerLock;
-static ManagedStatic<TimerGroup> DefaultTimerGroup;
+static TimerGroup *DefaultTimerGroup = 0;
static TimerGroup *getDefaultTimerGroup() {
- return &*DefaultTimerGroup;
+ if (DefaultTimerGroup) return DefaultTimerGroup;
+ return DefaultTimerGroup = new TimerGroup("Miscellaneous Ungrouped Timers");
}
Timer::Timer(const std::string &N)
: Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), PeakMem(0), Name(N),
Started(false), TG(getDefaultTimerGroup()) {
- sys::SmartScopedLock<true> Lock(&*TimerLock);
TG->addTimer();
}
Timer::Timer(const std::string &N, TimerGroup &tg)
: Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), PeakMem(0), Name(N),
Started(false), TG(&tg) {
- sys::SmartScopedLock<true> Lock(&*TimerLock);
TG->addTimer();
}
Timer::Timer(const Timer &T) {
- sys::SmartScopedLock<true> Lock(&*TimerLock);
TG = T.TG;
if (TG) TG->addTimer();
operator=(T);
@@ -81,7 +77,6 @@
// Copy ctor, initialize with no TG member.
Timer::Timer(bool, const Timer &T) {
- sys::SmartScopedLock<true> Lock(&*TimerLock);
TG = T.TG; // Avoid assertion in operator=
operator=(T); // Copy contents
TG = 0;
@@ -89,7 +84,6 @@
Timer::~Timer() {
- sys::SmartScopedLock<true> Lock(&*TimerLock);
if (TG) {
if (Started) {
Started = false;
@@ -135,10 +129,8 @@
}
static ManagedStatic<std::vector<Timer*> > ActiveTimers;
-static ManagedStatic<sys::SmartMutex<true> > ActiveTimerLock;
void Timer::startTimer() {
- sys::SmartScopedLock<true> Lock(&*ActiveTimerLock);
Started = true;
ActiveTimers->push_back(this);
TimeRecord TR = getTimeRecord(true);
@@ -150,7 +142,6 @@
}
void Timer::stopTimer() {
- sys::SmartScopedLock<true> Lock(&*ActiveTimerLock);
TimeRecord TR = getTimeRecord(false);
Elapsed += TR.Elapsed;
UserTime += TR.UserTime;
@@ -180,7 +171,6 @@
/// currently active timers, which will be printed when the timer group prints
///
void Timer::addPeakMemoryMeasurement() {
- sys::SmartScopedLock<true> Lock(&*ActiveTimerLock);
size_t MemUsed = getMemUsage();
for (std::vector<Timer*>::iterator I = ActiveTimers->begin(),
@@ -203,10 +193,7 @@
static ManagedStatic<Name2Pair> NamedGroupedTimers;
-static ManagedStatic<sys::SmartMutex<true> > NamedTimerLock;
-
static Timer &getNamedRegionTimer(const std::string &Name) {
- sys::SmartScopedLock<true> Lock(&*NamedTimerLock);
Name2Timer::iterator I = NamedTimers->find(Name);
if (I != NamedTimers->end())
return I->second;
@@ -216,7 +203,6 @@
static Timer &getNamedRegionTimer(const std::string &Name,
const std::string &GroupName) {
- sys::SmartScopedLock<true> Lock(&*NamedTimerLock);
Name2Pair::iterator I = NamedGroupedTimers->find(GroupName);
if (I == NamedGroupedTimers->end()) {
@@ -354,7 +340,7 @@
// If this is not an collection of ungrouped times, print the total time.
// Ungrouped timers don't really make sense to add up. We still print the
// TOTAL line to make the percentages make sense.
- if (this != &*DefaultTimerGroup) {
+ if (this != DefaultTimerGroup) {
*OutStream << " Total Execution Time: ";
printAlignedFP(Total.getProcessTime(), 4, 5, *OutStream);
@@ -391,5 +377,11 @@
if (OutStream != cerr.stream() && OutStream != cout.stream())
delete OutStream; // Close the file...
}
+
+ // Delete default timer group!
+ if (NumTimers == 0 && this == DefaultTimerGroup) {
+ delete DefaultTimerGroup;
+ DefaultTimerGroup = 0;
+ }
}
More information about the llvm-commits
mailing list