X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fbugpoint%2FFindBugs.cpp;h=e42cce47ba0206652193f4627482461e2b78c7c6;hb=befc9c16fae1719cafe9f54ab2b67219db44dc11;hp=385a35746f6cdb75b290d5971b0457ec06f526bc;hpb=032091d7f62774443c282915964189ea3d8930de;p=oota-llvm.git diff --git a/tools/bugpoint/FindBugs.cpp b/tools/bugpoint/FindBugs.cpp index 385a35746f6..e42cce47ba0 100644 --- a/tools/bugpoint/FindBugs.cpp +++ b/tools/bugpoint/FindBugs.cpp @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by Patrick Jenkins and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -13,13 +13,13 @@ // we can hopefully spot bugs in the optimizations. // //===----------------------------------------------------------------------===// + #include "BugDriver.h" #include "ToolRunner.h" - -#include "llvm/Bytecode/WriteBytecodePass.h" - +#include "llvm/Pass.h" #include #include +#include using namespace llvm; /// runManyPasses - Take the specified pass list and create different @@ -29,51 +29,47 @@ using namespace llvm; /// If the passes did not compile correctly, output the command required to /// recreate the failure. This returns true if a compiler error is found. /// -bool BugDriver::runManyPasses(const std::vector &AllPasses) -{ - std::string Filename; - std::vector TempPass(AllPasses); +bool BugDriver::runManyPasses(const std::vector &AllPasses) { + setPassesToRun(AllPasses); std::cout << "Starting bug finding procedure...\n\n"; // Creating a reference output if necessary if (initializeExecutionEnvironment()) return false; + std::cout << "\n"; if (ReferenceOutputFile.empty()) { - std::cout << "Generating reference output from raw program: \n"; - if(!createReferenceFile(Program)){ - return false; - } + std::cout << "Generating reference output from raw program: \n"; + if (!createReferenceFile(Program)) + return false; } srand(time(NULL)); - std::vector::iterator I = TempPass.begin(); - std::vector::iterator E = TempPass.end(); - - int num=1; - while(1){ + + unsigned num = 1; + while(1) { // // Step 1: Randomize the order of the optimizer passes. // - std::random_shuffle(TempPass.begin(), TempPass.end()); + std::random_shuffle(PassesToRun.begin(), PassesToRun.end()); // // Step 2: Run optimizer passes on the program and check for success. // std::cout << "Running selected passes on program to test for crash: "; - for(int i=0, e=TempPass.size(); i!=e; i++) { - std::cout << "-" << TempPass[i]->getPassArgument( )<< " "; + for(int i = 0, e = PassesToRun.size(); i != e; i++) { + std::cout << "-" << PassesToRun[i]->getPassArgument( )<< " "; } + std::string Filename; - if(runPasses(TempPass, Filename, false)) { + if(runPasses(PassesToRun, Filename, false)) { std::cout << "\n"; std::cout << "Optimizer passes caused failure!\n\n"; debugOptimizerCrash(); return true; + } else { + std::cout << "Combination " << num << " optimized successfully!\n"; } - else{ - std::cout << "Combination "< &AllPasses) std::cout << TEE.what(); return debugCodeGeneratorCrash(); } - + // // Step 4: Run the program and compare its output to the reference // output (created above). @@ -97,8 +93,7 @@ bool BugDriver::runManyPasses(const std::vector &AllPasses) std::cout << "\n*** diffProgram returned true!\n"; debugMiscompilation(); return true; - } - else{ + } else { std::cout << "\n*** diff'd output matches!\n"; } } catch (ToolExecutionError &TEE) { @@ -113,7 +108,5 @@ bool BugDriver::runManyPasses(const std::vector &AllPasses) num++; } //end while - // This will never be reached - std::cout << "Did not find any bugs :-( \n"; - return false; + // Unreachable. }