diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp index 4b88be2b0947..ff3fd6fefe02 100644 --- a/llvm/lib/Support/Timer.cpp +++ b/llvm/lib/Support/Timer.cpp @@ -33,10 +33,12 @@ namespace llvm { extern std::ostream *GetLibSupportInfoOutputFile(); } // problem is that a Statistic<> object gets destroyed, which ends up calling // 'GetLibSupportInfoOutputFile()' (below), which calls this function. // LibSupportInfoOutputFilename used to be a global variable, but sometimes it -// would get destroyed before the Statistic, causing havoc to ensue. +// would get destroyed before the Statistic, causing havoc to ensue. We "fix" +// this by creating the string the first time it is needed and never destroying +// it. static std::string &getLibSupportInfoOutputFilename() { - static std::string LibSupportInfoOutputFilename; - return LibSupportInfoOutputFilename; + static std::string *LibSupportInfoOutputFilename = new std::string(); + return *LibSupportInfoOutputFilename; } namespace {