[llvm-commits] [llvm] r109951 - in /llvm/trunk/tools/bugpoint: BugDriver.h ExecutionDriver.cpp Miscompilation.cpp
Rafael Espindola
rafael.espindola at gmail.com
Sat Jul 31 07:34:49 PDT 2010
Author: rafael
Date: Sat Jul 31 09:34:49 2010
New Revision: 109951
URL: http://llvm.org/viewvc/llvm-project?rev=109951&view=rev
Log:
Add const to some methods and change TestMergedProgram to return the merged
module and take a const BugDriver.
Modified:
llvm/trunk/tools/bugpoint/BugDriver.h
llvm/trunk/tools/bugpoint/ExecutionDriver.cpp
llvm/trunk/tools/bugpoint/Miscompilation.cpp
Modified: llvm/trunk/tools/bugpoint/BugDriver.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/BugDriver.h?rev=109951&r1=109950&r2=109951&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/BugDriver.h (original)
+++ llvm/trunk/tools/bugpoint/BugDriver.h Sat Jul 31 09:34:49 2010
@@ -179,7 +179,7 @@
std::string Bitcode,
const std::string &SharedObjects,
AbstractInterpreter *AI,
- std::string *Error);
+ std::string *Error) const;
/// executeProgramSafely - Used to create reference output with the "safe"
/// backend, if reference output is not provided. If there is a problem with
@@ -187,7 +187,8 @@
/// Error.
///
std::string executeProgramSafely(const Module *Program,
- std::string OutputFile, std::string *Error);
+ std::string OutputFile,
+ std::string *Error) const;
/// createReferenceFile - calls compileProgram and then records the output
/// into ReferenceOutputFile. Returns true if reference file created, false
@@ -206,7 +207,7 @@
const std::string &BitcodeFile = "",
const std::string &SharedObj = "",
bool RemoveBitcode = false,
- std::string *Error = 0);
+ std::string *Error = 0) const;
/// EmitProgressBitcode - This function is used to output M to a file named
/// "bugpoint-ID.bc".
Modified: llvm/trunk/tools/bugpoint/ExecutionDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExecutionDriver.cpp?rev=109951&r1=109950&r2=109951&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/ExecutionDriver.cpp (original)
+++ llvm/trunk/tools/bugpoint/ExecutionDriver.cpp Sat Jul 31 09:34:49 2010
@@ -325,7 +325,7 @@
std::string BitcodeFile,
const std::string &SharedObj,
AbstractInterpreter *AI,
- std::string *Error) {
+ std::string *Error) const {
if (AI == 0) AI = Interpreter;
assert(AI && "Interpreter should have been created already!");
bool CreatedBitcode = false;
@@ -402,7 +402,7 @@
///
std::string BugDriver::executeProgramSafely(const Module *Program,
std::string OutputFile,
- std::string *Error) {
+ std::string *Error) const {
return executeProgram(Program, OutputFile, "", "", SafeInterpreter, Error);
}
@@ -466,7 +466,7 @@
const std::string &BitcodeFile,
const std::string &SharedObject,
bool RemoveBitcode,
- std::string *ErrMsg) {
+ std::string *ErrMsg) const {
// Execute the program, generating an output file...
sys::Path Output(executeProgram(Program, "", BitcodeFile, SharedObject, 0,
ErrMsg));
Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/Miscompilation.cpp?rev=109951&r1=109950&r2=109951&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original)
+++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Sat Jul 31 09:34:49 2010
@@ -204,13 +204,15 @@
}
/// TestMergedProgram - Given two modules, link them together and run the
-/// program, checking to see if the program matches the diff. If the diff
-/// matches, return false, otherwise return true. If the DeleteInputs argument
-/// is set to true then this function deletes both input modules before it
-/// returns.
-///
-static bool TestMergedProgram(BugDriver &BD, Module *M1, Module *M2,
- bool DeleteInputs, std::string &Error) {
+/// program, checking to see if the program matches the diff. If there is
+/// an error, return NULL. If not, return the merged module. The Broken argument
+/// will be set to true if the output is different. If the DeleteInputs
+/// argument is set to true then this function deletes both input
+/// modules before it returns.
+///
+static Module *TestMergedProgram(const BugDriver &BD, Module *M1, Module *M2,
+ bool DeleteInputs, std::string &Error,
+ bool &Broken) {
// Link the two portions of the program back to together.
std::string ErrorMsg;
if (!DeleteInputs) {
@@ -224,16 +226,14 @@
}
delete M2; // We are done with this module.
- // Execute the program. If it does not match the expected output, we must
- // return true.
- bool Broken = BD.diffProgram(M1, "", "", false, &Error);
+ // Execute the program.
+ Broken = BD.diffProgram(M1, "", "", false, &Error);
if (!Error.empty()) {
// Delete the linked module
delete M1;
+ return NULL;
}
- // Delete the original and set the new program.
- delete BD.swapProgramIn(M1);
- return Broken;
+ return M1;
}
/// TestFuncs - split functions in a Module into two groups: those that are
@@ -329,10 +329,13 @@
// has broken. If something broke, then we'll inform the user and stop
// extraction.
AbstractInterpreter *AI = BD.switchToSafeInterpreter();
- bool Failure = TestMergedProgram(BD, ToOptimizeLoopExtracted, ToNotOptimize,
- false, Error);
- if (!Error.empty())
+ bool Failure;
+ Module *New = TestMergedProgram(BD, ToOptimizeLoopExtracted, ToNotOptimize,
+ false, Error, Failure);
+ if (!New)
return false;
+ // Delete the original and set the new program.
+ delete BD.swapProgramIn(New);
if (Failure) {
BD.switchToInterpreter(AI);
@@ -695,8 +698,13 @@
delete Test;
outs() << " Checking to see if the merged program executes correctly: ";
- bool Broken = TestMergedProgram(BD, Optimized, Safe, true, Error);
- if (Error.empty()) outs() << (Broken ? " nope.\n" : " yup.\n");
+ bool Broken;
+ Module *New = TestMergedProgram(BD, Optimized, Safe, true, Error, Broken);
+ if (New) {
+ outs() << (Broken ? " nope.\n" : " yup.\n");
+ // Delete the original and set the new program.
+ delete BD.swapProgramIn(New);
+ }
return Broken;
}
More information about the llvm-commits
mailing list