+ if (!PassesToRun.empty()) {
+ std::cout << "Running selected passes on program to test for crash: ";
+ if (runPasses(PassesToRun))
+ return debugCrash();
+ }
+
+ // Set up the execution environment, selecting a method to run LLVM bytecode.
+ if (initializeExecutionEnvironment()) return true;
+
+ // Run the raw input to see where we are coming from. If a reference output
+ // was specified, make sure that the raw output matches it. If not, it's a
+ // problem in the front-end or the code generator.
+ //
+ bool CreatedOutput = false;
+ if (ReferenceOutputFile.empty()) {
+ std::cout << "Generating reference output from raw program...";
+ ReferenceOutputFile = executeProgramWithCBE("bugpoint.reference.out");
+ CreatedOutput = true;
+ std::cout << "Reference output is: " << ReferenceOutputFile << "\n";
+ }
+
+ // Make sure the reference output file gets deleted on exit from this
+ // function, if appropriate.
+ struct Remover {
+ bool DeleteIt; const std::string &Filename;
+ Remover(bool deleteIt, const std::string &filename)
+ : DeleteIt(deleteIt), Filename(filename) {}
+ ~Remover() {
+ if (DeleteIt) removeFile(Filename);
+ }
+ } RemoverInstance(CreatedOutput, ReferenceOutputFile);
+
+ // Diff the output of the raw program against the reference output. If it
+ // matches, then we have a miscompilation bug.
+ std::cout << "*** Checking the code generator...\n";
+ if (!diffProgram()) {
+ std::cout << "\n*** Debugging miscompilation!\n";