forked from OSchip/llvm-project
Guard mutation of the timing info global.
llvm-svn: 73639
This commit is contained in:
parent
791505b5ea
commit
0dd39fdf96
|
@ -20,6 +20,8 @@
|
|||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Support/Threading.h"
|
||||
#include "llvm/System/Mutex.h"
|
||||
#include "llvm/Analysis/Dominators.h"
|
||||
#include "llvm-c/Core.h"
|
||||
#include <algorithm>
|
||||
|
@ -355,6 +357,9 @@ namespace {
|
|||
/// amount of time each pass takes to execute. This only happens when
|
||||
/// -time-passes is enabled on the command line.
|
||||
///
|
||||
|
||||
static ManagedStatic<sys::Mutex> TimingInfoMutex;
|
||||
|
||||
class VISIBILITY_HIDDEN TimingInfo {
|
||||
std::map<Pass*, Timer> TimingData;
|
||||
TimerGroup TG;
|
||||
|
@ -379,18 +384,22 @@ public:
|
|||
if (dynamic_cast<PMDataManager *>(P))
|
||||
return;
|
||||
|
||||
if (llvm_is_multithreaded()) TimingInfoMutex->acquire();
|
||||
std::map<Pass*, Timer>::iterator I = TimingData.find(P);
|
||||
if (I == TimingData.end())
|
||||
I=TimingData.insert(std::make_pair(P, Timer(P->getPassName(), TG))).first;
|
||||
I->second.startTimer();
|
||||
if (llvm_is_multithreaded()) TimingInfoMutex->release();
|
||||
}
|
||||
void passEnded(Pass *P) {
|
||||
if (dynamic_cast<PMDataManager *>(P))
|
||||
return;
|
||||
|
||||
if (llvm_is_multithreaded()) TimingInfoMutex->acquire();
|
||||
std::map<Pass*, Timer>::iterator I = TimingData.find(P);
|
||||
assert(I != TimingData.end() && "passStarted/passEnded not nested right!");
|
||||
I->second.stopTimer();
|
||||
if (llvm_is_multithreaded()) TimingInfoMutex->release();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue