Index: tools/bugpoint/ExecutionDriver.cpp =================================================================== --- tools/bugpoint/ExecutionDriver.cpp +++ tools/bugpoint/ExecutionDriver.cpp @@ -296,29 +296,10 @@ std::string BitcodeFile, const std::string &SharedObj, AbstractInterpreter *AI) const { + assert(!BitcodeFile.empty() && "BitcodeFile is empty."); if (!AI) AI = Interpreter; assert(AI && "Interpreter should have been created already!"); - if (BitcodeFile.empty()) { - // Emit the program to a bitcode file... - auto File = - sys::fs::TempFile::create(OutputPrefix + "-test-program-%%%%%%%.bc"); - if (!File) { - errs() << ToolName - << ": Error making unique filename: " << toString(File.takeError()) - << "!\n"; - exit(1); - } - DiscardTemp Discard{*File}; - BitcodeFile = File->TmpName; - - if (writeProgramToFile(File->FD, Program)) { - errs() << ToolName << ": Error emitting bitcode to file '" << BitcodeFile - << "'!\n"; - exit(1); - } - } - if (OutputFile.empty()) OutputFile = OutputPrefix + "-execution-output-%%%%%%%"; @@ -375,7 +356,23 @@ Expected BugDriver::executeProgramSafely(const Module &Program, const std::string &OutputFile) const { - return executeProgram(Program, OutputFile, "", "", SafeInterpreter); + Expected BitcodeFile = + sys::fs::TempFile::create(OutputPrefix + "-test-program-%%%%%%%.bc"); + if (!BitcodeFile) { + errs() << ToolName << ": Error making unique filename: " + << toString(BitcodeFile.takeError()) << "!\n"; + exit(1); + } + DiscardTemp Discard{*BitcodeFile}; + + if (writeProgramToFile(BitcodeFile->FD, Program)) { + errs() << ToolName << ": Error emitting bitcode to file '" + << BitcodeFile->TmpName << "'!\n"; + exit(1); + } + + return executeProgram(Program, OutputFile, BitcodeFile->TmpName, "", + SafeInterpreter); } Expected