[PATCH] D97507: llvm-lto: default Relocation Model should be selected by the TargetMachine.

wael yehia via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 10 08:13:06 PST 2021


w2yehia updated this revision to Diff 329672.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97507/new/

https://reviews.llvm.org/D97507

Files:
  llvm/lib/LTO/LTOBackend.cpp
  llvm/test/tools/llvm-lto/aix.ll


Index: llvm/test/tools/llvm-lto/aix.ll
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-lto/aix.ll
@@ -0,0 +1,12 @@
+; REQUIRES: powerpc-registered-target
+; RUN: llvm-as < %s > %t1
+; RUN: llvm-lto %t1 | FileCheck %s
+
+target triple = "powerpc-ibm-aix"
+
+define i32 @main() {
+entry:
+  ret i32 42
+}
+; CHECK: Wrote native object file
+
Index: llvm/lib/LTO/LTOBackend.cpp
===================================================================
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -184,10 +184,10 @@
   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_;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97507.329672.patch
Type: text/x-patch
Size: 942 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210310/cd1eff78/attachment.bin>


More information about the llvm-commits mailing list