diff options
author | Dan Gohman <gohman@apple.com> | 2008-07-11 21:54:34 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-07-11 21:54:34 +0000 |
commit | 5e29bafdd4026d91dfcc021dab82e21975b98911 (patch) | |
tree | 2c003a265f1efaf986c7660a9c5e791722985d10 /lib/Support | |
parent | b261a98997b7b93e6baffc418f7320873a709d7e (diff) | |
download | external_llvm-5e29bafdd4026d91dfcc021dab82e21975b98911.zip external_llvm-5e29bafdd4026d91dfcc021dab82e21975b98911.tar.gz external_llvm-5e29bafdd4026d91dfcc021dab82e21975b98911.tar.bz2 |
Add support for putting NamedRegionTimers in TimerGroups, and
use a timer group for the timers in SelectionDAGISel. Also,
Split scheduling out from emitting, to give each their own
timer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53476 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/Timer.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index 29fd00c..3c8879b 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -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 |