[PATCH] D27082: [LTO] Reject modules without datalayout

Davide Italiano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 13 20:30:21 PST 2016


davide updated this revision to Diff 81341.
davide added a comment.

Upload correct diff (`setDataLayout()` calls removed). Thanks to Mehdi for noticing.


https://reviews.llvm.org/D27082

Files:
  lib/LTO/LTO.cpp
  lib/LTO/LTOBackend.cpp
  lib/LTO/LTOModule.cpp


Index: lib/LTO/LTOModule.cpp
===================================================================
--- lib/LTO/LTOModule.cpp
+++ lib/LTO/LTOModule.cpp
@@ -231,7 +231,6 @@
 
   TargetMachine *target =
       march->createTargetMachine(TripleStr, CPU, FeatureStr, options, None);
-  M->setDataLayout(target->createDataLayout());
 
   std::unique_ptr<object::IRObjectFile> IRObj(
       new object::IRObjectFile(Buffer, std::move(M)));
Index: lib/LTO/LTOBackend.cpp
===================================================================
--- lib/LTO/LTOBackend.cpp
+++ lib/LTO/LTOBackend.cpp
@@ -191,7 +191,6 @@
 
 bool opt(Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod,
          bool IsThinLTO) {
-  Mod.setDataLayout(TM->createDataLayout());
   if (Conf.OptPipeline.empty())
     runOldPMPasses(Conf, Mod, TM, IsThinLTO);
   else
Index: lib/LTO/LTO.cpp
===================================================================
--- lib/LTO/LTO.cpp
+++ lib/LTO/LTO.cpp
@@ -320,8 +320,12 @@
   if (Conf.ResolutionFile)
     writeToResolutionFile(*Conf.ResolutionFile, Input.get(), Res);
 
-  // FIXME: move to backend
   Module &M = Input->Obj->getModule();
+  if (M.getDataLayoutStr().empty())
+    return make_error<StringError>("input module has no datalayout",
+                                    inconvertibleErrorCode());
+
+  // FIXME: move to backend
   if (!Conf.OverrideTriple.empty())
     M.setTargetTriple(Conf.OverrideTriple);
   else if (M.getTargetTriple().empty())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27082.81341.patch
Type: text/x-patch
Size: 1482 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161214/68c978ea/attachment.bin>


More information about the llvm-commits mailing list