#include "DeltaManager.h"
#include "ReducerWorkItem.h"
#include "TestRunner.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/CodeGen/CommandFlags.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/MemoryBufferRef.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
#include <system_error>
#ifdef _WIN32
#include <windows.h>
#endif
usingnamespacellvm;
cl::OptionCategory LLVMReduceOptions("llvm-reduce options");
static cl::opt<bool> Help("h", cl::desc("Alias for -help"), cl::Hidden,
cl::cat(LLVMReduceOptions));
static cl::opt<bool> Version("v", cl::desc("Alias for -version"), cl::Hidden,
cl::cat(LLVMReduceOptions));
static cl::opt<bool> PreserveDebugEnvironment(
"preserve-debug-environment",
cl::desc("Don't disable features used for crash "
"debugging (crash reports, llvm-symbolizer and core dumps)"),
cl::cat(LLVMReduceOptions));
static cl::opt<bool>
PrintDeltaPasses("print-delta-passes",
cl::desc("Print list of delta passes, passable to "
"--delta-passes as a comma separated list"),
cl::cat(LLVMReduceOptions));
static cl::opt<std::string> InputFilename(cl::Positional,
cl::desc("<input llvm ll/bc file>"),
cl::cat(LLVMReduceOptions));
static cl::opt<std::string>
TestFilename("test",
cl::desc("Name of the interesting-ness test to be run"),
cl::cat(LLVMReduceOptions));
static cl::list<std::string>
TestArguments("test-arg",
cl::desc("Arguments passed onto the interesting-ness test"),
cl::cat(LLVMReduceOptions));
static cl::opt<std::string> OutputFilename(
"output",
cl::desc("Specify the output file. default: reduced.ll|.bc|.mir"));
static cl::alias OutputFileAlias("o", cl::desc("Alias for -output"),
cl::aliasopt(OutputFilename),
cl::cat(LLVMReduceOptions));
static cl::opt<bool>
ReplaceInput("in-place",
cl::desc("WARNING: This option will replace your input file "
"with the reduced version!"),
cl::cat(LLVMReduceOptions));
enum class InputLanguages { … };
static cl::opt<InputLanguages>
InputLanguage("x", cl::ValueOptional,
cl::desc("Input language ('ir' or 'mir')"),
cl::init(InputLanguages::None),
cl::values(clEnumValN(InputLanguages::IR, "ir", ""),
clEnumValN(InputLanguages::MIR, "mir", "")),
cl::cat(LLVMReduceOptions));
static cl::opt<bool> ForceOutputBitcode(
"output-bitcode",
cl::desc("Emit final result as bitcode instead of text IR"), cl::Hidden,
cl::cat(LLVMReduceOptions));
static cl::opt<int>
MaxPassIterations("max-pass-iterations",
cl::desc("Maximum number of times to run the full set "
"of delta passes (default=5)"),
cl::init(5), cl::cat(LLVMReduceOptions));
extern cl::opt<cl::boolOrDefault> PreserveInputDbgFormat;
static codegen::RegisterCodeGenFlags CGF;
static void disableEnvironmentDebugFeatures() { … }
static std::pair<StringRef, bool> determineOutputType(bool IsMIR,
bool InputIsBitcode) { … }
int main(int Argc, char **Argv) { … }