Fix the JIT in the Nightly tester. This was not a fun bug to track down.

See the comments in the patch for details.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7457 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-07-31 19:38:34 +00:00
parent 396aecd032
commit 71336a9c14
2 changed files with 28 additions and 4 deletions

View File

@ -17,7 +17,18 @@
#include <functional> #include <functional>
#include <fstream> #include <fstream>
static std::string LibSupportInfoOutputFilename; // getLibSupportInfoOutputFilename - This ugly hack is brought to you courtesy
// of constructor/destructor ordering being unspecified by C++. Basically the
// 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. 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 = new std::string();
return *LibSupportInfoOutputFilename;
}
namespace { namespace {
#ifdef HAVE_MALLINFO #ifdef HAVE_MALLINFO
@ -30,7 +41,7 @@ namespace {
cl::opt<std::string, true> cl::opt<std::string, true>
InfoOutputFilename("info-output-file", InfoOutputFilename("info-output-file",
cl::desc("File to append -stats and -timer output to"), cl::desc("File to append -stats and -timer output to"),
cl::Hidden, cl::location(LibSupportInfoOutputFilename)); cl::Hidden, cl::location(getLibSupportInfoOutputFilename()));
} }
static TimerGroup *DefaultTimerGroup = 0; static TimerGroup *DefaultTimerGroup = 0;
@ -232,6 +243,7 @@ void Timer::print(const Timer &Total, std::ostream &OS) {
// GetLibSupportInfoOutputFile - Return a file stream to print our output on... // GetLibSupportInfoOutputFile - Return a file stream to print our output on...
std::ostream *GetLibSupportInfoOutputFile() { std::ostream *GetLibSupportInfoOutputFile() {
std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename();
if (LibSupportInfoOutputFilename.empty()) if (LibSupportInfoOutputFilename.empty())
return &std::cerr; return &std::cerr;
if (LibSupportInfoOutputFilename == "-") if (LibSupportInfoOutputFilename == "-")

View File

@ -17,7 +17,18 @@
#include <functional> #include <functional>
#include <fstream> #include <fstream>
static std::string LibSupportInfoOutputFilename; // getLibSupportInfoOutputFilename - This ugly hack is brought to you courtesy
// of constructor/destructor ordering being unspecified by C++. Basically the
// 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. 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 = new std::string();
return *LibSupportInfoOutputFilename;
}
namespace { namespace {
#ifdef HAVE_MALLINFO #ifdef HAVE_MALLINFO
@ -30,7 +41,7 @@ namespace {
cl::opt<std::string, true> cl::opt<std::string, true>
InfoOutputFilename("info-output-file", InfoOutputFilename("info-output-file",
cl::desc("File to append -stats and -timer output to"), cl::desc("File to append -stats and -timer output to"),
cl::Hidden, cl::location(LibSupportInfoOutputFilename)); cl::Hidden, cl::location(getLibSupportInfoOutputFilename()));
} }
static TimerGroup *DefaultTimerGroup = 0; static TimerGroup *DefaultTimerGroup = 0;
@ -232,6 +243,7 @@ void Timer::print(const Timer &Total, std::ostream &OS) {
// GetLibSupportInfoOutputFile - Return a file stream to print our output on... // GetLibSupportInfoOutputFile - Return a file stream to print our output on...
std::ostream *GetLibSupportInfoOutputFile() { std::ostream *GetLibSupportInfoOutputFile() {
std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename();
if (LibSupportInfoOutputFilename.empty()) if (LibSupportInfoOutputFilename.empty())
return &std::cerr; return &std::cerr;
if (LibSupportInfoOutputFilename == "-") if (LibSupportInfoOutputFilename == "-")