mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
remove some uses of llvm/Support/Streams.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79842 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b515d75856
commit
d9ea85ab01
@ -19,12 +19,12 @@
|
||||
#include "llvm/System/Mutex.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iosfwd>
|
||||
#include <cassert>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class TimerGroup;
|
||||
class raw_ostream;
|
||||
|
||||
/// Timer - This class is used to track the amount of time spent between
|
||||
/// invocations of it's startTimer()/stopTimer() methods. Given appropriate OS
|
||||
@ -112,7 +112,7 @@ public:
|
||||
|
||||
/// print - Print the current timer to standard error, and reset the "Started"
|
||||
/// flag.
|
||||
void print(const Timer &Total, std::ostream &OS);
|
||||
void print(const Timer &Total, raw_ostream &OS);
|
||||
|
||||
private:
|
||||
friend class TimerGroup;
|
||||
|
@ -12,11 +12,8 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Bitcode/Serialize.h"
|
||||
#include "string.h"
|
||||
|
||||
#ifdef DEBUG_BACKPATCH
|
||||
#include "llvm/Support/Streams.h"
|
||||
#endif
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <cstring>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
@ -86,7 +83,7 @@ SerializedPtrID Serializer::getPtrId(const void* ptr) {
|
||||
if (I == PtrMap.end()) {
|
||||
unsigned id = PtrMap.size()+1;
|
||||
#ifdef DEBUG_BACKPATCH
|
||||
llvm::cerr << "Registered PTR: " << ptr << " => " << id << "\n";
|
||||
errs() << "Registered PTR: " << ptr << " => " << id << "\n";
|
||||
#endif
|
||||
PtrMap[ptr] = id;
|
||||
return id;
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/LeakDetector.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
using namespace llvm;
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Support/Dwarf.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
using namespace llvm;
|
||||
using namespace llvm::dwarf;
|
||||
|
||||
|
@ -2598,9 +2598,9 @@ SimpleRegisterCoalescing::lastRegisterUse(unsigned Start, unsigned End,
|
||||
|
||||
void SimpleRegisterCoalescing::printRegName(unsigned reg) const {
|
||||
if (TargetRegisterInfo::isPhysicalRegister(reg))
|
||||
cerr << tri_->getName(reg);
|
||||
errs() << tri_->getName(reg);
|
||||
else
|
||||
cerr << "%reg" << reg;
|
||||
errs() << "%reg" << reg;
|
||||
}
|
||||
|
||||
void SimpleRegisterCoalescing::releaseMemory() {
|
||||
|
@ -259,11 +259,6 @@ bool VirtRegMap::FindUnusedRegisters(LiveIntervals* LIs) {
|
||||
return AnyUnused;
|
||||
}
|
||||
|
||||
void VirtRegMap::print(std::ostream &OS, const Module* M) const {
|
||||
raw_os_ostream RawOS(OS);
|
||||
print(RawOS, M);
|
||||
}
|
||||
|
||||
void VirtRegMap::print(raw_ostream &OS, const Module* M) const {
|
||||
const TargetRegisterInfo* TRI = MF->getTarget().getRegisterInfo();
|
||||
|
||||
@ -283,5 +278,5 @@ void VirtRegMap::print(raw_ostream &OS, const Module* M) const {
|
||||
}
|
||||
|
||||
void VirtRegMap::dump() const {
|
||||
print(cerr);
|
||||
print(errs());
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "llvm/ADT/IndexedMap.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include <map>
|
||||
|
||||
namespace llvm {
|
||||
@ -482,25 +481,10 @@ namespace llvm {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void print(std::ostream &OS, const Module* M = 0) const;
|
||||
void print(std::ostream *OS) const { if (OS) print(*OS); }
|
||||
void print(raw_ostream &OS, const Module* M = 0) const;
|
||||
void print(raw_ostream *OS) const { if (OS) print(*OS); }
|
||||
void dump() const;
|
||||
};
|
||||
|
||||
inline std::ostream *operator<<(std::ostream *OS, const VirtRegMap &VRM) {
|
||||
VRM.print(OS);
|
||||
return OS;
|
||||
}
|
||||
inline std::ostream &operator<<(std::ostream &OS, const VirtRegMap &VRM) {
|
||||
VRM.print(OS);
|
||||
return OS;
|
||||
}
|
||||
inline raw_ostream *operator<<(raw_ostream *OS, const VirtRegMap &VRM) {
|
||||
VRM.print(OS);
|
||||
return OS;
|
||||
}
|
||||
inline raw_ostream &operator<<(raw_ostream &OS, const VirtRegMap &VRM) {
|
||||
VRM.print(OS);
|
||||
return OS;
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "llvm/Debugger/SourceFile.h"
|
||||
#include "llvm/Debugger/SourceLanguage.h"
|
||||
#include "llvm/Support/SlowOperationInformer.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
using namespace llvm;
|
||||
|
||||
@ -184,7 +183,7 @@ void SourceFunctionInfo::getSourceLocation(unsigned &RetLineNo,
|
||||
if (SD) { // We found the first stop point!
|
||||
// This is just a sanity check.
|
||||
if (getSourceFile().getDescriptor() != SD)
|
||||
cout << "WARNING: first line of function is not in the"
|
||||
outs() << "WARNING: first line of function is not in the"
|
||||
<< " file that the function descriptor claims it is in.\n";
|
||||
break;
|
||||
}
|
||||
|
@ -15,9 +15,8 @@
|
||||
|
||||
#include "llvm/Debugger/SourceLanguage.h"
|
||||
#include "llvm/Debugger/ProgramInfo.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <cassert>
|
||||
#include <ostream>
|
||||
using namespace llvm;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -132,7 +131,7 @@ SourceFunctionInfo *SLU::lookupFunction(const std::string &FunctionName,
|
||||
SourceFunctionInfo *Found = IP.first->second;
|
||||
++IP.first;
|
||||
if (IP.first != IP.second)
|
||||
cout << "Whoa, found multiple functions with the same name. I should"
|
||||
outs() << "Whoa, found multiple functions with the same name. I should"
|
||||
<< " ask the user which one to use: FIXME!\n";
|
||||
return Found;
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Config/config.h" // Detect libffi
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/System/DynamicLibrary.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
@ -279,7 +278,7 @@ GenericValue Interpreter::callExternalFunction(Function *F,
|
||||
#endif // USE_LIBFFI
|
||||
|
||||
if (F->getName() == "__main")
|
||||
cerr << "Tried to execute an unknown external function: "
|
||||
errs() << "Tried to execute an unknown external function: "
|
||||
<< F->getType()->getDescription() << " __main\n";
|
||||
else
|
||||
llvm_report_error("Tried to execute an unknown external function: " +
|
||||
@ -393,7 +392,8 @@ GenericValue lle_X_sprintf(const FunctionType *FT,
|
||||
sprintf(Buffer, FmtBuf, (void*)GVTOP(Args[ArgNo++])); break;
|
||||
case 's':
|
||||
sprintf(Buffer, FmtBuf, (char*)GVTOP(Args[ArgNo++])); break;
|
||||
default: cerr << "<unknown printf code '" << *FmtStr << "'!>";
|
||||
default:
|
||||
errs() << "<unknown printf code '" << *FmtStr << "'!>";
|
||||
ArgNo++; break;
|
||||
}
|
||||
strcpy(OutputBuffer, Buffer);
|
||||
@ -414,7 +414,7 @@ GenericValue lle_X_printf(const FunctionType *FT,
|
||||
NewArgs.push_back(PTOGV((void*)&Buffer[0]));
|
||||
NewArgs.insert(NewArgs.end(), Args.begin(), Args.end());
|
||||
GenericValue GV = lle_X_sprintf(FT, NewArgs);
|
||||
cout << Buffer;
|
||||
outs() << Buffer;
|
||||
return GV;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
#include "JIT.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/System/DynamicLibrary.h"
|
||||
#include "llvm/Config/config.h"
|
||||
using namespace llvm;
|
||||
|
@ -851,13 +851,12 @@ size_t basic_parser_impl::getOptionWidth(const Option &O) const {
|
||||
//
|
||||
void basic_parser_impl::printOptionInfo(const Option &O,
|
||||
size_t GlobalWidth) const {
|
||||
cout << " -" << O.ArgStr;
|
||||
outs() << " -" << O.ArgStr;
|
||||
|
||||
if (const char *ValName = getValueName())
|
||||
cout << "=<" << getValueStr(O, ValName) << ">";
|
||||
outs() << "=<" << getValueStr(O, ValName) << '>';
|
||||
|
||||
cout << std::string(GlobalWidth-getOptionWidth(O), ' ') << " - "
|
||||
<< O.HelpStr << "\n";
|
||||
outs().indent(GlobalWidth-getOptionWidth(O)) << " - " << O.HelpStr << '\n';
|
||||
}
|
||||
|
||||
|
||||
@ -990,21 +989,21 @@ void generic_parser_base::printOptionInfo(const Option &O,
|
||||
size_t GlobalWidth) const {
|
||||
if (O.hasArgStr()) {
|
||||
size_t L = std::strlen(O.ArgStr);
|
||||
cout << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ')
|
||||
<< " - " << O.HelpStr << "\n";
|
||||
outs() << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ')
|
||||
<< " - " << O.HelpStr << '\n';
|
||||
|
||||
for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
|
||||
size_t NumSpaces = GlobalWidth-strlen(getOption(i))-8;
|
||||
cout << " =" << getOption(i) << std::string(NumSpaces, ' ')
|
||||
<< " - " << getDescription(i) << "\n";
|
||||
outs() << " =" << getOption(i) << std::string(NumSpaces, ' ')
|
||||
<< " - " << getDescription(i) << '\n';
|
||||
}
|
||||
} else {
|
||||
if (O.HelpStr[0])
|
||||
cout << " " << O.HelpStr << "\n";
|
||||
outs() << " " << O.HelpStr << "\n";
|
||||
for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
|
||||
size_t L = std::strlen(getOption(i));
|
||||
cout << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ')
|
||||
<< " - " << getDescription(i) << "\n";
|
||||
outs() << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ')
|
||||
<< " - " << getDescription(i) << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1063,9 +1062,9 @@ public:
|
||||
}
|
||||
|
||||
if (ProgramOverview)
|
||||
cout << "OVERVIEW: " << ProgramOverview << "\n";
|
||||
outs() << "OVERVIEW: " << ProgramOverview << "\n";
|
||||
|
||||
cout << "USAGE: " << ProgramName << " [options]";
|
||||
outs() << "USAGE: " << ProgramName << " [options]";
|
||||
|
||||
// Print out the positional options.
|
||||
Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists...
|
||||
@ -1075,28 +1074,28 @@ public:
|
||||
|
||||
for (size_t i = CAOpt != 0, e = PositionalOpts.size(); i != e; ++i) {
|
||||
if (PositionalOpts[i]->ArgStr[0])
|
||||
cout << " --" << PositionalOpts[i]->ArgStr;
|
||||
cout << " " << PositionalOpts[i]->HelpStr;
|
||||
outs() << " --" << PositionalOpts[i]->ArgStr;
|
||||
outs() << " " << PositionalOpts[i]->HelpStr;
|
||||
}
|
||||
|
||||
// Print the consume after option info if it exists...
|
||||
if (CAOpt) cout << " " << CAOpt->HelpStr;
|
||||
if (CAOpt) outs() << " " << CAOpt->HelpStr;
|
||||
|
||||
cout << "\n\n";
|
||||
outs() << "\n\n";
|
||||
|
||||
// Compute the maximum argument length...
|
||||
MaxArgLen = 0;
|
||||
for (size_t i = 0, e = Opts.size(); i != e; ++i)
|
||||
MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth());
|
||||
|
||||
cout << "OPTIONS:\n";
|
||||
outs() << "OPTIONS:\n";
|
||||
for (size_t i = 0, e = Opts.size(); i != e; ++i)
|
||||
Opts[i].second->printOptionInfo(MaxArgLen);
|
||||
|
||||
// Print any extra help the user has declared.
|
||||
for (std::vector<const char *>::iterator I = MoreHelp->begin(),
|
||||
E = MoreHelp->end(); I != E; ++I)
|
||||
cout << *I;
|
||||
outs() << *I;
|
||||
MoreHelp->clear();
|
||||
|
||||
// Halt the program since help information was printed
|
||||
@ -1125,42 +1124,43 @@ namespace {
|
||||
class VersionPrinter {
|
||||
public:
|
||||
void print() {
|
||||
cout << "Low Level Virtual Machine (http://llvm.org/):\n";
|
||||
cout << " " << PACKAGE_NAME << " version " << PACKAGE_VERSION;
|
||||
raw_ostream &stdout = outs();
|
||||
stdout << "Low Level Virtual Machine (http://llvm.org/):\n";
|
||||
stdout << " " << PACKAGE_NAME << " version " << PACKAGE_VERSION;
|
||||
#ifdef LLVM_VERSION_INFO
|
||||
cout << LLVM_VERSION_INFO;
|
||||
stdout << LLVM_VERSION_INFO;
|
||||
#endif
|
||||
cout << "\n ";
|
||||
stdout << "\n ";
|
||||
#ifndef __OPTIMIZE__
|
||||
cout << "DEBUG build";
|
||||
stdout << "DEBUG build";
|
||||
#else
|
||||
cout << "Optimized build";
|
||||
stdout << "Optimized build";
|
||||
#endif
|
||||
#ifndef NDEBUG
|
||||
cout << " with assertions";
|
||||
stdout << " with assertions";
|
||||
#endif
|
||||
cout << ".\n";
|
||||
cout << " Built " << __DATE__ << "(" << __TIME__ << ").\n";
|
||||
cout << "\n";
|
||||
cout << " Registered Targets:\n";
|
||||
stdout << ".\n";
|
||||
stdout << " Built " << __DATE__ << "(" << __TIME__ << ").\n";
|
||||
stdout << "\n";
|
||||
stdout << " Registered Targets:\n";
|
||||
|
||||
std::vector<std::pair<std::string, const Target*> > Targets;
|
||||
size_t Width = 0;
|
||||
for (TargetRegistry::iterator it = TargetRegistry::begin(),
|
||||
ie = TargetRegistry::end(); it != ie; ++it) {
|
||||
Targets.push_back(std::make_pair(it->getName(), &*it));
|
||||
Width = std::max(Width, ::strlen(it->getName()));
|
||||
}
|
||||
std::sort(Targets.begin(), Targets.end());
|
||||
std::vector<std::pair<std::string, const Target*> > Targets;
|
||||
size_t Width = 0;
|
||||
for (TargetRegistry::iterator it = TargetRegistry::begin(),
|
||||
ie = TargetRegistry::end(); it != ie; ++it) {
|
||||
Targets.push_back(std::make_pair(it->getName(), &*it));
|
||||
Width = std::max(Width, ::strlen(it->getName()));
|
||||
}
|
||||
std::sort(Targets.begin(), Targets.end());
|
||||
|
||||
for (unsigned i = 0, e = Targets.size(); i != e; ++i) {
|
||||
const Target *T = Targets[i].second;
|
||||
cout << " " << T->getName()
|
||||
for (unsigned i = 0, e = Targets.size(); i != e; ++i) {
|
||||
const Target *T = Targets[i].second;
|
||||
stdout << " " << T->getName()
|
||||
<< std::string(Width - ::strlen(T->getName()), ' ') << " - "
|
||||
<< T->getShortDescription() << "\n";
|
||||
}
|
||||
if (Targets.empty())
|
||||
cout << " (none)\n";
|
||||
}
|
||||
if (Targets.empty())
|
||||
stdout << " (none)\n";
|
||||
}
|
||||
void operator=(bool OptionWasSpecified) {
|
||||
if (OptionWasSpecified) {
|
||||
|
@ -14,10 +14,9 @@
|
||||
#define DONT_GET_PLUGIN_LOADER_OPTION
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/PluginLoader.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/System/DynamicLibrary.h"
|
||||
#include "llvm/System/Mutex.h"
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
using namespace llvm;
|
||||
|
||||
@ -28,8 +27,8 @@ void PluginLoader::operator=(const std::string &Filename) {
|
||||
sys::SmartScopedLock<true> Lock(*PluginsLock);
|
||||
std::string Error;
|
||||
if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) {
|
||||
cerr << "Error opening '" << Filename << "': " << Error
|
||||
<< "\n -load request ignored.\n";
|
||||
errs() << "Error opening '" << Filename << "': " << Error
|
||||
<< "\n -load request ignored.\n";
|
||||
} else {
|
||||
Plugins->push_back(Filename);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Support/SlowOperationInformer.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/System/Alarm.h"
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
@ -28,8 +28,8 @@ SlowOperationInformer::~SlowOperationInformer() {
|
||||
if (LastPrintAmount) {
|
||||
// If we have printed something, make _sure_ we print the 100% amount, and
|
||||
// also print a newline.
|
||||
cout << std::string(LastPrintAmount, '\b') << "Progress "
|
||||
<< OperationName << ": 100% \n";
|
||||
outs() << std::string(LastPrintAmount, '\b') << "Progress "
|
||||
<< OperationName << ": 100% \n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ SlowOperationInformer::~SlowOperationInformer() {
|
||||
bool SlowOperationInformer::progress(unsigned Amount) {
|
||||
int status = sys::AlarmStatus();
|
||||
if (status == -1) {
|
||||
cout << "\n";
|
||||
outs() << "\n";
|
||||
LastPrintAmount = 0;
|
||||
return true;
|
||||
}
|
||||
@ -61,6 +61,7 @@ bool SlowOperationInformer::progress(unsigned Amount) {
|
||||
OS << "% ";
|
||||
|
||||
LastPrintAmount = OS.str().size();
|
||||
cout << ToPrint+OS.str() << std::flush;
|
||||
outs() << ToPrint+OS.str();
|
||||
outs().flush();
|
||||
return false;
|
||||
}
|
||||
|
@ -24,16 +24,15 @@
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/System/Mutex.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include <algorithm>
|
||||
#include <ostream>
|
||||
#include <cstring>
|
||||
using namespace llvm;
|
||||
|
||||
// GetLibSupportInfoOutputFile - Return a file stream to print our output on.
|
||||
namespace llvm { extern std::ostream *GetLibSupportInfoOutputFile(); }
|
||||
namespace llvm { extern raw_ostream *GetLibSupportInfoOutputFile(); }
|
||||
|
||||
/// -stats - Command line option to cause transformations to emit stats about
|
||||
/// what they did.
|
||||
@ -96,7 +95,7 @@ StatisticInfo::~StatisticInfo() {
|
||||
if (Stats.empty()) return;
|
||||
|
||||
// Get the stream to write to.
|
||||
std::ostream &OutStream = *GetLibSupportInfoOutputFile();
|
||||
raw_ostream &OutStream = *GetLibSupportInfoOutputFile();
|
||||
|
||||
// Figure out how long the biggest Value and Name fields are.
|
||||
unsigned MaxNameLen = 0, MaxValLen = 0;
|
||||
@ -125,8 +124,9 @@ StatisticInfo::~StatisticInfo() {
|
||||
|
||||
}
|
||||
|
||||
OutStream << std::endl; // Flush the output stream...
|
||||
OutStream << '\n'; // Flush the output stream...
|
||||
OutStream.flush();
|
||||
|
||||
if (&OutStream != cerr.stream() && &OutStream != cout.stream())
|
||||
if (&OutStream != &outs() && &OutStream != &errs())
|
||||
delete &OutStream; // Close the file.
|
||||
}
|
||||
|
@ -14,16 +14,16 @@
|
||||
#include "llvm/Support/Timer.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Support/Format.h"
|
||||
#include "llvm/System/Process.h"
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
using namespace llvm;
|
||||
|
||||
// GetLibSupportInfoOutputFile - Return a file stream to print our output on.
|
||||
namespace llvm { extern std::ostream *GetLibSupportInfoOutputFile(); }
|
||||
namespace llvm { extern raw_ostream *GetLibSupportInfoOutputFile(); }
|
||||
|
||||
// getLibSupportInfoOutputFilename - This ugly hack is brought to you courtesy
|
||||
// of constructor/destructor ordering being unspecified by C++. Basically the
|
||||
@ -269,38 +269,17 @@ NamedRegionTimer::NamedRegionTimer(const std::string &Name,
|
||||
// TimerGroup Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// printAlignedFP - Simulate the printf "%A.Bf" format, where A is the
|
||||
// TotalWidth size, and B is the AfterDec size.
|
||||
//
|
||||
static void printAlignedFP(double Val, unsigned AfterDec, unsigned TotalWidth,
|
||||
std::ostream &OS) {
|
||||
assert(TotalWidth >= AfterDec+1 && "Bad FP Format!");
|
||||
OS.width(TotalWidth-AfterDec-1);
|
||||
char OldFill = OS.fill();
|
||||
OS.fill(' ');
|
||||
OS << (int)Val; // Integer part;
|
||||
OS << ".";
|
||||
OS.width(AfterDec);
|
||||
OS.fill('0');
|
||||
unsigned ResultFieldSize = 1;
|
||||
while (AfterDec--) ResultFieldSize *= 10;
|
||||
OS << (int)(Val*ResultFieldSize) % ResultFieldSize;
|
||||
OS.fill(OldFill);
|
||||
}
|
||||
|
||||
static void printVal(double Val, double Total, std::ostream &OS) {
|
||||
static void printVal(double Val, double Total, raw_ostream &OS) {
|
||||
if (Total < 1e-7) // Avoid dividing by zero...
|
||||
OS << " ----- ";
|
||||
else {
|
||||
OS << " ";
|
||||
printAlignedFP(Val, 4, 7, OS);
|
||||
OS << " (";
|
||||
printAlignedFP(Val*100/Total, 1, 5, OS);
|
||||
OS << "%)";
|
||||
OS << " " << format("%7.4f", Val) << " (";
|
||||
OS << format("%5.1f", Val*100/Total) << "%)";
|
||||
}
|
||||
}
|
||||
|
||||
void Timer::print(const Timer &Total, std::ostream &OS) {
|
||||
void Timer::print(const Timer &Total, raw_ostream &OS) {
|
||||
if (&Total < this) {
|
||||
Total.Lock.acquire();
|
||||
Lock.acquire();
|
||||
@ -320,13 +299,11 @@ void Timer::print(const Timer &Total, std::ostream &OS) {
|
||||
OS << " ";
|
||||
|
||||
if (Total.MemUsed) {
|
||||
OS.width(9);
|
||||
OS << MemUsed << " ";
|
||||
OS << format("%9lld", (long long)MemUsed) << " ";
|
||||
}
|
||||
if (Total.PeakMem) {
|
||||
if (PeakMem) {
|
||||
OS.width(9);
|
||||
OS << PeakMem << " ";
|
||||
OS << format("%9lld", (long long)PeakMem) << " ";
|
||||
} else
|
||||
OS << " ";
|
||||
}
|
||||
@ -344,23 +321,25 @@ void Timer::print(const Timer &Total, std::ostream &OS) {
|
||||
}
|
||||
|
||||
// GetLibSupportInfoOutputFile - Return a file stream to print our output on...
|
||||
std::ostream *
|
||||
raw_ostream *
|
||||
llvm::GetLibSupportInfoOutputFile() {
|
||||
std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename();
|
||||
if (LibSupportInfoOutputFilename.empty())
|
||||
return cerr.stream();
|
||||
return &errs();
|
||||
if (LibSupportInfoOutputFilename == "-")
|
||||
return cout.stream();
|
||||
return &outs();
|
||||
|
||||
std::ostream *Result = new std::ofstream(LibSupportInfoOutputFilename.c_str(),
|
||||
std::ios::app);
|
||||
if (!Result->good()) {
|
||||
cerr << "Error opening info-output-file '"
|
||||
|
||||
std::string Error;
|
||||
raw_ostream *Result = new raw_fd_ostream(LibSupportInfoOutputFilename.c_str(),
|
||||
Error, raw_fd_ostream::F_Append);
|
||||
if (Error.empty())
|
||||
return Result;
|
||||
|
||||
errs() << "Error opening info-output-file '"
|
||||
<< LibSupportInfoOutputFilename << " for appending!\n";
|
||||
delete Result;
|
||||
return cerr.stream();
|
||||
}
|
||||
return Result;
|
||||
delete Result;
|
||||
return &errs();
|
||||
}
|
||||
|
||||
|
||||
@ -375,7 +354,7 @@ void TimerGroup::removeTimer() {
|
||||
unsigned Padding = (80-Name.length())/2;
|
||||
if (Padding > 80) Padding = 0; // Don't allow "negative" numbers
|
||||
|
||||
std::ostream *OutStream = GetLibSupportInfoOutputFile();
|
||||
raw_ostream *OutStream = GetLibSupportInfoOutputFile();
|
||||
|
||||
++NumTimers;
|
||||
{ // Scope to contain Total timer... don't allow total timer to drop us to
|
||||
@ -397,10 +376,8 @@ void TimerGroup::removeTimer() {
|
||||
if (this != DefaultTimerGroup) {
|
||||
*OutStream << " Total Execution Time: ";
|
||||
|
||||
printAlignedFP(Total.getProcessTime(), 4, 5, *OutStream);
|
||||
*OutStream << " seconds (";
|
||||
printAlignedFP(Total.getWallTime(), 4, 5, *OutStream);
|
||||
*OutStream << " wall clock)\n";
|
||||
*OutStream << format("%5.4f", Total.getProcessTime()) << " seconds (";
|
||||
*OutStream << format("%5.4f", Total.getWallTime()) << " wall clock)\n";
|
||||
}
|
||||
*OutStream << "\n";
|
||||
|
||||
@ -422,13 +399,14 @@ void TimerGroup::removeTimer() {
|
||||
TimersToPrint[i].print(Total, *OutStream);
|
||||
|
||||
Total.print(Total, *OutStream);
|
||||
*OutStream << std::endl; // Flush output
|
||||
*OutStream << '\n';
|
||||
OutStream->flush();
|
||||
}
|
||||
--NumTimers;
|
||||
|
||||
TimersToPrint.clear();
|
||||
|
||||
if (OutStream != cerr.stream() && OutStream != cout.stream())
|
||||
if (OutStream != &errs() && OutStream != &outs())
|
||||
delete OutStream; // Close the file...
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user