1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

Pretty straightforward replacement of "bytecode" by "bitcode"

performed on tools/ first, in order not to cause lethal damage

llvm-svn: 37877
This commit is contained in:
Gabor Greif 2007-07-04 21:55:50 +00:00
parent 9072b65b0b
commit 9e76bbf30e
10 changed files with 148 additions and 148 deletions

View File

@ -69,7 +69,7 @@ BugDriver::BugDriver(const char *toolname, bool as_child, bool find_bugs,
run_find_bugs(find_bugs), Timeout(timeout), MemoryLimit(memlimit) {}
/// ParseInputFile - Given a bytecode or assembly input filename, parse and
/// ParseInputFile - Given a bitcode or assembly input filename, parse and
/// return it, or return null if not possible.
///
Module *llvm::ParseInputFile(const std::string &Filename) {
@ -88,8 +88,8 @@ Module *llvm::ParseInputFile(const std::string &Filename) {
}
// This method takes the specified list of LLVM input files, attempts to load
// them, either as assembly or bytecode, then link them together. It returns
// true on failure (if, for example, an input bytecode file could not be
// them, either as assembly or bitcode, then link them together. It returns
// true on failure (if, for example, an input bitcode file could not be
// parsed), and false on success.
//
bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
@ -153,7 +153,7 @@ bool BugDriver::run() {
// determine what the problem is. Does the optimization series crash the
// compiler, or does it produce illegal code? We make the top-level
// decision by trying to run all of the passes on the the input program,
// which should generate a bytecode file. If it does generate a bytecode
// which should generate a bitcode file. If it does generate a bitcode
// file, then we know the compiler didn't crash, so try to diagnose a
// miscompilation.
if (!PassesToRun.empty()) {
@ -162,7 +162,7 @@ bool BugDriver::run() {
return debugOptimizerCrash();
}
// Set up the execution environment, selecting a method to run LLVM bytecode.
// Set up the execution environment, selecting a method to run LLVM bitcode.
if (initializeExecutionEnvironment()) return true;
// Test to see if we have a code generator crash.

View File

@ -107,9 +107,9 @@ public:
const std::string &ReferenceOutput);
/// compileSharedObject - This method creates a SharedObject from a given
/// BytecodeFile for debugging a code generator.
/// BitcodeFile for debugging a code generator.
///
std::string compileSharedObject(const std::string &BytecodeFile);
std::string compileSharedObject(const std::string &BitcodeFile);
/// debugCodeGenerator - This method narrows down a module to a function or
/// set of functions, using the CBE as a ``safe'' code generator for other
@ -167,7 +167,7 @@ public:
/// generator (e.g., llc crashes), this will throw an exception.
///
std::string executeProgram(std::string RequestedOutputFilename = "",
std::string Bytecode = "",
std::string Bitcode = "",
const std::string &SharedObjects = "",
AbstractInterpreter *AI = 0,
bool *ProgramExitedNonzero = 0);
@ -191,14 +191,14 @@ public:
/// is different, true is returned. If there is a problem with the code
/// generator (e.g., llc crashes), this will throw an exception.
///
bool diffProgram(const std::string &BytecodeFile = "",
bool diffProgram(const std::string &BitcodeFile = "",
const std::string &SharedObj = "",
bool RemoveBytecode = false);
bool RemoveBitcode = false);
/// EmitProgressBytecode - This function is used to output the current Program
/// EmitProgressBitcode - This function is used to output the current Program
/// to a file named "bugpoint-ID.bc".
///
void EmitProgressBytecode(const std::string &ID, bool NoFlyer = false);
void EmitProgressBitcode(const std::string &ID, bool NoFlyer = false);
/// deleteInstructionFromProgram - This method clones the current Program and
/// deletes the specified instruction from the cloned module. It then runs a
@ -236,10 +236,10 @@ public:
Module *runPassesOn(Module *M, const std::vector<const PassInfo*> &Passes,
bool AutoDebugCrashes = false);
/// runPasses - Run the specified passes on Program, outputting a bytecode
/// runPasses - Run the specified passes on Program, outputting a bitcode
/// file and writting the filename into OutputFile if successful. If the
/// optimizations fail for some reason (optimizer crashes), return true,
/// otherwise return false. If DeleteOutput is set to true, the bytecode is
/// otherwise return false. If DeleteOutput is set to true, the bitcode is
/// deleted on success, and the filename string is undefined. This prints to
/// cout a single line message indicating whether compilation was successful
/// or failed, unless Quiet is set.
@ -258,7 +258,7 @@ public:
bool runManyPasses(const std::vector<const PassInfo*> &AllPasses);
/// writeProgramToFile - This writes the current "Program" to the named
/// bytecode file. If an error occurs, true is returned.
/// bitcode file. If an error occurs, true is returned.
///
bool writeProgramToFile(const std::string &Filename, Module *M = 0) const;
@ -282,7 +282,7 @@ private:
bool initializeExecutionEnvironment();
};
/// ParseInputFile - Given a bytecode or assembly input filename, parse and
/// ParseInputFile - Given a bitcode or assembly input filename, parse and
/// return it, or return null if not possible.
///
Module *ParseInputFile(const std::string &InputFilename);

View File

@ -70,7 +70,7 @@ ReducePassList::doTest(std::vector<const PassInfo*> &Prefix,
BD.Program = ParseInputFile(PrefixOutput.toString());
if (BD.Program == 0) {
std::cerr << BD.getToolName() << ": Error reading bytecode file '"
std::cerr << BD.getToolName() << ": Error reading bitcode file '"
<< PrefixOutput << "'!\n";
exit(1);
}
@ -396,7 +396,7 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
ReduceCrashingGlobalVariables(BD, TestFn).reduceList(GVs);
if (GVs.size() < OldSize)
BD.EmitProgressBytecode("reduced-global-variables");
BD.EmitProgressBitcode("reduced-global-variables");
}
}
}
@ -417,7 +417,7 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
ReduceCrashingFunctions(BD, TestFn).reduceList(Functions);
if (Functions.size() < OldSize)
BD.EmitProgressBytecode("reduced-function");
BD.EmitProgressBitcode("reduced-function");
}
// Attempt to delete entire basic blocks at a time to speed up
@ -508,7 +508,7 @@ ExitLoops:
}
}
BD.EmitProgressBytecode("reduced-simplified");
BD.EmitProgressBitcode("reduced-simplified");
return false;
}
@ -532,7 +532,7 @@ bool BugDriver::debugOptimizerCrash(const std::string &ID) {
<< (PassesToRun.size() == 1 ? ": " : "es: ")
<< getPassesString(PassesToRun) << '\n';
EmitProgressBytecode(ID);
EmitProgressBitcode(ID);
return DebugACrash(*this, TestForOptimizerCrash);
}

