aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Support/Timer.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/llvm/Support/Timer.h b/include/llvm/Support/Timer.h
index b9882a9708..584199f440 100644
--- a/include/llvm/Support/Timer.h
+++ b/include/llvm/Support/Timer.h
@@ -113,14 +113,19 @@ private:
/// the relevant timer. This makes it easy to time a region of code.
///
class TimeRegion {
- Timer &T;
+ Timer *T;
TimeRegion(const TimeRegion &); // DO NOT IMPLEMENT
public:
- explicit TimeRegion(Timer &t) : T(t) {
- T.startTimer();
+ explicit TimeRegion(Timer &t) : T(&t) {
+ T->startTimer();
+ }
+ explicit TimeRegion(Timer *t) : T(t) {
+ if (T)
+ T->startTimer();
}
~TimeRegion() {
- T.stopTimer();
+ if (T)
+ T->stopTimer();
}
};