[PATCH] D27082: [LTO] Reject modules without datalayout
Davide Italiano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 13 20:19:06 PST 2016
davide updated this revision to Diff 81340.
davide added a comment.
Prefer `Error<T>` instead to `report_fatal_error()`
https://reviews.llvm.org/D27082
Files:
lib/LTO/LTO.cpp
test/tools/llvm-lto2/X86/nodatalayout.ll
Index: test/tools/llvm-lto2/X86/nodatalayout.ll
===================================================================
--- /dev/null
+++ test/tools/llvm-lto2/X86/nodatalayout.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-as < %s > %t1.bc
+
+; Reject input modules without a datalayout.
+; RUN: not llvm-lto2 %t1.bc -o %t.o \
+; RUN: -r %t1.bc,patatino,px 2>&1 | FileCheck %s
+
+; CHECK: input module has no datalayout
+
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @patatino() {
+ ret void
+}
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.81340.patch
Type: text/x-patch
Size: 1137 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161214/438998d2/attachment.bin>
More information about the llvm-commits
mailing list