]> granicus.if.org Git - llvm/commitdiff
[ThinLTO] Verify lazy-loaded source module for function importing when assertions...
authorMehdi Amini <mehdi.amini@apple.com>
Fri, 23 Dec 2016 05:16:19 +0000 (05:16 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Fri, 23 Dec 2016 05:16:19 +0000 (05:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290416 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/FunctionImport.cpp

index c57435e284a614be01315b001fb220e2864aeed0..9489f8d699b52c7c5a032498bbb11d9d0673f836 100644 (file)
@@ -697,6 +697,14 @@ Expected<bool> FunctionImporter::importFunctions(
       }
     }
 
+#ifndef DEBUG
+    // Note: this can't be done after `renameModuleForThinLTO` as it leaves the
+    // module in a state that does not pass the verifier (for example aliases
+    // pointing to available_externally functions).
+    if (verifyModule(*SrcModule, &errs()))
+      report_fatal_error("Invalid lazy-loaded source module for importing");
+#endif
+
     // Link in the specified functions.
     if (renameModuleForThinLTO(*SrcModule, Index, &GlobalsToImport))
       return true;