Reapply 53476 and 53480, with a fix so that it properly updates
the BB member to the current basic block after emitting instructions. llvm-svn: 53567
This commit is contained in:
@@ -182,19 +182,51 @@ void Timer::addPeakMemoryMeasurement() {
|
||||
// NamedRegionTimer Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
static ManagedStatic<std::map<std::string, Timer> > NamedTimers;
|
||||
namespace {
|
||||
|
||||
typedef std::map<std::string, Timer> Name2Timer;
|
||||
typedef std::map<std::string, std::pair<TimerGroup, Name2Timer> > Name2Pair;
|
||||
|
||||
}
|
||||
|
||||
static ManagedStatic<Name2Timer> NamedTimers;
|
||||
|
||||
static ManagedStatic<Name2Pair> NamedGroupedTimers;
|
||||
|
||||
static Timer &getNamedRegionTimer(const std::string &Name) {
|
||||
std::map<std::string, Timer>::iterator I = NamedTimers->find(Name);
|
||||
Name2Timer::iterator I = NamedTimers->find(Name);
|
||||
if (I != NamedTimers->end())
|
||||
return I->second;
|
||||
|
||||
return NamedTimers->insert(I, std::make_pair(Name, Timer(Name)))->second;
|
||||
}
|
||||
|
||||
static Timer &getNamedRegionTimer(const std::string &Name,
|
||||
const std::string &GroupName) {
|
||||
|
||||
Name2Pair::iterator I = NamedGroupedTimers->find(GroupName);
|
||||
if (I == NamedGroupedTimers->end()) {
|
||||
TimerGroup TG(GroupName);
|
||||
std::pair<TimerGroup, Name2Timer> Pair(TG, Name2Timer());
|
||||
I = NamedGroupedTimers->insert(I, std::make_pair(GroupName, Pair));
|
||||
}
|
||||
|
||||
Name2Timer::iterator J = I->second.second.find(Name);
|
||||
if (J == I->second.second.end())
|
||||
J = I->second.second.insert(J,
|
||||
std::make_pair(Name,
|
||||
Timer(Name,
|
||||
I->second.first)));
|
||||
|
||||
return J->second;
|
||||
}
|
||||
|
||||
NamedRegionTimer::NamedRegionTimer(const std::string &Name)
|
||||
: TimeRegion(getNamedRegionTimer(Name)) {}
|
||||
|
||||
NamedRegionTimer::NamedRegionTimer(const std::string &Name,
|
||||
const std::string &GroupName)
|
||||
: TimeRegion(getNamedRegionTimer(Name, GroupName)) {}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// TimerGroup Implementation
|
||||
|
||||
Reference in New Issue
Block a user