mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Replacing std::iostreams with llvm iostreams. Some of these changes involve
adding a temporary wrapper around the ostream to make it friendly to functions expecting an LLVM stream. This should be fixed in the future. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31990 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Support/FileUtilities.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/System/Path.h"
|
||||
#include "llvm/System/Program.h"
|
||||
#include "llvm/Config/alloca.h"
|
||||
@@ -55,7 +56,8 @@ bool BugDriver::writeProgramToFile(const std::string &Filename,
|
||||
std::ofstream Out(Filename.c_str(), io_mode);
|
||||
if (!Out.good()) return true;
|
||||
try {
|
||||
WriteBytecodeToFile(M ? M : Program, Out, /*compression=*/true);
|
||||
llvm_ostream L(Out);
|
||||
WriteBytecodeToFile(M ? M : Program, L, /*compression=*/true);
|
||||
} catch (...) {
|
||||
return true;
|
||||
}
|
||||
@@ -72,15 +74,15 @@ void BugDriver::EmitProgressBytecode(const std::string &ID, bool NoFlyer) {
|
||||
//
|
||||
std::string Filename = "bugpoint-" + ID + ".bc";
|
||||
if (writeProgramToFile(Filename)) {
|
||||
std::cerr << "Error opening file '" << Filename << "' for writing!\n";
|
||||
llvm_cerr << "Error opening file '" << Filename << "' for writing!\n";
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "Emitted bytecode to '" << Filename << "'\n";
|
||||
llvm_cout << "Emitted bytecode to '" << Filename << "'\n";
|
||||
if (NoFlyer || PassesToRun.empty()) return;
|
||||
std::cout << "\n*** You can reproduce the problem with: ";
|
||||
std::cout << "opt " << Filename << " ";
|
||||
std::cout << getPassesString(PassesToRun) << "\n";
|
||||
llvm_cout << "\n*** You can reproduce the problem with: ";
|
||||
llvm_cout << "opt " << Filename << " ";
|
||||
llvm_cout << getPassesString(PassesToRun) << "\n";
|
||||
}
|
||||
|
||||
int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) {
|
||||
@@ -89,7 +91,7 @@ int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) {
|
||||
std::ios::binary;
|
||||
std::ofstream OutFile(ChildOutput.c_str(), io_mode);
|
||||
if (!OutFile.good()) {
|
||||
std::cerr << "Error opening bytecode file: " << ChildOutput << "\n";
|
||||
llvm_cerr << "Error opening bytecode file: " << ChildOutput << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -101,14 +103,15 @@ int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) {
|
||||
if (Passes[i]->getNormalCtor())
|
||||
PM.add(Passes[i]->getNormalCtor()());
|
||||
else
|
||||
std::cerr << "Cannot create pass yet: " << Passes[i]->getPassName()
|
||||
llvm_cerr << "Cannot create pass yet: " << Passes[i]->getPassName()
|
||||
<< "\n";
|
||||
}
|
||||
// Check that the module is well formed on completion of optimization
|
||||
PM.add(createVerifierPass());
|
||||
|
||||
// Write bytecode out to disk as the last step...
|
||||
PM.add(new WriteBytecodePass(&OutFile));
|
||||
llvm_ostream L(OutFile);
|
||||
PM.add(new WriteBytecodePass(&L));
|
||||
|
||||
// Run all queued passes.
|
||||
PM.run(*Program);
|
||||
@@ -128,11 +131,11 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
|
||||
std::string &OutputFilename, bool DeleteOutput,
|
||||
bool Quiet) const {
|
||||
// setup the output file name
|
||||
std::cout << std::flush;
|
||||
llvm_cout << std::flush;
|
||||
sys::Path uniqueFilename("bugpoint-output.bc");
|
||||
std::string ErrMsg;
|
||||
if (uniqueFilename.makeUnique(true, &ErrMsg)) {
|
||||
std::cerr << getToolName() << ": Error making unique filename: "
|
||||
llvm_cerr << getToolName() << ": Error making unique filename: "
|
||||
<< ErrMsg << "\n";
|
||||
return(1);
|
||||
}
|
||||
@@ -141,7 +144,7 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
|
||||
// set up the input file name
|
||||
sys::Path inputFilename("bugpoint-input.bc");
|
||||
if (inputFilename.makeUnique(true, &ErrMsg)) {
|
||||
std::cerr << getToolName() << ": Error making unique filename: "
|
||||
llvm_cerr << getToolName() << ": Error making unique filename: "
|
||||
<< ErrMsg << "\n";
|
||||
return(1);
|
||||
}
|
||||
@@ -149,10 +152,11 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
|
||||
std::ios::binary;
|
||||
std::ofstream InFile(inputFilename.c_str(), io_mode);
|
||||
if (!InFile.good()) {
|
||||
std::cerr << "Error opening bytecode file: " << inputFilename << "\n";
|
||||
llvm_cerr << "Error opening bytecode file: " << inputFilename << "\n";
|
||||
return(1);
|
||||
}
|
||||
WriteBytecodeToFile(Program,InFile,false);
|
||||
llvm_ostream L(InFile);
|
||||
WriteBytecodeToFile(Program,L,false);
|
||||
InFile.close();
|
||||
|
||||
// setup the child process' arguments
|
||||
@@ -203,17 +207,17 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
|
||||
|
||||
if (!Quiet) {
|
||||
if (result == 0)
|
||||
std::cout << "Success!\n";
|
||||
llvm_cout << "Success!\n";
|
||||
else if (result > 0)
|
||||
std::cout << "Exited with error code '" << result << "'\n";
|
||||
llvm_cout << "Exited with error code '" << result << "'\n";
|
||||
else if (result < 0) {
|
||||
if (result == -1)
|
||||
std::cout << "Execute failed: " << ErrMsg << "\n";
|
||||
llvm_cout << "Execute failed: " << ErrMsg << "\n";
|
||||
else
|
||||
std::cout << "Crashed with signal #" << abs(result) << "\n";
|
||||
llvm_cout << "Crashed with signal #" << abs(result) << "\n";
|
||||
}
|
||||
if (result & 0x01000000)
|
||||
std::cout << "Dumped core\n";
|
||||
llvm_cout << "Dumped core\n";
|
||||
}
|
||||
|
||||
// Was the child successful?
|
||||
@@ -231,7 +235,7 @@ Module *BugDriver::runPassesOn(Module *M,
|
||||
std::string BytecodeResult;
|
||||
if (runPasses(Passes, BytecodeResult, false/*delete*/, true/*quiet*/)) {
|
||||
if (AutoDebugCrashes) {
|
||||
std::cerr << " Error running this sequence of passes"
|
||||
llvm_cerr << " Error running this sequence of passes"
|
||||
<< " on the input program!\n";
|
||||
delete OldProgram;
|
||||
EmitProgressBytecode("pass-error", false);
|
||||
@@ -246,7 +250,7 @@ Module *BugDriver::runPassesOn(Module *M,
|
||||
|
||||
Module *Ret = ParseInputFile(BytecodeResult);
|
||||
if (Ret == 0) {
|
||||
std::cerr << getToolName() << ": Error reading bytecode file '"
|
||||
llvm_cerr << getToolName() << ": Error reading bytecode file '"
|
||||
<< BytecodeResult << "'!\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user