mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
stringref'ize Timer apis
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99877 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
83fa78efb1
commit
cebf5bc2ee
@ -16,6 +16,7 @@
|
||||
#define LLVM_SUPPORT_TIMER_H
|
||||
|
||||
#include "llvm/System/DataTypes.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -88,8 +89,8 @@ class Timer {
|
||||
|
||||
Timer **Prev, *Next; // Doubly linked list of timers in the group.
|
||||
public:
|
||||
explicit Timer(const std::string &N) : TG(0) { init(N); }
|
||||
Timer(const std::string &N, TimerGroup &tg) : TG(0) { init(N, tg); }
|
||||
explicit Timer(StringRef N) : TG(0) { init(N); }
|
||||
Timer(StringRef N, TimerGroup &tg) : TG(0) { init(N, tg); }
|
||||
Timer(const Timer &RHS) : TG(0) {
|
||||
assert(RHS.TG == 0 && "Can only copy uninitialized timers");
|
||||
}
|
||||
@ -101,8 +102,8 @@ public:
|
||||
|
||||
// Create an uninitialized timer, client must use 'init'.
|
||||
explicit Timer() : TG(0) {}
|
||||
void init(const std::string &N);
|
||||
void init(const std::string &N, TimerGroup &tg);
|
||||
void init(StringRef N);
|
||||
void init(StringRef N, TimerGroup &tg);
|
||||
|
||||
const std::string &getName() const { return Name; }
|
||||
bool isInitialized() const { return TG != 0; }
|
||||
@ -149,9 +150,8 @@ public:
|
||||
/// is primarily used for debugging and for hunting performance problems.
|
||||
///
|
||||
struct NamedRegionTimer : public TimeRegion {
|
||||
explicit NamedRegionTimer(const std::string &Name);
|
||||
explicit NamedRegionTimer(const std::string &Name,
|
||||
const std::string &GroupName);
|
||||
explicit NamedRegionTimer(StringRef Name);
|
||||
explicit NamedRegionTimer(StringRef Name, StringRef GroupName);
|
||||
};
|
||||
|
||||
|
||||
@ -169,10 +169,10 @@ class TimerGroup {
|
||||
TimerGroup(const TimerGroup &TG); // DO NOT IMPLEMENT
|
||||
void operator=(const TimerGroup &TG); // DO NOT IMPLEMENT
|
||||
public:
|
||||
explicit TimerGroup(const std::string &name);
|
||||
explicit TimerGroup(StringRef name);
|
||||
~TimerGroup();
|
||||
|
||||
void setName(const std::string &name) { Name = name; }
|
||||
void setName(StringRef name) { Name.assign(name.begin(), name.end()); }
|
||||
|
||||
/// print - Print any started timers in this group and zero them.
|
||||
void print(raw_ostream &OS);
|
||||
|
@ -55,20 +55,20 @@ namespace {
|
||||
|
||||
// CreateInfoOutputFile - Return a file stream to print our output on.
|
||||
raw_ostream *llvm::CreateInfoOutputFile() {
|
||||
std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename();
|
||||
if (LibSupportInfoOutputFilename.empty())
|
||||
const std::string &OutputFilename = getLibSupportInfoOutputFilename();
|
||||
if (OutputFilename.empty())
|
||||
return new raw_fd_ostream(2, false); // stderr.
|
||||
if (LibSupportInfoOutputFilename == "-")
|
||||
if (OutputFilename == "-")
|
||||
return new raw_fd_ostream(1, false); // stdout.
|
||||
|
||||
std::string Error;
|
||||
raw_ostream *Result = new raw_fd_ostream(LibSupportInfoOutputFilename.c_str(),
|
||||
raw_ostream *Result = new raw_fd_ostream(OutputFilename.c_str(),
|
||||
Error, raw_fd_ostream::F_Append);
|
||||
if (Error.empty())
|
||||
return Result;
|
||||
|
||||
errs() << "Error opening info-output-file '"
|
||||
<< LibSupportInfoOutputFilename << " for appending!\n";
|
||||
<< OutputFilename << " for appending!\n";
|
||||
delete Result;
|
||||
return new raw_fd_ostream(2, false); // stderr.
|
||||
}
|
||||
@ -96,17 +96,17 @@ static TimerGroup *getDefaultTimerGroup() {
|
||||
// Timer Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void Timer::init(const std::string &N) {
|
||||
void Timer::init(StringRef N) {
|
||||
assert(TG == 0 && "Timer already initialized");
|
||||
Name = N;
|
||||
Name.assign(N.begin(), N.end());
|
||||
Started = false;
|
||||
TG = getDefaultTimerGroup();
|
||||
TG->addTimer(*this);
|
||||
}
|
||||
|
||||
void Timer::init(const std::string &N, TimerGroup &tg) {
|
||||
void Timer::init(StringRef N, TimerGroup &tg) {
|
||||
assert(TG == 0 && "Timer already initialized");
|
||||
Name = N;
|
||||
Name.assign(N.begin(), N.end());
|
||||
Started = false;
|
||||
TG = &tg;
|
||||
TG->addTimer(*this);
|
||||
@ -201,7 +201,7 @@ public:
|
||||
delete I->second.first;
|
||||
}
|
||||
|
||||
Timer &get(const std::string &Name, const std::string &GroupName) {
|
||||
Timer &get(StringRef Name, StringRef GroupName) {
|
||||
sys::SmartScopedLock<true> L(*TimerLock);
|
||||
|
||||
std::pair<TimerGroup*, Name2TimerMap> &GroupEntry = Map[GroupName];
|
||||
@ -219,7 +219,7 @@ public:
|
||||
static ManagedStatic<Name2TimerMap> NamedTimers;
|
||||
static ManagedStatic<Name2PairMap> NamedGroupedTimers;
|
||||
|
||||
static Timer &getNamedRegionTimer(const std::string &Name) {
|
||||
static Timer &getNamedRegionTimer(StringRef Name) {
|
||||
sys::SmartScopedLock<true> L(*TimerLock);
|
||||
|
||||
Timer &T = (*NamedTimers)[Name];
|
||||
@ -228,11 +228,10 @@ static Timer &getNamedRegionTimer(const std::string &Name) {
|
||||
return T;
|
||||
}
|
||||
|
||||
NamedRegionTimer::NamedRegionTimer(const std::string &Name)
|
||||
NamedRegionTimer::NamedRegionTimer(StringRef Name)
|
||||
: TimeRegion(getNamedRegionTimer(Name)) {}
|
||||
|
||||
NamedRegionTimer::NamedRegionTimer(const std::string &Name,
|
||||
const std::string &GroupName)
|
||||
NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef GroupName)
|
||||
: TimeRegion(NamedGroupedTimers->get(Name, GroupName)) {}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -243,8 +242,8 @@ NamedRegionTimer::NamedRegionTimer(const std::string &Name,
|
||||
/// TimerGroup ctor/dtor and is protected by the TimerLock lock.
|
||||
static TimerGroup *TimerGroupList = 0;
|
||||
|
||||
TimerGroup::TimerGroup(const std::string &name)
|
||||
: Name(name), FirstTimer(0) {
|
||||
TimerGroup::TimerGroup(StringRef name)
|
||||
: Name(name.begin(), name.end()), FirstTimer(0) {
|
||||
|
||||
// Add the group to TimerGroupList.
|
||||
sys::SmartScopedLock<true> L(*TimerLock);
|
||||
|
Loading…
x
Reference in New Issue
Block a user