mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
For PR351:
* removeFile() -> sys::Path::destroyFile() * remove extraneous toString() calls * convert local variables representing path names from std::string to sys::Path * Use sys::Path objects with FileRemove instead of std::string * Use sys::Path methods for construction of path names llvm-svn: 19001
This commit is contained in:
parent
df60327fbe
commit
e2af7fb67b
@ -175,7 +175,7 @@ bool BugDriver::run() {
|
|||||||
|
|
||||||
// Make sure the reference output file gets deleted on exit from this
|
// Make sure the reference output file gets deleted on exit from this
|
||||||
// function, if appropriate.
|
// function, if appropriate.
|
||||||
FileRemover RemoverInstance(ReferenceOutputFile, CreatedOutput);
|
FileRemover RemoverInstance(sys::Path(ReferenceOutputFile), CreatedOutput);
|
||||||
|
|
||||||
// Diff the output of the raw program against the reference output. If it
|
// Diff the output of the raw program against the reference output. If it
|
||||||
// matches, then we have a miscompilation bug.
|
// matches, then we have a miscompilation bug.
|
||||||
|
@ -49,23 +49,25 @@ namespace llvm {
|
|||||||
ReducePassList::TestResult
|
ReducePassList::TestResult
|
||||||
ReducePassList::doTest(std::vector<const PassInfo*> &Prefix,
|
ReducePassList::doTest(std::vector<const PassInfo*> &Prefix,
|
||||||
std::vector<const PassInfo*> &Suffix) {
|
std::vector<const PassInfo*> &Suffix) {
|
||||||
std::string PrefixOutput;
|
sys::Path PrefixOutput;
|
||||||
Module *OrigProgram = 0;
|
Module *OrigProgram = 0;
|
||||||
if (!Prefix.empty()) {
|
if (!Prefix.empty()) {
|
||||||
std::cout << "Checking to see if these passes crash: "
|
std::cout << "Checking to see if these passes crash: "
|
||||||
<< getPassesString(Prefix) << ": ";
|
<< getPassesString(Prefix) << ": ";
|
||||||
if (BD.runPasses(Prefix, PrefixOutput))
|
std::string PfxOutput;
|
||||||
|
if (BD.runPasses(Prefix, PfxOutput))
|
||||||
return KeepPrefix;
|
return KeepPrefix;
|
||||||
|
|
||||||
|
PrefixOutput.setFile(PfxOutput);
|
||||||
OrigProgram = BD.Program;
|
OrigProgram = BD.Program;
|
||||||
|
|
||||||
BD.Program = ParseInputFile(PrefixOutput);
|
BD.Program = ParseInputFile(PrefixOutput.toString());
|
||||||
if (BD.Program == 0) {
|
if (BD.Program == 0) {
|
||||||
std::cerr << BD.getToolName() << ": Error reading bytecode file '"
|
std::cerr << BD.getToolName() << ": Error reading bytecode file '"
|
||||||
<< PrefixOutput << "'!\n";
|
<< PrefixOutput << "'!\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
removeFile(PrefixOutput);
|
PrefixOutput.destroyFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Checking to see if these passes crash: "
|
std::cout << "Checking to see if these passes crash: "
|
||||||
|
@ -161,7 +161,7 @@ void BugDriver::compileProgram(Module *M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove the temporary bytecode file when we are done.
|
// Remove the temporary bytecode file when we are done.
|
||||||
FileRemover BytecodeFileRemover(BytecodeFile.toString());
|
FileRemover BytecodeFileRemover(BytecodeFile);
|
||||||
|
|
||||||
// Actually compile the program!
|
// Actually compile the program!
|
||||||
Interpreter->compileProgram(BytecodeFile.toString());
|
Interpreter->compileProgram(BytecodeFile.toString());
|
||||||
@ -195,7 +195,7 @@ std::string BugDriver::executeProgram(std::string OutputFile,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove the temporary bytecode file when we are done.
|
// Remove the temporary bytecode file when we are done.
|
||||||
FileRemover BytecodeFileRemover(BytecodeFile, CreatedBytecode);
|
FileRemover BytecodeFileRemover(sys::Path(BytecodeFile), CreatedBytecode);
|
||||||
|
|
||||||
if (OutputFile.empty()) OutputFile = "bugpoint-execution-output";
|
if (OutputFile.empty()) OutputFile = "bugpoint-execution-output";
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ std::string BugDriver::executeProgramWithCBE(std::string OutputFile) {
|
|||||||
|
|
||||||
std::string BugDriver::compileSharedObject(const std::string &BytecodeFile) {
|
std::string BugDriver::compileSharedObject(const std::string &BytecodeFile) {
|
||||||
assert(Interpreter && "Interpreter should have been created already!");
|
assert(Interpreter && "Interpreter should have been created already!");
|
||||||
std::string OutputCFile;
|
sys::Path OutputCFile;
|
||||||
|
|
||||||
// Using CBE
|
// Using CBE
|
||||||
cbe->OutputC(BytecodeFile, OutputCFile);
|
cbe->OutputC(BytecodeFile, OutputCFile);
|
||||||
@ -268,11 +268,12 @@ std::string BugDriver::compileSharedObject(const std::string &BytecodeFile) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string SharedObjectFile;
|
std::string SharedObjectFile;
|
||||||
if (gcc->MakeSharedObject(OutputCFile, GCC::CFile, SharedObjectFile))
|
if (gcc->MakeSharedObject(OutputCFile.toString(), GCC::CFile,
|
||||||
|
SharedObjectFile))
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
// Remove the intermediate C file
|
// Remove the intermediate C file
|
||||||
removeFile(OutputCFile);
|
OutputCFile.destroyFile();
|
||||||
|
|
||||||
return "./" + SharedObjectFile;
|
return "./" + SharedObjectFile;
|
||||||
}
|
}
|
||||||
@ -288,19 +289,20 @@ bool BugDriver::diffProgram(const std::string &BytecodeFile,
|
|||||||
bool ProgramExitedNonzero;
|
bool ProgramExitedNonzero;
|
||||||
|
|
||||||
// Execute the program, generating an output file...
|
// Execute the program, generating an output file...
|
||||||
std::string Output = executeProgram("", BytecodeFile, SharedObject, 0,
|
sys::Path Output (executeProgram("", BytecodeFile, SharedObject, 0,
|
||||||
&ProgramExitedNonzero);
|
&ProgramExitedNonzero));
|
||||||
|
|
||||||
// If we're checking the program exit code, assume anything nonzero is bad.
|
// If we're checking the program exit code, assume anything nonzero is bad.
|
||||||
if (CheckProgramExitCode && ProgramExitedNonzero) {
|
if (CheckProgramExitCode && ProgramExitedNonzero) {
|
||||||
removeFile(Output);
|
Output.destroyFile();
|
||||||
if (RemoveBytecode) removeFile(BytecodeFile);
|
if (RemoveBytecode)
|
||||||
|
sys::Path(BytecodeFile).destroyFile();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Error;
|
std::string Error;
|
||||||
bool FilesDifferent = false;
|
bool FilesDifferent = false;
|
||||||
if (DiffFiles(ReferenceOutputFile, Output, &Error)) {
|
if (DiffFiles(ReferenceOutputFile, Output.toString(), &Error)) {
|
||||||
if (!Error.empty()) {
|
if (!Error.empty()) {
|
||||||
std::cerr << "While diffing output: " << Error << '\n';
|
std::cerr << "While diffing output: " << Error << '\n';
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -309,10 +311,10 @@ bool BugDriver::diffProgram(const std::string &BytecodeFile,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove the generated output.
|
// Remove the generated output.
|
||||||
removeFile(Output);
|
Output.destroyFile();
|
||||||
|
|
||||||
// Remove the bytecode file if we are supposed to.
|
// Remove the bytecode file if we are supposed to.
|
||||||
if (RemoveBytecode) removeFile(BytecodeFile);
|
if (RemoveBytecode) sys::Path(BytecodeFile).destroyFile();
|
||||||
return FilesDifferent;
|
return FilesDifferent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
|
|||||||
// If the prefix maintains the predicate by itself, only keep the prefix!
|
// If the prefix maintains the predicate by itself, only keep the prefix!
|
||||||
if (BD.diffProgram(BytecodeResult)) {
|
if (BD.diffProgram(BytecodeResult)) {
|
||||||
std::cout << " nope.\n";
|
std::cout << " nope.\n";
|
||||||
removeFile(BytecodeResult);
|
sys::Path(BytecodeResult).destroyFile();
|
||||||
return KeepPrefix;
|
return KeepPrefix;
|
||||||
}
|
}
|
||||||
std::cout << " yup.\n"; // No miscompilation!
|
std::cout << " yup.\n"; // No miscompilation!
|
||||||
@ -107,7 +107,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
|
|||||||
<< BytecodeResult << "'!\n";
|
<< BytecodeResult << "'!\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
removeFile(BytecodeResult); // No longer need the file on disk
|
sys::Path(BytecodeResult).destroyFile(); // No longer need the file on disk
|
||||||
|
|
||||||
// Don't check if there are no passes in the suffix.
|
// Don't check if there are no passes in the suffix.
|
||||||
if (Suffix.empty())
|
if (Suffix.empty())
|
||||||
@ -760,9 +760,9 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe) {
|
|||||||
std::cerr << ": still failing!\n";
|
std::cerr << ": still failing!\n";
|
||||||
else
|
else
|
||||||
std::cerr << ": didn't fail.\n";
|
std::cerr << ": didn't fail.\n";
|
||||||
removeFile(TestModuleBC.toString());
|
TestModuleBC.destroyFile();
|
||||||
removeFile(SafeModuleBC.toString());
|
SafeModuleBC.destroyFile();
|
||||||
removeFile(SharedObject);
|
sys::Path(SharedObject).destroyFile();
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
|
|||||||
// If we are supposed to delete the bytecode file or if the passes crashed,
|
// If we are supposed to delete the bytecode file or if the passes crashed,
|
||||||
// remove it now. This may fail if the file was never created, but that's ok.
|
// remove it now. This may fail if the file was never created, but that's ok.
|
||||||
if (DeleteOutput || !ExitedOK)
|
if (DeleteOutput || !ExitedOK)
|
||||||
removeFile(OutputFilename);
|
sys::Path(OutputFilename).destroyFile();
|
||||||
|
|
||||||
if (!Quiet) {
|
if (!Quiet) {
|
||||||
if (ExitedOK)
|
if (ExitedOK)
|
||||||
@ -194,6 +194,6 @@ Module *BugDriver::runPassesOn(Module *M,
|
|||||||
<< BytecodeResult << "'!\n";
|
<< BytecodeResult << "'!\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
removeFile(BytecodeResult); // No longer need the file on disk
|
sys::Path(BytecodeResult).destroyFile(); // No longer need the file on disk
|
||||||
return Ret;
|
return Ret;
|
||||||
}
|
}
|
||||||
|
@ -276,10 +276,11 @@ int main(int argc, char **argv, char **envp ) {
|
|||||||
// Otherwise, create a script that will run the bytecode through the JIT.
|
// Otherwise, create a script that will run the bytecode through the JIT.
|
||||||
if (Native) {
|
if (Native) {
|
||||||
// Name of the Assembly Language output file
|
// Name of the Assembly Language output file
|
||||||
std::string AssemblyFile = OutputFilename + ".s";
|
sys::Path AssemblyFile ( OutputFilename);
|
||||||
|
AssemblyFile.appendSuffix("s");
|
||||||
|
|
||||||
// Mark the output files for removal if we get an interrupt.
|
// Mark the output files for removal if we get an interrupt.
|
||||||
sys::RemoveFileOnSignal(sys::Path(AssemblyFile));
|
sys::RemoveFileOnSignal(AssemblyFile);
|
||||||
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
|
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
|
||||||
|
|
||||||
// Determine the locations of the llc and gcc programs.
|
// Determine the locations of the llc and gcc programs.
|
||||||
@ -293,17 +294,19 @@ int main(int argc, char **argv, char **envp ) {
|
|||||||
|
|
||||||
// Generate an assembly language file for the bytecode.
|
// Generate an assembly language file for the bytecode.
|
||||||
if (Verbose) std::cout << "Generating Assembly Code\n";
|
if (Verbose) std::cout << "Generating Assembly Code\n";
|
||||||
GenerateAssembly(AssemblyFile, RealBytecodeOutput, llc);
|
GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc);
|
||||||
if (Verbose) std::cout << "Generating Native Code\n";
|
if (Verbose) std::cout << "Generating Native Code\n";
|
||||||
GenerateNative(OutputFilename, AssemblyFile, Libraries, gcc, envp );
|
GenerateNative(OutputFilename, AssemblyFile.toString(),
|
||||||
|
Libraries, gcc, envp );
|
||||||
|
|
||||||
// Remove the assembly language file.
|
// Remove the assembly language file.
|
||||||
removeFile (AssemblyFile);
|
AssemblyFile.destroyFile();;
|
||||||
} else if (NativeCBE) {
|
} else if (NativeCBE) {
|
||||||
std::string CFile = OutputFilename + ".cbe.c";
|
sys::Path CFile (OutputFilename);
|
||||||
|
CFile.appendSuffix("cbe.c");
|
||||||
|
|
||||||
// Mark the output files for removal if we get an interrupt.
|
// Mark the output files for removal if we get an interrupt.
|
||||||
sys::RemoveFileOnSignal(sys::Path(CFile));
|
sys::RemoveFileOnSignal(CFile);
|
||||||
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
|
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
|
||||||
|
|
||||||
// Determine the locations of the llc and gcc programs.
|
// Determine the locations of the llc and gcc programs.
|
||||||
@ -317,12 +320,12 @@ int main(int argc, char **argv, char **envp ) {
|
|||||||
|
|
||||||
// Generate an assembly language file for the bytecode.
|
// Generate an assembly language file for the bytecode.
|
||||||
if (Verbose) std::cout << "Generating Assembly Code\n";
|
if (Verbose) std::cout << "Generating Assembly Code\n";
|
||||||
GenerateCFile(CFile, RealBytecodeOutput, llc);
|
GenerateCFile(CFile.toString(), RealBytecodeOutput, llc);
|
||||||
if (Verbose) std::cout << "Generating Native Code\n";
|
if (Verbose) std::cout << "Generating Native Code\n";
|
||||||
GenerateNative(OutputFilename, CFile, Libraries, gcc, envp );
|
GenerateNative(OutputFilename, CFile.toString(), Libraries, gcc, envp );
|
||||||
|
|
||||||
// Remove the assembly language file.
|
// Remove the assembly language file.
|
||||||
removeFile(CFile);
|
CFile.destroyFile();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
EmitShellScript(argv);
|
EmitShellScript(argv);
|
||||||
|
@ -448,10 +448,11 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
// Otherwise, create a script that will run the bytecode through the JIT.
|
// Otherwise, create a script that will run the bytecode through the JIT.
|
||||||
if (Native) {
|
if (Native) {
|
||||||
// Name of the Assembly Language output file
|
// Name of the Assembly Language output file
|
||||||
std::string AssemblyFile = OutputFilename + ".s";
|
sys::Path AssemblyFile ( OutputFilename);
|
||||||
|
AssemblyFile.appendSuffix("s");
|
||||||
|
|
||||||
// Mark the output files for removal if we get an interrupt.
|
// Mark the output files for removal if we get an interrupt.
|
||||||
sys::RemoveFileOnSignal(sys::Path(AssemblyFile));
|
sys::RemoveFileOnSignal(AssemblyFile);
|
||||||
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
|
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
|
||||||
|
|
||||||
// Determine the locations of the llc and gcc programs.
|
// Determine the locations of the llc and gcc programs.
|
||||||
@ -465,17 +466,19 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
|
|
||||||
// Generate an assembly language file for the bytecode.
|
// Generate an assembly language file for the bytecode.
|
||||||
if (Verbose) std::cout << "Generating Assembly Code\n";
|
if (Verbose) std::cout << "Generating Assembly Code\n";
|
||||||
GenerateAssembly(AssemblyFile, RealBytecodeOutput, llc);
|
GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc);
|
||||||
if (Verbose) std::cout << "Generating Native Code\n";
|
if (Verbose) std::cout << "Generating Native Code\n";
|
||||||
GenerateNative(OutputFilename, AssemblyFile, Libraries, gcc, envp);
|
GenerateNative(OutputFilename, AssemblyFile.toString(), Libraries,
|
||||||
|
gcc, envp);
|
||||||
|
|
||||||
// Remove the assembly language file.
|
// Remove the assembly language file.
|
||||||
removeFile (AssemblyFile);
|
AssemblyFile.destroyFile();
|
||||||
} else if (NativeCBE) {
|
} else if (NativeCBE) {
|
||||||
std::string CFile = OutputFilename + ".cbe.c";
|
sys::Path CFile (OutputFilename);
|
||||||
|
CFile.appendSuffix("cbe.c");
|
||||||
|
|
||||||
// Mark the output files for removal if we get an interrupt.
|
// Mark the output files for removal if we get an interrupt.
|
||||||
sys::RemoveFileOnSignal(sys::Path(CFile));
|
sys::RemoveFileOnSignal(CFile);
|
||||||
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
|
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
|
||||||
|
|
||||||
// Determine the locations of the llc and gcc programs.
|
// Determine the locations of the llc and gcc programs.
|
||||||
@ -489,12 +492,12 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
|
|
||||||
// Generate an assembly language file for the bytecode.
|
// Generate an assembly language file for the bytecode.
|
||||||
if (Verbose) std::cout << "Generating Assembly Code\n";
|
if (Verbose) std::cout << "Generating Assembly Code\n";
|
||||||
GenerateCFile(CFile, RealBytecodeOutput, llc);
|
GenerateCFile(CFile.toString(), RealBytecodeOutput, llc);
|
||||||
if (Verbose) std::cout << "Generating Native Code\n";
|
if (Verbose) std::cout << "Generating Native Code\n";
|
||||||
GenerateNative(OutputFilename, CFile, Libraries, gcc, envp);
|
GenerateNative(OutputFilename, CFile.toString(), Libraries, gcc, envp);
|
||||||
|
|
||||||
// Remove the assembly language file.
|
// Remove the assembly language file.
|
||||||
removeFile(CFile);
|
CFile.destroyFile();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
EmitShellScript(argv);
|
EmitShellScript(argv);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user