use early exits to reduce indentation.
[oota-llvm.git] / tools / opt / opt.cpp
index 12bb2ec2c7cc38f98a736319dfe5caeb9264593b..50a2e390ce6e3084b01edffca5fe28ef333cee0f 100644 (file)
@@ -30,6 +30,7 @@
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PluginLoader.h"
+#include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/StandardPasses.h"
 #include "llvm/Support/SystemUtils.h"
 #include "llvm/Support/raw_ostream.h"
@@ -340,12 +341,14 @@ void AddStandardLinkPasses(PassManager &PM) {
 // main for opt
 //
 int main(int argc, char **argv) {
-  llvm_shutdown_obj X;  // Call llvm_shutdown() on exit.
+  sys::PrintStackTraceOnErrorSignal();
+  llvm::PrettyStackTraceProgram X(argc, argv);
+  
+  llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.
   LLVMContext &Context = getGlobalContext();
   
   cl::ParseCommandLineOptions(argc, argv,
     "llvm .bc -> .bc modular optimizer and analysis printer\n");
-  sys::PrintStackTraceOnErrorSignal();
 
   // Allocate a full target machine description only if necessary.
   // FIXME: The choice of target should be controllable on the command line.