Index: lib/CodeGen/MachineVerifier.cpp =================================================================== --- lib/CodeGen/MachineVerifier.cpp +++ lib/CodeGen/MachineVerifier.cpp @@ -56,14 +56,13 @@ MachineVerifier(Pass *pass, const char *b) : PASS(pass), Banner(b), - OutFileName(getenv("LLVM_VERIFY_MACHINEINSTRS")) + OS(&errs()) {} bool runOnMachineFunction(MachineFunction &MF); Pass *const PASS; const char *Banner; - const char *const OutFileName; raw_ostream *OS; const MachineFunction *MF; const TargetMachine *TM; @@ -277,22 +276,6 @@ } bool MachineVerifier::runOnMachineFunction(MachineFunction &MF) { - raw_ostream *OutFile = nullptr; - if (OutFileName) { - std::error_code EC; - OutFile = new raw_fd_ostream(OutFileName, EC, - sys::fs::F_Append | sys::fs::F_Text); - if (EC) { - errs() << "Error opening '" << OutFileName << "': " << EC.message() - << '\n'; - exit(1); - } - - OS = OutFile; - } else { - OS = &errs(); - } - foundErrors = 0; this->MF = &MF; @@ -363,9 +346,7 @@ } visitMachineFunctionAfter(); - if (OutFile) - delete OutFile; - else if (foundErrors) + if (foundErrors) report_fatal_error("Found "+Twine(foundErrors)+" machine code errors."); // Clean up. Index: lib/CodeGen/Passes.cpp =================================================================== --- lib/CodeGen/Passes.cpp +++ lib/CodeGen/Passes.cpp @@ -81,7 +81,9 @@ cl::desc("Dump garbage collector data")); static cl::opt VerifyMachineCode("verify-machineinstrs", cl::Hidden, cl::desc("Verify generated machine code"), - cl::init(getenv("LLVM_VERIFY_MACHINEINSTRS")!=nullptr)); + cl::init(false), + cl::ZeroOrMore); + static cl::opt PrintMachineInstrs("print-machineinstrs", cl::ValueOptional, cl::desc("Print machine instrs"), Index: test/lit.cfg =================================================================== --- test/lit.cfg +++ test/lit.cfg @@ -270,6 +270,8 @@ # Warn, but still provide a substitution. lit_config.note('Did not find ' + tool_name + ' in ' + llvm_tools_dir) tool_path = llvm_tools_dir + '/' + tool_name + if tool_name == "llc" and os.environ['LLVM_ENABLE_MACHINE_VERIFIER'] == "1": + tool_path += " -verify-machineinstrs" config.substitutions.append((pattern, tool_pipe + tool_path)) ### Targets