[lld] r296542 - [ELF] - Allow the Code Model flag when using LTO
Martell Malone via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 28 15:43:26 PST 2017
Author: martell
Date: Tue Feb 28 17:43:26 2017
New Revision: 296542
URL: http://llvm.org/viewvc/llvm-project?rev=296542&view=rev
Log:
[ELF] - Allow the Code Model flag when using LTO
Differential Revision: https://reviews.llvm.org/D29445
Added:
lld/trunk/test/ELF/lto/codemodel.ll
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/LTO.cpp
lld/trunk/include/lld/Core/TargetOptionsCommandFlags.h
lld/trunk/lib/Core/TargetOptionsCommandFlags.cpp
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=296542&r1=296541&r2=296542&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Tue Feb 28 17:43:26 2017
@@ -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>
Modified: lld/trunk/ELF/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?rev=296542&r1=296541&r2=296542&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.cpp (original)
+++ lld/trunk/ELF/LTO.cpp Tue Feb 28 17:43:26 2017
@@ -73,6 +73,7 @@ static std::unique_ptr<lto::LTO> createL
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;
Modified: lld/trunk/include/lld/Core/TargetOptionsCommandFlags.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/TargetOptionsCommandFlags.h?rev=296542&r1=296541&r2=296542&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/TargetOptionsCommandFlags.h (original)
+++ lld/trunk/include/lld/Core/TargetOptionsCommandFlags.h Tue Feb 28 17:43:26 2017
@@ -11,8 +11,10 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Support/CodeGen.h"
#include "llvm/Target/TargetOptions.h"
namespace lld {
llvm::TargetOptions InitTargetOptionsFromCodeGenFlags();
+llvm::CodeModel::Model GetCodeModelFromCMModel();
}
Modified: lld/trunk/lib/Core/TargetOptionsCommandFlags.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/TargetOptionsCommandFlags.cpp?rev=296542&r1=296541&r2=296542&view=diff
==============================================================================
--- lld/trunk/lib/Core/TargetOptionsCommandFlags.cpp (original)
+++ lld/trunk/lib/Core/TargetOptionsCommandFlags.cpp Tue Feb 28 17:43:26 2017
@@ -26,3 +26,7 @@
llvm::TargetOptions lld::InitTargetOptionsFromCodeGenFlags() {
return ::InitTargetOptionsFromCodeGenFlags();
}
+
+llvm::CodeModel::Model lld::GetCodeModelFromCMModel() {
+ return CMModel;
+}
Added: lld/trunk/test/ELF/lto/codemodel.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/codemodel.ll?rev=296542&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/codemodel.ll (added)
+++ lld/trunk/test/ELF/lto/codemodel.ll Tue Feb 28 17:43:26 2017
@@ -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)
+}
More information about the llvm-commits
mailing list