aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/LTO/LTOBackend.cpp
diff options
context:
space:
mode:
authorWael Yehia <wyehia@ca.ibm.com>2021-03-10 17:20:09 -0500
committerDavid Tenty <daltenty@ibm.com>2021-03-10 17:31:26 -0500
commitbe646e31487b22f7f546fe91a978283581cc6dbb (patch)
treedf58b0bf9ac3b290c957db45a13ad8692b7346a7 /llvm/lib/LTO/LTOBackend.cpp
parent1a808286eff01fde07794b2c94138a96e7099561 (diff)
downloadllvm-be646e31487b22f7f546fe91a978283581cc6dbb.zip
llvm-be646e31487b22f7f546fe91a978283581cc6dbb.tar.gz
llvm-be646e31487b22f7f546fe91a978283581cc6dbb.tar.bz2
llvm-lto: default Relocation Model should be selected by the TargetMachine.
Right now, the createTargetMachine function in LTOBackend.cpp (used by llvm-lto, and other components) selects the default Relocation Model when none is specified in the module. Other components (such as opt and llc) that construct a TargetMachine delegate the decision on the default value to the polymorphic TargetMachine's constructor. This commit aligns llvm-lto with other components. Reviewed By: daltenty, fhahn Differential Revision: https://reviews.llvm.org/D97507
Diffstat (limited to 'llvm/lib/LTO/LTOBackend.cpp')
-rw-r--r--llvm/lib/LTO/LTOBackend.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 954aa2b..d49cdd5 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -184,10 +184,10 @@ createTargetMachine(const Config &Conf, const Target *TheTarget, Module &M) {
for (const std::string &A : Conf.MAttrs)
Features.AddFeature(A);
- Reloc::Model RelocModel;
+ Optional<Reloc::Model> RelocModel = None;
if (Conf.RelocModel)
RelocModel = *Conf.RelocModel;
- else
+ else if (M.getModuleFlag("PIC Level"))
RelocModel =
M.getPICLevel() == PICLevel::NotPIC ? Reloc::Static : Reloc::PIC_;