[PATCH] D29445: LTO: add a code-model flag
Martell Malone via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 28 15:55:26 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296542: [ELF] - Allow the Code Model flag when using LTO (authored by martell).
Changed prior to commit:
https://reviews.llvm.org/D29445?vs=88174&id=90098#toc
Repository:
rL LLVM
https://reviews.llvm.org/D29445
Files:
lld/trunk/ELF/Config.h
lld/trunk/ELF/LTO.cpp
lld/trunk/include/lld/Core/TargetOptionsCommandFlags.h
lld/trunk/lib/Core/TargetOptionsCommandFlags.cpp
lld/trunk/test/ELF/lto/codemodel.ll
Index: lld/trunk/include/lld/Core/TargetOptionsCommandFlags.h
===================================================================
--- lld/trunk/include/lld/Core/TargetOptionsCommandFlags.h
+++ lld/trunk/include/lld/Core/TargetOptionsCommandFlags.h
@@ -11,8 +11,10 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Support/CodeGen.h"
#include "llvm/Target/TargetOptions.h"
namespace lld {
llvm::TargetOptions InitTargetOptionsFromCodeGenFlags();
+llvm::CodeModel::Model GetCodeModelFromCMModel();
}
Index: lld/trunk/test/ELF/lto/codemodel.ll
===================================================================
--- lld/trunk/test/ELF/lto/codemodel.ll
+++ lld/trunk/test/ELF/lto/codemodel.ll
@@ -0,0 +1,20 @@
+; REQUIRES: x86
+; RUN: llvm-as %s -o %t.o
+; RUN: ld.lld -m elf_x86_64 %t.o -o %ts -mllvm -code-model=small
+; RUN: ld.lld -m elf_x86_64 %t.o -o %tl -mllvm -code-model=large
+; RUN: llvm-objdump -d %ts | FileCheck %s --check-prefix=CHECK-SMALL
+; RUN: llvm-objdump -d %tl | FileCheck %s --check-prefix=CHECK-LARGE
+
+target triple = "x86_64-unknown-linux-gnu"
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+ at data = internal constant [0 x i32] []
+
+define i32* @_start() nounwind readonly {
+entry:
+; CHECK-SMALL-LABEL: _start:
+; CHECK-SMALL: movl $2097440, %eax
+; CHECK-LARGE-LABEL: _start:
+; CHECK-LARGE: movabsq $2097440, %rax
+ ret i32* getelementptr ([0 x i32], [0 x i32]* @data, i64 0, i64 0)
+}
Index: lld/trunk/ELF/Config.h
===================================================================
--- lld/trunk/ELF/Config.h
+++ lld/trunk/ELF/Config.h
@@ -13,6 +13,7 @@
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
+#include "llvm/Support/CodeGen.h"
#include "llvm/Support/ELF.h"
#include <vector>
Index: lld/trunk/ELF/LTO.cpp
===================================================================
--- lld/trunk/ELF/LTO.cpp
+++ lld/trunk/ELF/LTO.cpp
@@ -73,6 +73,7 @@
Conf.Options.RelaxELFRelocations = true;
Conf.RelocModel = Config->pic() ? Reloc::PIC_ : Reloc::Static;
+ Conf.CodeModel = GetCodeModelFromCMModel();
Conf.DisableVerify = Config->DisableVerify;
Conf.DiagHandler = diagnosticHandler;
Conf.OptLevel = Config->LTOO;
Index: lld/trunk/lib/Core/TargetOptionsCommandFlags.cpp
===================================================================
--- lld/trunk/lib/Core/TargetOptionsCommandFlags.cpp
+++ lld/trunk/lib/Core/TargetOptionsCommandFlags.cpp
@@ -26,3 +26,7 @@
llvm::TargetOptions lld::InitTargetOptionsFromCodeGenFlags() {
return ::InitTargetOptionsFromCodeGenFlags();
}
+
+llvm::CodeModel::Model lld::GetCodeModelFromCMModel() {
+ return CMModel;
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29445.90098.patch
Type: text/x-patch
Size: 2749 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170228/ad2bf75b/attachment.bin>
More information about the llvm-commits
mailing list