Refactor and clean up a bunch more code. No major functionality changes.
* Make several methods of bugdriver global functions (ParseInputFile, PrintFunctionList)
* Make PrintFunctionList truncate the output after 10 entries, like the crash debugger
did. This allows code sharing.
* Add a couple of methods to BugDriver that allows us to eliminate some friends
* Improve comments in ExtractFunction.cpp
* Make classes that used to be friends up bugdriver now live in anon namespaces
* Rip a bunch of functionality in the miscompilation tester into a new
TestMergedProgram function for future code sharing.
* Fix a bug in the miscompilation tester induced in my last checkin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12393 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index 04f494a..2be8cd0 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -59,7 +59,7 @@
OrigProgram = BD.Program;
- BD.Program = BD.ParseInputFile(PrefixOutput);
+ BD.Program = ParseInputFile(PrefixOutput);
if (BD.Program == 0) {
std::cerr << BD.getToolName() << ": Error reading bytecode file '"
<< PrefixOutput << "'!\n";
@@ -85,7 +85,7 @@
}
namespace llvm {
- class ReduceCrashingFunctions : public ListReducer<const Function*> {
+ class ReduceCrashingFunctions : public ListReducer<Function*> {
BugDriver &BD;
bool (*TestFn)(BugDriver &, Module *);
public:
@@ -93,8 +93,8 @@
bool (*testFn)(BugDriver &, Module *))
: BD(bd), TestFn(testFn) {}
- virtual TestResult doTest(std::vector<const Function*> &Prefix,
- std::vector<const Function*> &Kept) {
+ virtual TestResult doTest(std::vector<Function*> &Prefix,
+ std::vector<Function*> &Kept) {
if (!Kept.empty() && TestFuncs(Kept))
return KeepSuffix;
if (!Prefix.empty() && TestFuncs(Prefix))
@@ -102,11 +102,11 @@
return NoFailure;
}
- bool TestFuncs(std::vector<const Function*> &Prefix);
+ bool TestFuncs(std::vector<Function*> &Prefix);
};
}
-bool ReduceCrashingFunctions::TestFuncs(std::vector<const Function*> &Funcs) {
+bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) {
// Clone the program to try hacking it apart...
Module *M = CloneModule(BD.getProgram());
@@ -119,13 +119,8 @@
Functions.insert(CMF);
}
- std::cout << "Checking for crash with only these functions:";
- unsigned NumPrint = Funcs.size();
- if (NumPrint > 10) NumPrint = 10;
- for (unsigned i = 0; i != NumPrint; ++i)
- std::cout << " " << Funcs[i]->getName();
- if (NumPrint < Funcs.size())
- std::cout << "... <" << Funcs.size() << " total>";
+ std::cout << "Checking for crash with only these functions: ";
+ PrintFunctionList(Funcs);
std::cout << ": ";
// Loop over and delete any functions which we aren't supposed to be playing
@@ -295,8 +290,8 @@
}
// Now try to reduce the number of functions in the module to something small.
- std::vector<const Function*> Functions;
- for (Module::const_iterator I = BD.getProgram()->begin(),
+ std::vector<Function*> Functions;
+ for (Module::iterator I = BD.getProgram()->begin(),
E = BD.getProgram()->end(); I != E; ++I)
if (!I->isExternal())
Functions.push_back(I);