[Lldb-commits] [PATCH] D62273: Expression: correct relocation model for Windows

Saleem Abdulrasool via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed May 22 16:04:16 PDT 2019


compnerd created this revision.
compnerd added reviewers: aprantl, JDevlieghere, labath, clayborg, xiaobai, davide.
Herald added a project: LLDB.

The Windows CG model cannot generate code with the PIC relocation model as all code is implicitly PIC.  Invert the condition and inline the single use.  This improves expression handling on Windows.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D62273

Files:
  source/Expression/IRExecutionUnit.cpp


Index: source/Expression/IRExecutionUnit.cpp
===================================================================
--- source/Expression/IRExecutionUnit.cpp
+++ source/Expression/IRExecutionUnit.cpp
@@ -258,23 +258,17 @@
     log->Printf("Module being sent to JIT: \n%s", s.c_str());
   }

-  llvm::Triple triple(m_module->getTargetTriple());
-  llvm::Reloc::Model relocModel;
-
-  if (triple.isOSBinFormatELF()) {
-    relocModel = llvm::Reloc::Static;
-  } else {
-    relocModel = llvm::Reloc::PIC_;
-  }
-
   m_module_up->getContext().setInlineAsmDiagnosticHandler(ReportInlineAsmError,
                                                           &error);

   llvm::EngineBuilder builder(std::move(m_module_up));
+  llvm::Triple triple(m_module->getTargetTriple());

   builder.setEngineKind(llvm::EngineKind::JIT)
       .setErrorStr(&error_string)
-      .setRelocationModel(relocModel)
+      .setRelocationModel(triple.isOSBinFormatMacho()
+                              ? llvm::Reloc::PIC_
+                              : llvm::Reloc::Static)
       .setMCJITMemoryManager(
           std::unique_ptr<MemoryManager>(new MemoryManager(*this)))
       .setOptLevel(llvm::CodeGenOpt::Less);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62273.200834.patch
Type: text/x-patch
Size: 1195 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190522/d2a019fd/attachment.bin>


More information about the lldb-commits mailing list