+ bool CreatedOutput = false;
+ if (ReferenceOutputFile.empty()) {
+ std::cout << "Generating reference output from raw program: ";
+ if(!createReferenceFile(Program)){
+ return debugCodeGeneratorCrash();
+ }
+ CreatedOutput = true;
+ }
+
+ // Make sure the reference output file gets deleted on exit from this
+ // function, if appropriate.
+ sys::Path ROF(ReferenceOutputFile);
+ FileRemover RemoverInstance(ROF, CreatedOutput);
+
+ // Diff the output of the raw program against the reference output. If it
+ // matches, then we assume there is a miscompilation bug and try to
+ // diagnose it.
+ std::cout << "*** Checking the code generator...\n";
+ try {
+ if (!diffProgram()) {
+ std::cout << "\n*** Debugging miscompilation!\n";
+ return debugMiscompilation();
+ }
+ } catch (ToolExecutionError &TEE) {
+ std::cerr << TEE.what();
+ return debugCodeGeneratorCrash();
+ }
+
+ std::cout << "\n*** Input program does not match reference diff!\n";
+ std::cout << "Debugging code generator problem!\n";
+ try {
+ return debugCodeGenerator();
+ } catch (ToolExecutionError &TEE) {
+ std::cerr << TEE.what();
+ return debugCodeGeneratorCrash();
+ }
+}
+
+void llvm::PrintFunctionList(const std::vector<Function*> &Funcs) {
+ 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 << std::flush;
+}
+
+void llvm::PrintGlobalVariableList(const std::vector<GlobalVariable*> &GVs) {
+ unsigned NumPrint = GVs.size();
+ if (NumPrint > 10) NumPrint = 10;
+ for (unsigned i = 0; i != NumPrint; ++i)
+ std::cout << " " << GVs[i]->getName();
+ if (NumPrint < GVs.size())
+ std::cout << "... <" << GVs.size() << " total>";
+ std::cout << std::flush;