]> granicus.if.org Git - llvm/commitdiff
Object: Move datalayout check into irsymtab::build. NFCI.
authorPeter Collingbourne <peter@pcc.me.uk>
Thu, 8 Jun 2017 22:04:24 +0000 (22:04 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Thu, 8 Jun 2017 22:04:24 +0000 (22:04 +0000)
This check is a requirement of the irsymtab builder, not of any
particular caller.

Differential Revision: https://reviews.llvm.org/D33970

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

lib/Object/IRSymtab.cpp

index 94f134909391c7f59a7322232bf250bdf3bb7ac1..d21acdb1d556a8c6321951388548293014981bec 100644 (file)
@@ -90,6 +90,10 @@ struct Builder {
 };
 
 Error Builder::addModule(Module *M) {
+  if (M->getDataLayoutStr().empty())
+    return make_error<StringError>("input module has no datalayout",
+                                   inconvertibleErrorCode());
+
   SmallPtrSet<GlobalValue *, 8> Used;
   collectUsedGlobalVariables(*M, Used, /*CompilerUsed*/ false);
 
@@ -277,10 +281,6 @@ static Expected<FileContents> upgrade(ArrayRef<BitcodeModule> BMs) {
     if (!MOrErr)
       return MOrErr.takeError();
 
-    if ((*MOrErr)->getDataLayoutStr().empty())
-      return make_error<StringError>("input module has no datalayout",
-                                     inconvertibleErrorCode());
-
     Mods.push_back(MOrErr->get());
     OwnedMods.push_back(std::move(*MOrErr));
   }