Don't try to materialize a function that isn't materializable anyways. This
authorNick Lewycky <nicholas@mxc.ca>
Mon, 15 Feb 2010 21:27:56 +0000 (21:27 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Mon, 15 Feb 2010 21:27:56 +0000 (21:27 +0000)
fixes a crash using FPM on a Function that isn't owned by a Module.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96273 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/PassManager.cpp

index a1d554e4ff8ca8026d20be5b56dcec2493ddd51d..8a3527ea52a441836cc10b97daff4a16013c8fea 100644 (file)
@@ -1220,9 +1220,11 @@ void FunctionPassManager::add(Pass *P) {
 /// so, return true.
 ///
 bool FunctionPassManager::run(Function &F) {
-  std::string errstr;
-  if (F.Materialize(&errstr)) {
-    llvm_report_error("Error reading bitcode file: " + errstr);
+  if (F.isMaterializable()) {
+    std::string errstr;
+    if (F.Materialize(&errstr)) {
+      llvm_report_error("Error reading bitcode file: " + errstr);
+    }
   }
   return FPM->run(F);
 }