aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/LTO/LTOBackend.cpp
diff options
context:
space:
mode:
authorCaroline Tice <cmtice@google.com>2018-09-21 18:41:31 +0000
committerCaroline Tice <cmtice@google.com>2018-09-21 18:41:31 +0000
commit3dea3f9e0a7e2c72ff7e109d1581b62365fc7ae8 (patch)
treeae18be7979a8f0730ee13cb221f15961824720ff /llvm/lib/LTO/LTOBackend.cpp
parent8a59dbf7fd73f28792f605c059e5cea189e0c587 (diff)
downloadllvm-3dea3f9e0a7e2c72ff7e109d1581b62365fc7ae8.zip
llvm-3dea3f9e0a7e2c72ff7e109d1581b62365fc7ae8.tar.gz
llvm-3dea3f9e0a7e2c72ff7e109d1581b62365fc7ae8.tar.bz2
Pass code-model through Module IR to LTO which will use it.
Currently the code-model does not get saved in the module IR, so if a code model is specified when compiling with LTO, it gets lost and is not propagated properly to LTO. This patch, along with one for the front end, fixes that. Differential Revision: https://reviews.llvm.org/D52322 llvm-svn: 342760
Diffstat (limited to 'llvm/lib/LTO/LTOBackend.cpp')
-rw-r--r--llvm/lib/LTO/LTOBackend.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index eadbb41..be33ab8 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -138,9 +138,15 @@ createTargetMachine(Config &Conf, const Target *TheTarget, Module &M) {
RelocModel =
M.getPICLevel() == PICLevel::NotPIC ? Reloc::Static : Reloc::PIC_;
+ Optional<CodeModel::Model> CodeModel;
+ if (Conf.CodeModel)
+ CodeModel = *Conf.CodeModel;
+ else
+ CodeModel = M.getCodeModel();
+
return std::unique_ptr<TargetMachine>(TheTarget->createTargetMachine(
TheTriple, Conf.CPU, Features.getString(), Conf.Options, RelocModel,
- Conf.CodeModel, Conf.CGOptLevel));
+ CodeModel, Conf.CGOptLevel));
}
static void runNewPMPasses(Config &Conf, Module &Mod, TargetMachine *TM,