Index: llvm/tools/llvm-reduce/TestRunner.h =================================================================== --- llvm/tools/llvm-reduce/TestRunner.h +++ llvm/tools/llvm-reduce/TestRunner.h @@ -29,7 +29,7 @@ TestRunner(StringRef TestName, const std::vector &TestArgs, std::unique_ptr Program, std::unique_ptr TM, const char *ToolName, - StringRef OutputFilename, bool OutputBitcode); + StringRef OutputFilename, bool InputIsBitcode, bool OutputBitcode); /// Runs the interesting-ness test for the specified file /// @returns 0 if test was successful, 1 if otherwise @@ -46,6 +46,10 @@ void writeOutput(StringRef Message); + bool inputIsBitcode() const { + return InputIsBitcode; + } + private: StringRef TestName; const char *ToolName; @@ -53,6 +57,7 @@ std::unique_ptr Program; std::unique_ptr TM; StringRef OutputFilename; + const bool InputIsBitcode; bool EmitBitcode; }; Index: llvm/tools/llvm-reduce/TestRunner.cpp =================================================================== --- llvm/tools/llvm-reduce/TestRunner.cpp +++ llvm/tools/llvm-reduce/TestRunner.cpp @@ -22,10 +22,12 @@ const std::vector &TestArgs, std::unique_ptr Program, std::unique_ptr TM, const char *ToolName, - StringRef OutputName, bool OutputBitcode) + StringRef OutputName, bool InputIsBitcode, + bool OutputBitcode) : TestName(TestName), ToolName(ToolName), TestArgs(TestArgs), Program(std::move(Program)), TM(std::move(TM)), - OutputFilename(OutputName), EmitBitcode(OutputBitcode) { + OutputFilename(OutputName), InputIsBitcode(InputIsBitcode), + EmitBitcode(OutputBitcode) { assert(this->Program && "Initialized with null program?"); } Index: llvm/tools/llvm-reduce/deltas/Delta.cpp =================================================================== --- llvm/tools/llvm-reduce/deltas/Delta.cpp +++ llvm/tools/llvm-reduce/deltas/Delta.cpp @@ -47,7 +47,7 @@ static cl::opt TmpFilesAsBitcode( "write-tmp-files-as-bitcode", - cl::desc("Write temporary files as bitcode, instead of textual IR"), + cl::desc("Always write temporary files as bitcode instead of textual IR"), cl::init(false), cl::cat(LLVMReduceOptions)); #ifdef LLVM_ENABLE_THREADS @@ -66,11 +66,14 @@ const char *ToolName); bool isReduced(ReducerWorkItem &M, TestRunner &Test) { + const bool UseBitcode = Test.inputIsBitcode() || TmpFilesAsBitcode; + SmallString<128> CurrentFilepath; + // Write ReducerWorkItem to tmp file int FD; std::error_code EC = sys::fs::createTemporaryFile( - "llvm-reduce", M.isMIR() ? "mir" : (TmpFilesAsBitcode ? "bc" : "ll"), FD, + "llvm-reduce", M.isMIR() ? "mir" : (UseBitcode ? "bc" : "ll"), FD, CurrentFilepath); if (EC) { errs() << "Error making unique filename: " << EC.message() << "!\n"; Index: llvm/tools/llvm-reduce/llvm-reduce.cpp =================================================================== --- llvm/tools/llvm-reduce/llvm-reduce.cpp +++ llvm/tools/llvm-reduce/llvm-reduce.cpp @@ -163,7 +163,8 @@ // Initialize test environment TestRunner Tester(TestFilename, TestArguments, std::move(OriginalProgram), - std::move(TM), Argv[0], OutputFilename, OutputBitcode); + std::move(TM), Argv[0], OutputFilename, InputIsBitcode, + OutputBitcode); // This parses and writes out the testcase into a temporary file copy for the // test, rather than evaluating the source IR directly. This is for the