//
// The LLVM Compiler Infrastructure
//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
return 0;
}
+cl::opt<bool> SilencePasses("silence-passes", cl::desc("Suppress output of running passes (both stdout and stderr)"));
+
/// 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,
///
bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
std::string &OutputFilename, bool DeleteOutput,
- bool Quiet) const {
+ bool Quiet, unsigned NumExtraArgs,
+ const char * const *ExtraArgs) const {
// setup the output file name
cout << std::flush;
sys::Path uniqueFilename("bugpoint-output.bc");
// setup the child process' arguments
const char** args = (const char**)
alloca(sizeof(const char*) *
- (Passes.size()+13+2*PluginLoader::getNumPlugins()));
+ (Passes.size()+13+2*PluginLoader::getNumPlugins()+NumExtraArgs));
int n = 0;
sys::Path tool = sys::Program::FindProgramByName(ToolName);
if (UseValgrind) {
E = pass_args.end(); I != E; ++I )
args[n++] = I->c_str();
args[n++] = inputFilename.c_str();
+ for (unsigned i = 0; i < NumExtraArgs; ++i)
+ args[n++] = *ExtraArgs;
args[n++] = 0;
sys::Path prog;
prog = sys::Program::FindProgramByName("valgrind");
else
prog = tool;
- int result = sys::Program::ExecuteAndWait(prog, args, 0, 0,
+
+ // Redirect stdout and stderr to nowhere if SilencePasses is given
+ sys::Path Nowhere;
+ const sys::Path *Redirects[3] = {0, &Nowhere, &Nowhere};
+
+ int result = sys::Program::ExecuteAndWait(prog, args, 0, (SilencePasses ? Redirects : 0),
Timeout, MemoryLimit, &ErrMsg);
// If we are supposed to delete the bitcode file or if the passes crashed,
/// failure.
Module *BugDriver::runPassesOn(Module *M,
const std::vector<const PassInfo*> &Passes,
- bool AutoDebugCrashes) {
+ bool AutoDebugCrashes, unsigned NumExtraArgs,
+ const char * const *ExtraArgs) {
Module *OldProgram = swapProgramIn(M);
std::string BitcodeResult;
- if (runPasses(Passes, BitcodeResult, false/*delete*/, true/*quiet*/)) {
+ if (runPasses(Passes, BitcodeResult, false/*delete*/, true/*quiet*/,
+ NumExtraArgs, ExtraArgs)) {
if (AutoDebugCrashes) {
cerr << " Error running this sequence of passes"
<< " on the input program!\n";