diff options
author | Chris Lattner <sabre@nondot.org> | 2004-03-14 20:50:42 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-03-14 20:50:42 +0000 |
commit | efdc0b505712d1ca4460def27e51c430f033d58d (patch) | |
tree | cf9c16dc624f0c78d238bad288dd5b2e83515245 /tools/bugpoint/CrashDebugger.cpp | |
parent | a1a7148c4de22a2cedc76b97ef80569b36698342 (diff) |
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
Diffstat (limited to 'tools/bugpoint/CrashDebugger.cpp')
-rw-r--r-- | tools/bugpoint/CrashDebugger.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp index 04f494a0b6..2be8cd0244 100644 --- a/tools/bugpoint/CrashDebugger.cpp +++ b/tools/bugpoint/CrashDebugger.cpp @@ -59,7 +59,7 @@ ReducePassList::doTest(std::vector<const PassInfo*> &Prefix, 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 @@ ReducePassList::doTest(std::vector<const PassInfo*> &Prefix, } namespace llvm { - class ReduceCrashingFunctions : public ListReducer<const Function*> { + class ReduceCrashingFunctions : public ListReducer<Function*> { BugDriver &BD; bool (*TestFn)(BugDriver &, Module *); public: @@ -93,8 +93,8 @@ namespace llvm { 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 @@ namespace llvm { 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 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<const Function*> &Funcs) { 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 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) { } // 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); |