Just make the Dwarf timer group static inside of the getter function. No need to alloc/dealloc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66591 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
index 88c0714..e9fb32c 100644
--- a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
@@ -48,10 +48,9 @@
X("dwarfwriter", "DWARF Information Writer");
char DwarfWriter::ID = 0;
-static TimerGroup *DwarfTimerGroup = 0;
-static TimerGroup *getDwarfTimerGroup() {
- if (DwarfTimerGroup) return DwarfTimerGroup;
- return DwarfTimerGroup = new TimerGroup("Dwarf Exception and Debugging");
+static TimerGroup &getDwarfTimerGroup() {
+ static TimerGroup DwarfTimerGroup("Dwarf Exception and Debugging");
+ return DwarfTimerGroup;
}
namespace llvm {
@@ -3022,7 +3021,7 @@
RootDbgScope(0), DebugTimer(0) {
if (TimePassesIsEnabled)
DebugTimer = new Timer("Dwarf Debug Writer",
- *getDwarfTimerGroup());
+ getDwarfTimerGroup());
}
virtual ~DwarfDebug() {
for (unsigned j = 0, M = Values.size(); j < M; ++j)
@@ -4068,7 +4067,7 @@
ExceptionTimer(0) {
if (TimePassesIsEnabled)
ExceptionTimer = new Timer("Dwarf Exception Writer",
- *getDwarfTimerGroup());
+ getDwarfTimerGroup());
}
virtual ~DwarfException() {
@@ -4491,7 +4490,6 @@
DwarfWriter::~DwarfWriter() {
delete DE;
delete DD;
- delete DwarfTimerGroup; DwarfTimerGroup = 0;
}
/// BeginModule - Emit all Dwarf sections that should come prior to the