View File

@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
//
// This file contains code used to execute the program utilizing one of the
// various ways of running LLVM bytecode.
// various ways of running LLVM bitcode.
//
//===----------------------------------------------------------------------===//
@ -181,25 +181,25 @@ bool BugDriver::initializeExecutionEnvironment() {
/// generation crash testing.
///
void BugDriver::compileProgram(Module *M) {
// Emit the program to a bytecode file...
sys::Path BytecodeFile ("bugpoint-test-program.bc");
// Emit the program to a bitcode file...
sys::Path BitcodeFile ("bugpoint-test-program.bc");
std::string ErrMsg;
if (BytecodeFile.makeUnique(true,&ErrMsg)) {
if (BitcodeFile.makeUnique(true,&ErrMsg)) {
std::cerr << ToolName << ": Error making unique filename: " << ErrMsg
<< "\n";
exit(1);
}
if (writeProgramToFile(BytecodeFile.toString(), M)) {
std::cerr << ToolName << ": Error emitting bytecode to file '"
<< BytecodeFile << "'!\n";
if (writeProgramToFile(BitcodeFile.toString(), M)) {
std::cerr << ToolName << ": Error emitting bitcode to file '"
<< BitcodeFile << "'!\n";
exit(1);
}
// Remove the temporary bytecode file when we are done.
FileRemover BytecodeFileRemover(BytecodeFile);
// Remove the temporary bitcode file when we are done.
FileRemover BitcodeFileRemover(BitcodeFile);
// Actually compile the program!
Interpreter->compileProgram(BytecodeFile.toString());
Interpreter->compileProgram(BitcodeFile.toString());
}
@ -208,35 +208,35 @@ void BugDriver::compileProgram(Module *M) {
/// filename may be optionally specified.
///
std::string BugDriver::executeProgram(std::string OutputFile,
std::string BytecodeFile,
std::string BitcodeFile,
const std::string &SharedObj,
AbstractInterpreter *AI,
bool *ProgramExitedNonzero) {
if (AI == 0) AI = Interpreter;
assert(AI && "Interpreter should have been created already!");
bool CreatedBytecode = false;
bool CreatedBitcode = false;
std::string ErrMsg;
if (BytecodeFile.empty()) {
// Emit the program to a bytecode file...
if (BitcodeFile.empty()) {
// Emit the program to a bitcode file...
sys::Path uniqueFilename("bugpoint-test-program.bc");
if (uniqueFilename.makeUnique(true, &ErrMsg)) {
std::cerr << ToolName << ": Error making unique filename: "
<< ErrMsg << "!\n";
exit(1);
}
BytecodeFile = uniqueFilename.toString();
BitcodeFile = uniqueFilename.toString();
if (writeProgramToFile(BytecodeFile, Program)) {
std::cerr << ToolName << ": Error emitting bytecode to file '"
<< BytecodeFile << "'!\n";
if (writeProgramToFile(BitcodeFile, Program)) {
std::cerr << ToolName << ": Error emitting bitcode to file '"
<< BitcodeFile << "'!\n";
exit(1);
}
CreatedBytecode = true;
CreatedBitcode = true;
}
// Remove the temporary bytecode file when we are done.
sys::Path BytecodePath (BytecodeFile);
FileRemover BytecodeFileRemover(BytecodePath, CreatedBytecode);
// Remove the temporary bitcode file when we are done.
sys::Path BitcodePath (BitcodeFile);
FileRemover BitcodeFileRemover(BitcodePath, CreatedBitcode);
if (OutputFile.empty()) OutputFile = "bugpoint-execution-output";
@ -261,11 +261,11 @@ std::string BugDriver::executeProgram(std::string OutputFile,
int RetVal = 0;
if (InterpreterSel == RunLLC || InterpreterSel == RunCBE ||
InterpreterSel == CBE_bug || InterpreterSel == LLC_Safe)
RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile,
RetVal = AI->ExecuteProgram(BitcodeFile, InputArgv, InputFile,
OutputFile, AdditionalLinkerArgs, SharedObjs,
Timeout, MemoryLimit);
else
RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile,
RetVal = AI->ExecuteProgram(BitcodeFile, InputArgv, InputFile,
OutputFile, std::vector<std::string>(),
SharedObjs, Timeout, MemoryLimit);
@ -311,12 +311,12 @@ std::string BugDriver::executeProgramWithCBE(std::string OutputFile) {
return outFN;
}
std::string BugDriver::compileSharedObject(const std::string &BytecodeFile) {
std::string BugDriver::compileSharedObject(const std::string &BitcodeFile) {
assert(Interpreter && "Interpreter should have been created already!");
sys::Path OutputFile;
// Using CBE
GCC::FileType FT = cbe->OutputCode(BytecodeFile, OutputFile);
GCC::FileType FT = cbe->OutputCode(BitcodeFile, OutputFile);
std::string SharedObjectFile;
if (gcc->MakeSharedObject(OutputFile.toString(), FT,
@ -360,20 +360,20 @@ bool BugDriver::createReferenceFile(Module *M, const std::string &Filename) {
/// is different, true is returned. If there is a problem with the code
/// generator (e.g., llc crashes), this will throw an exception.
///
bool BugDriver::diffProgram(const std::string &BytecodeFile,
bool BugDriver::diffProgram(const std::string &BitcodeFile,
const std::string &SharedObject,
bool RemoveBytecode) {
bool RemoveBitcode) {
bool ProgramExitedNonzero;
// Execute the program, generating an output file...
sys::Path Output(executeProgram("", BytecodeFile, SharedObject, 0,
sys::Path Output(executeProgram("", BitcodeFile, SharedObject, 0,
&ProgramExitedNonzero));
// If we're checking the program exit code, assume anything nonzero is bad.
if (CheckProgramExitCode && ProgramExitedNonzero) {
Output.eraseFromDisk();
if (RemoveBytecode)
sys::Path(BytecodeFile).eraseFromDisk();
if (RemoveBitcode)
sys::Path(BitcodeFile).eraseFromDisk();
return true;
}
@ -392,9 +392,9 @@ bool BugDriver::diffProgram(const std::string &BytecodeFile,
// Remove the generated output.
Output.eraseFromDisk();
// Remove the bytecode file if we are supposed to.
if (RemoveBytecode)
sys::Path(BytecodeFile).eraseFromDisk();
// Remove the bitcode file if we are supposed to.
if (RemoveBitcode)
sys::Path(BitcodeFile).eraseFromDisk();
return FilesDifferent;
}

View File

@ -139,7 +139,7 @@ Module *BugDriver::ExtractLoop(Module *M) {
if (NewM == 0) {
Module *Old = swapProgramIn(M);
std::cout << "*** Loop extraction failed: ";
EmitProgressBytecode("loopextraction", true);
EmitProgressBitcode("loopextraction", true);
std::cout << "*** Sorry. :( Please report a bug!\n";
swapProgramIn(Old);
return 0;
@ -361,7 +361,7 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
if (Ret == 0) {
std::cout << "*** Basic Block extraction failed, please report a bug!\n";
M = swapProgramIn(M);
EmitProgressBytecode("basicblockextractfail", true);
EmitProgressBitcode("basicblockextractfail", true);
swapProgramIn(M);
}
return Ret;

View File

@ -59,17 +59,17 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
std::cout << "Checking to see if '" << getPassesString(Suffix)
<< "' compile correctly: ";
std::string BytecodeResult;
if (BD.runPasses(Suffix, BytecodeResult, false/*delete*/, true/*quiet*/)) {
std::string BitcodeResult;
if (BD.runPasses(Suffix, BitcodeResult, false/*delete*/, true/*quiet*/)) {
std::cerr << " Error running this sequence of passes"
<< " on the input program!\n";
BD.setPassesToRun(Suffix);
BD.EmitProgressBytecode("pass-error", false);
BD.EmitProgressBitcode("pass-error", false);
exit(BD.debugOptimizerCrash());
}
// Check to see if the finished program matches the reference output...
if (BD.diffProgram(BytecodeResult, "", true /*delete bytecode*/)) {
if (BD.diffProgram(BitcodeResult, "", true /*delete bitcode*/)) {
std::cout << " nope.\n";
if (Suffix.empty()) {
std::cerr << BD.getToolName() << ": I'm confused: the test fails when "
@ -90,21 +90,21 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
// If it is not broken with the kept passes, it's possible that the prefix
// passes must be run before the kept passes to break it. If the program
// WORKS after the prefix passes, but then fails if running the prefix AND
// kept passes, we can update our bytecode file to include the result of the
// kept passes, we can update our bitcode file to include the result of the
// prefix passes, then discard the prefix passes.
//
if (BD.runPasses(Prefix, BytecodeResult, false/*delete*/, true/*quiet*/)) {
if (BD.runPasses(Prefix, BitcodeResult, false/*delete*/, true/*quiet*/)) {
std::cerr << " Error running this sequence of passes"
<< " on the input program!\n";
BD.setPassesToRun(Prefix);
BD.EmitProgressBytecode("pass-error", false);
BD.EmitProgressBitcode("pass-error", false);
exit(BD.debugOptimizerCrash());
}
// If the prefix maintains the predicate by itself, only keep the prefix!
if (BD.diffProgram(BytecodeResult)) {
if (BD.diffProgram(BitcodeResult)) {
std::cout << " nope.\n";
sys::Path(BytecodeResult).eraseFromDisk();
sys::Path(BitcodeResult).eraseFromDisk();
return KeepPrefix;
}
std::cout << " yup.\n"; // No miscompilation!
@ -112,13 +112,13 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
// Ok, so now we know that the prefix passes work, try running the suffix
// passes on the result of the prefix passes.
//
Module *PrefixOutput = ParseInputFile(BytecodeResult);
Module *PrefixOutput = ParseInputFile(BitcodeResult);
if (PrefixOutput == 0) {
std::cerr << BD.getToolName() << ": Error reading bytecode file '"
<< BytecodeResult << "'!\n";
std::cerr << BD.getToolName() << ": Error reading bitcode file '"
<< BitcodeResult << "'!\n";
exit(1);
}
sys::Path(BytecodeResult).eraseFromDisk(); // No longer need the file on disk
sys::Path(BitcodeResult).eraseFromDisk(); // No longer need the file on disk
// Don't check if there are no passes in the suffix.
if (Suffix.empty())
@ -129,16 +129,16 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
<< getPassesString(Prefix) << "' passes: ";
Module *OriginalInput = BD.swapProgramIn(PrefixOutput);
if (BD.runPasses(Suffix, BytecodeResult, false/*delete*/, true/*quiet*/)) {
if (BD.runPasses(Suffix, BitcodeResult, false/*delete*/, true/*quiet*/)) {
std::cerr << " Error running this sequence of passes"
<< " on the input program!\n";
BD.setPassesToRun(Suffix);
BD.EmitProgressBytecode("pass-error", false);
BD.EmitProgressBitcode("pass-error", false);
exit(BD.debugOptimizerCrash());
}
// Run the result...
if (BD.diffProgram(BytecodeResult, "", true/*delete bytecode*/)) {
if (BD.diffProgram(BitcodeResult, "", true/*delete bitcode*/)) {
std::cout << " nope.\n";
delete OriginalInput; // We pruned down the original input...
return KeepSuffix;
@ -601,25 +601,25 @@ bool BugDriver::debugMiscompilation() {
std::cout << "\n*** Found miscompiling pass"
<< (getPassesToRun().size() == 1 ? "" : "es") << ": "
<< getPassesString(getPassesToRun()) << '\n';
EmitProgressBytecode("passinput");
EmitProgressBitcode("passinput");
std::vector<Function*> MiscompiledFunctions =
DebugAMiscompilation(*this, TestOptimizer);
// Output a bunch of bytecode files for the user...
std::cout << "Outputting reduced bytecode files which expose the problem:\n";
// Output a bunch of bitcode files for the user...
std::cout << "Outputting reduced bitcode files which expose the problem:\n";
Module *ToNotOptimize = CloneModule(getProgram());
Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize,
MiscompiledFunctions);
std::cout << " Non-optimized portion: ";
ToNotOptimize = swapProgramIn(ToNotOptimize);
EmitProgressBytecode("tonotoptimize", true);
EmitProgressBitcode("tonotoptimize", true);
setNewProgram(ToNotOptimize); // Delete hacked module.
std::cout << " Portion that is input to optimizer: ";
ToOptimize = swapProgramIn(ToOptimize);
EmitProgressBytecode("tooptimize");
EmitProgressBitcode("tooptimize");
setNewProgram(ToOptimize); // Delete hacked module.
return false;
@ -795,7 +795,7 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe) {
exit(1);
}
if (BD.writeProgramToFile(TestModuleBC.toString(), Test)) {
std::cerr << "Error writing bytecode to `" << TestModuleBC << "'\nExiting.";
std::cerr << "Error writing bitcode to `" << TestModuleBC << "'\nExiting.";
exit(1);
}
delete Test;
@ -809,7 +809,7 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe) {
}
if (BD.writeProgramToFile(SafeModuleBC.toString(), Safe)) {
std::cerr << "Error writing bytecode to `" << SafeModuleBC << "'\nExiting.";
std::cerr << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
exit(1);
}
std::string SharedObject = BD.compileSharedObject(SafeModuleBC.toString());
@ -865,7 +865,7 @@ bool BugDriver::debugCodeGenerator() {
}
if (writeProgramToFile(TestModuleBC.toString(), ToCodeGen)) {
std::cerr << "Error writing bytecode to `" << TestModuleBC << "'\nExiting.";
std::cerr << "Error writing bitcode to `" << TestModuleBC << "'\nExiting.";
exit(1);
}
delete ToCodeGen;
@ -879,7 +879,7 @@ bool BugDriver::debugCodeGenerator() {
}
if (writeProgramToFile(SafeModuleBC.toString(), ToNotCodeGen)) {
std::cerr << "Error writing bytecode to `" << SafeModuleBC << "'\nExiting.";
std::cerr << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
exit(1);
}
std::string SharedObject = compileSharedObject(SafeModuleBC.toString());

View File

@ -47,7 +47,7 @@ namespace {
cl::desc("Run optimizations through valgrind"));
}
/// writeProgramToFile - This writes the current "Program" to the named bytecode
/// writeProgramToFile - This writes the current "Program" to the named bitcode
/// file. If an error occurs, true is returned.
///
bool BugDriver::writeProgramToFile(const std::string &Filename,
@ -62,11 +62,11 @@ bool BugDriver::writeProgramToFile(const std::string &Filename,
}
/// EmitProgressBytecode - This function is used to output the current Program
/// EmitProgressBitcode - This function is used to output the current Program
/// to a file named "bugpoint-ID.bc".
///
void BugDriver::EmitProgressBytecode(const std::string &ID, bool NoFlyer) {
// Output the input to the current pass to a bytecode file, emit a message
void BugDriver::EmitProgressBitcode(const std::string &ID, bool NoFlyer) {
// Output the input to the current pass to a bitcode file, emit a message
// telling the user how to reproduce it: opt -foo blah.bc
//
std::string Filename = "bugpoint-" + ID + ".bc";
@ -75,7 +75,7 @@ void BugDriver::EmitProgressBytecode(const std::string &ID, bool NoFlyer) {
return;
}
cout << "Emitted bytecode to '" << Filename << "'\n";
cout << "Emitted bitcode to '" << Filename << "'\n";
if (NoFlyer || PassesToRun.empty()) return;
cout << "\n*** You can reproduce the problem with: ";
cout << "opt " << Filename << " ";
@ -88,7 +88,7 @@ int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) {
std::ios::binary;
std::ofstream OutFile(ChildOutput.c_str(), io_mode);
if (!OutFile.good()) {
cerr << "Error opening bytecode file: " << ChildOutput << "\n";
cerr << "Error opening bitcode file: " << ChildOutput << "\n";
return 1;
}
@ -105,7 +105,7 @@ int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) {
// Check that the module is well formed on completion of optimization
PM.add(createVerifierPass());
// Write bytecode out to disk as the last step...
// Write bitcode out to disk as the last step...
PM.add(CreateBitcodeWriterPass(OutFile));
// Run all queued passes.
@ -114,10 +114,10 @@ int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) {
return 0;
}
/// runPasses - Run the specified passes on Program, outputting a bytecode file
/// runPasses - Run the specified passes on Program, outputting a bitcode file
/// and writing the filename into OutputFile if successful. If the
/// optimizations fail for some reason (optimizer crashes), return true,
/// otherwise return false. If DeleteOutput is set to true, the bytecode is
/// otherwise return false. If DeleteOutput is set to true, the bitcode is
/// deleted on success, and the filename string is undefined. This prints to
/// cout a single line message indicating whether compilation was successful or
/// failed.
@ -147,7 +147,7 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
std::ios::binary;
std::ofstream InFile(inputFilename.c_str(), io_mode);
if (!InFile.good()) {
cerr << "Error opening bytecode file: " << inputFilename << "\n";
cerr << "Error opening bitcode file: " << inputFilename << "\n";
return(1);
}
WriteBitcodeToFile(Program, InFile);
@ -192,7 +192,7 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
int result = sys::Program::ExecuteAndWait(prog, args, 0, 0,
Timeout, MemoryLimit, &ErrMsg);
// If we are supposed to delete the bytecode file or if the passes crashed,
// If we are supposed to delete the bitcode file or if the passes crashed,
// remove it now. This may fail if the file was never created, but that's ok.
if (DeleteOutput || result != 0)
sys::Path(OutputFilename).eraseFromDisk();
@ -227,13 +227,13 @@ Module *BugDriver::runPassesOn(Module *M,
const std::vector<const PassInfo*> &Passes,
bool AutoDebugCrashes) {
Module *OldProgram = swapProgramIn(M);
std::string BytecodeResult;
if (runPasses(Passes, BytecodeResult, false/*delete*/, true/*quiet*/)) {
std::string BitcodeResult;
if (runPasses(Passes, BitcodeResult, false/*delete*/, true/*quiet*/)) {
if (AutoDebugCrashes) {
cerr << " Error running this sequence of passes"
<< " on the input program!\n";
delete OldProgram;
EmitProgressBytecode("pass-error", false);
EmitProgressBitcode("pass-error", false);
exit(debugOptimizerCrash());
}
swapProgramIn(OldProgram);
@ -243,12 +243,12 @@ Module *BugDriver::runPassesOn(Module *M,
// Restore the current program.
swapProgramIn(OldProgram);
Module *Ret = ParseInputFile(BytecodeResult);
Module *Ret = ParseInputFile(BitcodeResult);
if (Ret == 0) {
cerr << getToolName() << ": Error reading bytecode file '"
<< BytecodeResult << "'!\n";
cerr << getToolName() << ": Error reading bitcode file '"
<< BitcodeResult << "'!\n";
exit(1);
}
sys::Path(BytecodeResult).eraseFromDisk(); // No longer need the file on disk
sys::Path(BitcodeResult).eraseFromDisk(); // No longer need the file on disk
return Ret;
}

View File

@ -108,7 +108,7 @@ namespace {
if (Args) { ToolArgs = *Args; }
}
virtual int ExecuteProgram(const std::string &Bytecode,
virtual int ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
@ -120,7 +120,7 @@ namespace {
};
}
int LLI::ExecuteProgram(const std::string &Bytecode,
int LLI::ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
@ -143,7 +143,7 @@ int LLI::ExecuteProgram(const std::string &Bytecode,
for (unsigned i = 0, e = ToolArgs.size(); i != e; ++i)
LLIArgs.push_back(ToolArgs[i].c_str());
LLIArgs.push_back(Bytecode.c_str());
LLIArgs.push_back(Bitcode.c_str());
// Add optional parameters to the running program from Argv
for (unsigned i=0, e = Args.size(); i != e; ++i)
LLIArgs.push_back(Args[i].c_str());
@ -177,9 +177,9 @@ AbstractInterpreter *AbstractInterpreter::createLLI(const std::string &ProgPath,
//===----------------------------------------------------------------------===//
// LLC Implementation of AbstractIntepreter interface
//
GCC::FileType LLC::OutputCode(const std::string &Bytecode,
GCC::FileType LLC::OutputCode(const std::string &Bitcode,
sys::Path &OutputAsmFile) {
sys::Path uniqueFile(Bytecode+".llc.s");
sys::Path uniqueFile(Bitcode+".llc.s");
std::string ErrMsg;
if (uniqueFile.makeUnique(true, &ErrMsg)) {
std::cerr << "Error making unique filename: " << ErrMsg << "\n";
@ -196,7 +196,7 @@ GCC::FileType LLC::OutputCode(const std::string &Bytecode,
LLCArgs.push_back ("-o");
LLCArgs.push_back (OutputAsmFile.c_str()); // Output to the Asm file
LLCArgs.push_back ("-f"); // Overwrite as necessary...
LLCArgs.push_back (Bytecode.c_str()); // This is the input bytecode
LLCArgs.push_back (Bitcode.c_str()); // This is the input bitcode
LLCArgs.push_back (0);
std::cout << "<llc>" << std::flush;
@ -212,13 +212,13 @@ GCC::FileType LLC::OutputCode(const std::string &Bytecode,
return GCC::AsmFile;
}
void LLC::compileProgram(const std::string &Bytecode) {
void LLC::compileProgram(const std::string &Bitcode) {
sys::Path OutputAsmFile;
OutputCode(Bytecode, OutputAsmFile);
OutputCode(Bitcode, OutputAsmFile);
OutputAsmFile.eraseFromDisk();
}
int LLC::ExecuteProgram(const std::string &Bytecode,
int LLC::ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
@ -228,7 +228,7 @@ int LLC::ExecuteProgram(const std::string &Bytecode,
unsigned MemoryLimit) {
sys::Path OutputAsmFile;
OutputCode(Bytecode, OutputAsmFile);
OutputCode(Bitcode, OutputAsmFile);
FileRemover OutFileRemover(OutputAsmFile);
std::vector<std::string> GCCArgs(ArgsForGCC);
@ -274,7 +274,7 @@ namespace {
if (Args) { ToolArgs = *Args; }
}
virtual int ExecuteProgram(const std::string &Bytecode,
virtual int ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
@ -287,7 +287,7 @@ namespace {
};
}
int JIT::ExecuteProgram(const std::string &Bytecode,
int JIT::ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
@ -310,7 +310,7 @@ int JIT::ExecuteProgram(const std::string &Bytecode,
JITArgs.push_back("-load");
JITArgs.push_back(SharedLibs[i].c_str());
}
JITArgs.push_back(Bytecode.c_str());
JITArgs.push_back(Bitcode.c_str());
// Add optional parameters to the running program from Argv
for (unsigned i=0, e = Args.size(); i != e; ++i)
JITArgs.push_back(Args[i].c_str());
@ -342,9 +342,9 @@ AbstractInterpreter *AbstractInterpreter::createJIT(const std::string &ProgPath,
return 0;
}
GCC::FileType CBE::OutputCode(const std::string &Bytecode,
GCC::FileType CBE::OutputCode(const std::string &Bitcode,
sys::Path &OutputCFile) {
sys::Path uniqueFile(Bytecode+".cbe.c");
sys::Path uniqueFile(Bitcode+".cbe.c");
std::string ErrMsg;
if (uniqueFile.makeUnique(true, &ErrMsg)) {
std::cerr << "Error making unique filename: " << ErrMsg << "\n";
@ -362,7 +362,7 @@ GCC::FileType CBE::OutputCode(const std::string &Bytecode,
LLCArgs.push_back (OutputCFile.c_str()); // Output to the C file
LLCArgs.push_back ("-march=c"); // Output C language
LLCArgs.push_back ("-f"); // Overwrite as necessary...
LLCArgs.push_back (Bytecode.c_str()); // This is the input bytecode
LLCArgs.push_back (Bitcode.c_str()); // This is the input bitcode
LLCArgs.push_back (0);
std::cout << "<cbe>" << std::flush;
@ -377,13 +377,13 @@ GCC::FileType CBE::OutputCode(const std::string &Bytecode,
return GCC::CFile;
}
void CBE::compileProgram(const std::string &Bytecode) {
void CBE::compileProgram(const std::string &Bitcode) {
sys::Path OutputCFile;
OutputCode(Bytecode, OutputCFile);
OutputCode(Bitcode, OutputCFile);
OutputCFile.eraseFromDisk();
}
int CBE::ExecuteProgram(const std::string &Bytecode,
int CBE::ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
@ -392,7 +392,7 @@ int CBE::ExecuteProgram(const std::string &Bytecode,
unsigned Timeout,
unsigned MemoryLimit) {
sys::Path OutputCFile;
OutputCode(Bytecode, OutputCFile);
OutputCode(Bitcode, OutputCFile);
FileRemover CFileRemove(OutputCFile);

View File

@ -80,7 +80,7 @@ public:
//===---------------------------------------------------------------------===//
/// AbstractInterpreter Class - Subclasses of this class are used to execute
/// LLVM bytecode in a variety of ways. This abstract interface hides this
/// LLVM bitcode in a variety of ways. This abstract interface hides this
/// complexity behind a simple interface.
///
class AbstractInterpreter {
@ -101,25 +101,25 @@ public:
virtual ~AbstractInterpreter() {}
/// compileProgram - Compile the specified program from bytecode to executable
/// compileProgram - Compile the specified program from bitcode to executable
/// code. This does not produce any output, it is only used when debugging
/// the code generator. If the code generator fails, an exception should be
/// thrown, otherwise, this function will just return.
virtual void compileProgram(const std::string &Bytecode) {}
virtual void compileProgram(const std::string &Bitcode) {}
/// OutputCode - Compile the specified program from bytecode to code
/// OutputCode - Compile the specified program from bitcode to code
/// understood by the GCC driver (either C or asm). If the code generator
/// fails, an exception should be thrown, otherwise, this function returns the
/// type of code emitted.
virtual GCC::FileType OutputCode(const std::string &Bytecode,
virtual GCC::FileType OutputCode(const std::string &Bitcode,
sys::Path &OutFile) {
throw std::string("OutputCode not supported by this AbstractInterpreter!");
}
/// ExecuteProgram - Run the specified bytecode file, emitting output to the
/// ExecuteProgram - Run the specified bitcode file, emitting output to the
/// specified filename. This returns the exit code of the program.
///
virtual int ExecuteProgram(const std::string &Bytecode,
virtual int ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
@ -146,13 +146,13 @@ public:
}
~CBE() { delete gcc; }
/// compileProgram - Compile the specified program from bytecode to executable
/// compileProgram - Compile the specified program from bitcode to executable
/// code. This does not produce any output, it is only used when debugging
/// the code generator. If the code generator fails, an exception should be
/// thrown, otherwise, this function will just return.
virtual void compileProgram(const std::string &Bytecode);
virtual void compileProgram(const std::string &Bitcode);
virtual int ExecuteProgram(const std::string &Bytecode,
virtual int ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
@ -163,11 +163,11 @@ public:
unsigned Timeout = 0,
unsigned MemoryLimit = 0);
/// OutputCode - Compile the specified program from bytecode to code
/// OutputCode - Compile the specified program from bitcode to code
/// understood by the GCC driver (either C or asm). If the code generator
/// fails, an exception should be thrown, otherwise, this function returns the
/// type of code emitted.
virtual GCC::FileType OutputCode(const std::string &Bytecode,
virtual GCC::FileType OutputCode(const std::string &Bitcode,
sys::Path &OutFile);
};
@ -187,13 +187,13 @@ public:
}
~LLC() { delete gcc; }
/// compileProgram - Compile the specified program from bytecode to executable
/// compileProgram - Compile the specified program from bitcode to executable
/// code. This does not produce any output, it is only used when debugging
/// the code generator. If the code generator fails, an exception should be
/// thrown, otherwise, this function will just return.
virtual void compileProgram(const std::string &Bytecode);
virtual void compileProgram(const std::string &Bitcode);
virtual int ExecuteProgram(const std::string &Bytecode,
virtual int ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
@ -204,7 +204,7 @@ public:
unsigned Timeout = 0,
unsigned MemoryLimit = 0);
virtual GCC::FileType OutputCode(const std::string &Bytecode,
virtual GCC::FileType OutputCode(const std::string &Bitcode,
sys::Path &OutFile);
};

View File

@ -1,4 +1,4 @@
//===-- llvm-bcanalyzer.cpp - Byte Code Analyzer --------------------------===//
//===-- llvm-bcanalyzer.cpp - Bitcode Analyzer --------------------------===//
//
// The LLVM Compiler Infrastructure
//
@ -8,22 +8,22 @@
//===----------------------------------------------------------------------===//
//
// This tool may be invoked in the following manner:
// llvm-bcanalyzer [options] - Read LLVM bytecode from stdin
// llvm-bcanalyzer [options] x.bc - Read LLVM bytecode from the x.bc file
// llvm-bcanalyzer [options] - Read LLVM bitcode from stdin
// llvm-bcanalyzer [options] x.bc - Read LLVM bitcode from the x.bc file
//
// Options:
// --help - Output information about command line switches
// --dump - Dump low-level bytecode structure in readable format
// --dump - Dump low-level bitcode structure in readable format
//
// This tool provides analytical information about a bytecode file. It is
// intended as an aid to developers of bytecode reading and writing software. It
// produces on std::out a summary of the bytecode file that shows various
// This tool provides analytical information about a bitcode file. It is
// intended as an aid to developers of bitcode reading and writing software. It
// produces on std::out a summary of the bitcode file that shows various
// statistics about the contents of the file. By default this information is
// detailed and contains information about individual bytecode blocks and the
// detailed and contains information about individual bitcode blocks and the
// functions in the module.
// The tool is also able to print a bytecode file in a straight forward text
// The tool is also able to print a bitcode file in a straight forward text
// format that shows the containment and relationships of the information in
// the bytecode file (-dump option).
// the bitcode file (-dump option).
//
//===----------------------------------------------------------------------===//
@ -41,12 +41,12 @@
using namespace llvm;
static cl::opt<std::string>
InputFilename(cl::Positional, cl::desc("<input bytecode>"), cl::init("-"));
InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-"));
static cl::opt<std::string>
OutputFilename("-o", cl::init("-"), cl::desc("<output file>"));
static cl::opt<bool> Dump("dump", cl::desc("Dump low level bytecode trace"));
static cl::opt<bool> Dump("dump", cl::desc("Dump low level bitcode trace"));
//===----------------------------------------------------------------------===//
// Bitcode specific analysis.