Index: llvm/trunk/lib/Support/Signals.cpp =================================================================== --- llvm/trunk/lib/Support/Signals.cpp +++ llvm/trunk/lib/Support/Signals.cpp @@ -26,15 +26,21 @@ #include "llvm/Support/Program.h" #include "llvm/Support/StringSaver.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/Options.h" #include -namespace llvm { - //===----------------------------------------------------------------------===// //=== WARNING: Implementation here must contain only TRULY operating system //=== independent code. //===----------------------------------------------------------------------===// +using namespace llvm; + +static cl::opt + DisableSymbolication("disable-symbolication", + cl::desc("Disable symbolizing crash backtraces."), + cl::init(false), cl::Hidden); + static ManagedStatic>> CallBacksToRun; void sys::RunSignalHandlers() { @@ -44,9 +50,6 @@ I.first(I.second); CallBacksToRun->clear(); } -} - -using namespace llvm; static bool findModulesAndOffsets(void **StackTrace, int Depth, const char **Modules, intptr_t *Offsets, @@ -70,6 +73,9 @@ static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace, int Depth, llvm::raw_ostream &OS) { + if (DisableSymbolication) + return false; + // Don't recursively invoke the llvm-symbolizer binary. if (Argv0.find("llvm-symbolizer") != std::string::npos) return false; Index: llvm/trunk/test/BugPoint/unsymbolized.ll =================================================================== --- llvm/trunk/test/BugPoint/unsymbolized.ll +++ llvm/trunk/test/BugPoint/unsymbolized.ll @@ -0,0 +1,21 @@ +; REQUIRES: loadable_module +; RUN: echo "import sys" > %t.py +; RUN: echo "print('args = ' + str(sys.argv))" >> %t.py +; RUN: echo "exit(1)" >> %t.py +; RUN: not bugpoint -load %llvmshlibdir/BugpointPasses%shlibext %s -output-prefix %t -bugpoint-crashcalls -opt-command="%python" -opt-args %t.py | FileCheck %s +; RUN: not --crash opt -load %llvmshlibdir/BugpointPasses%shlibext %s -bugpoint-crashcalls -disable-symbolication 2>&1 | FileCheck --check-prefix=CRASH %s + +; Test that bugpoint disables symbolication on the opt tool to reduce runtime overhead when opt crashes +; CHECK: args = {{.*}}'-disable-symbolication' + +; Test that opt, when it crashes & is passed -disable-symbolication, doesn't symbolicate. +; In theory this test should maybe be in test/tools/opt or +; test/Transforms, but since there doesn't seem to be another convenient way to +; crash opt, apart from the BugpointPasses dynamic plugin, this is the spot for +; now. +; CRASH-NOT: Signals.inc + +define void @f() { + call void @f() + ret void +} Index: llvm/trunk/tools/bugpoint/OptimizerDriver.cpp =================================================================== --- llvm/trunk/tools/bugpoint/OptimizerDriver.cpp +++ llvm/trunk/tools/bugpoint/OptimizerDriver.cpp @@ -202,10 +202,11 @@ } else Args.push_back(tool.c_str()); - 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()); + Args.push_back("-disable-symbolication"); + Args.push_back("-o"); + Args.push_back(OutputFilename.c_str()); std::vector pass_args; for (unsigned i = 0, e = PluginLoader::getNumPlugins(); i != e; ++i) { pass_args.push_back(std::string("-load"));