[llvm-commits] CVS: llvm/tools/bugpoint/OptimizerDriver.cpp
Nick Lewycky
nicholas at mxc.ca
Wed Sep 13 20:50:09 PDT 2006
Changes in directory llvm/tools/bugpoint:
OptimizerDriver.cpp updated: 1.44 -> 1.45
---
Log message:
Add --enable-valgrind option to run optimizations through valgrind to
pick up on memory errors.
---
Diffs of the changes: (+16 -3)
OptimizerDriver.cpp | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
Index: llvm/tools/bugpoint/OptimizerDriver.cpp
diff -u llvm/tools/bugpoint/OptimizerDriver.cpp:1.44 llvm/tools/bugpoint/OptimizerDriver.cpp:1.45
--- llvm/tools/bugpoint/OptimizerDriver.cpp:1.44 Sun Aug 27 17:12:06 2006
+++ llvm/tools/bugpoint/OptimizerDriver.cpp Wed Sep 13 22:49:54 2006
@@ -41,6 +41,8 @@
// 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 @@
///
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 @@
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 @@
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,
More information about the llvm-commits
mailing list