From fb1f29acf9dfc9386a3951e62fa09d9ab84eca05 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sun, 8 Aug 2010 22:14:20 +0000 Subject: [PATCH] Add a opt-args option that can be used to pass arguments to every opt invocation. Fixes PR7793: bugpoint -debug test.ll --opt-args -unroll-count=4 llvm-svn: 110555 --- llvm/docs/CommandGuide/bugpoint.pod | 4 ++++ llvm/tools/bugpoint/OptimizerDriver.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/llvm/docs/CommandGuide/bugpoint.pod b/llvm/docs/CommandGuide/bugpoint.pod index 7afeea1aba5a..1870a0d84b60 100644 --- a/llvm/docs/CommandGuide/bugpoint.pod +++ b/llvm/docs/CommandGuide/bugpoint.pod @@ -67,6 +67,10 @@ tool. Pass all arguments specified after B<--gcc-tool-args> to the invocation of B. +=item B<--opt-args> I + +Pass all arguments specified after B<--opt-args> to the invocation of B. + =item B<--disable-{dce,simplifycfg}> Do not run the specified passes to clean up and reduce the size of the test diff --git a/llvm/tools/bugpoint/OptimizerDriver.cpp b/llvm/tools/bugpoint/OptimizerDriver.cpp index 7abcece3a844..ffd40997fc54 100644 --- a/llvm/tools/bugpoint/OptimizerDriver.cpp +++ b/llvm/tools/bugpoint/OptimizerDriver.cpp @@ -88,6 +88,10 @@ void BugDriver::EmitProgressBitcode(const Module *M, cl::opt SilencePasses("silence-passes", cl::desc("Suppress output of running passes (both stdout and stderr)")); +static cl::list OptArgs("opt-args", cl::Positional, + cl::desc("..."), + cl::ZeroOrMore, cl::PositionalEatsArgs); + /// runPasses - Run the specified passes on Program, outputting a bitcode file /// and writing the filename into OutputFile if successful. If the /// optimizations fail for some reason (optimizer crashes), return true, @@ -154,6 +158,8 @@ bool BugDriver::runPasses(Module *Program, Args.push_back("-o"); Args.push_back(OutputFilename.c_str()); + for (unsigned i = 0, e = OptArgs.size(); i != e; ++i) + Args.push_back(OptArgs[i].c_str()); std::vector pass_args; for (unsigned i = 0, e = PluginLoader::getNumPlugins(); i != e; ++i) { pass_args.push_back( std::string("-load"));