Fix for bug 391.
Improve exeception handling around bcreader invocations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14674 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp
index c9fd577..4ece8b9 100644
--- a/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -137,6 +137,8 @@
       } catch (...) {
         std::cerr << "Error creating the interpreter!\n";
       }
+    } catch (std::string& errmsg) {
+      std::cerr << "Error reading the bytecode file: " << errmsg << "\n";
     } catch (...) {
       std::cerr << "Error reading the bytecode file!\n";
     }
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp
index 5340a19..02577df 100644
--- a/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/lib/ExecutionEngine/JIT/JIT.cpp
@@ -117,6 +117,9 @@
   // Make sure we read in the function if it exists in this Module
   try {
     MP->materializeFunction(F);
+  } catch ( std::string& errmsg ) {
+    std::cerr << "Error parsing bytecode file: " << errmsg << "\n";
+    abort();
   } catch (...) {
     std::cerr << "Error parsing bytecode file!\n";
     abort();
diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp
index 8881329..b37b460 100644
--- a/lib/VMCore/Pass.cpp
+++ b/lib/VMCore/Pass.cpp
@@ -92,7 +92,15 @@
 void FunctionPassManager::add(FunctionPass *P) { PM->add(P); }
 void FunctionPassManager::add(ImmutablePass *IP) { PM->add(IP); }
 bool FunctionPassManager::run(Function &F) { 
-  MP->materializeFunction(&F);
+  try {
+    MP->materializeFunction(&F);
+  } catch (std::string& errstr) {
+    std::cerr << "Error reading bytecode file: " << errstr << "\n";
+    abort();
+  } catch (...) {
+    std::cerr << "Error reading bytecode file:\n";
+    abort();
+  }
   return PM->run(F); 
 }