diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2006-09-14 03:49:54 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2006-09-14 03:49:54 +0000 |
commit | 40394bc4197b0e67f4effa5bbf7e655138be82c3 (patch) | |
tree | 5cf087c2a829127c74db24a6fdce1797228fced9 /tools | |
parent | 97d92d50aa52fd7f891ddeaf9e3886305a5a77d9 (diff) | |
download | external_llvm-40394bc4197b0e67f4effa5bbf7e655138be82c3.zip external_llvm-40394bc4197b0e67f4effa5bbf7e655138be82c3.tar.gz external_llvm-40394bc4197b0e67f4effa5bbf7e655138be82c3.tar.bz2 |
Add --enable-valgrind option to run optimizations through valgrind to
pick up on memory errors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30311 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bugpoint/OptimizerDriver.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp index 43d973e..8087ddb 100644 --- a/tools/bugpoint/OptimizerDriver.cpp +++ b/tools/bugpoint/OptimizerDriver.cpp @@ -41,6 +41,8 @@ namespace { // ChildOutput - This option captures the name of the child output file that // is set up by the parent bugpoint process cl::opt<std::string> ChildOutput("child-output", cl::ReallyHidden); + cl::opt<bool> UseValgrind("enable-valgrind", + cl::desc("Run optimizations through valgrind")); } /// writeProgramToFile - This writes the current "Program" to the named bytecode @@ -124,7 +126,7 @@ int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) { /// bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes, std::string &OutputFilename, bool DeleteOutput, - bool Quiet) const{ + bool Quiet) const { // setup the output file name std::cout << std::flush; sys::Path uniqueFilename("bugpoint-output.bc"); @@ -158,7 +160,14 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes, alloca(sizeof(const char*) * (Passes.size()+10+2*PluginLoader::getNumPlugins())); int n = 0; - args[n++] = ToolName.c_str(); + if (UseValgrind) { + args[n++] = "valgrind"; + args[n++] = "--error-exitcode=1"; + args[n++] = "-q"; + args[n++] = sys::Program::FindProgramByName(ToolName).c_str(); + } else + args[n++] = ToolName.c_str(); + args[n++] = "-as-child"; args[n++] = "-child-output"; args[n++] = OutputFilename.c_str(); @@ -176,7 +185,11 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes, args[n++] = inputFilename.c_str(); args[n++] = 0; - sys::Path prog(sys::Program::FindProgramByName(ToolName)); + sys::Path prog; + if (UseValgrind) + prog = sys::Program::FindProgramByName("valgrind"); + else + prog = sys::Program::FindProgramByName(ToolName); int result = sys::Program::ExecuteAndWait(prog,args,0,0,Timeout,&ErrMsg); // If we are supposed to delete the bytecode file or if the passes crashed, |