File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -215,6 +215,16 @@ class LLVMTargetInfo {
215215 * \return `llvm::TargetOptions` object for this target
216216 */
217217 const llvm::TargetOptions& GetTargetOptions () const { return target_options_; }
218+ /* !
219+ * \brief Get the LLVM target reloc model
220+ * \return `llvm::Reloc::Model` object for this target
221+ */
222+ const llvm::Reloc::Model& GetTargetRelocModel () const { return reloc_model_; }
223+ /* !
224+ * \brief Get the LLVM target code model
225+ * \return `llvm::CodeModel::Model` object for this target
226+ */
227+ const llvm::CodeModel::Model& GetTargetCodeModel () const { return code_model_; }
218228 /* !
219229 * \brief Get fast math flags
220230 * \return `llvm::FastMathFlags` for this target
Original file line number Diff line number Diff line change @@ -482,6 +482,14 @@ void LLVMModuleNode::InitORCJIT() {
482482 tm_builder.setCodeGenOptLevel (llvm::CodeGenOptLevel::Aggressive);
483483#endif
484484
485+ // Default is no explicit JIT code & reloc model
486+ // Propagate instance code & reloc for RISCV case.
487+ auto arch = tm_builder.getTargetTriple ().getArch ();
488+ if (arch == llvm::Triple::riscv32 || arch == llvm::Triple::riscv64) {
489+ tm_builder.setRelocationModel (llvm_target->GetTargetRelocModel ());
490+ tm_builder.setCodeModel (llvm_target->GetTargetCodeModel ());
491+ }
492+
485493 // create the taget machine
486494 std::unique_ptr<llvm::TargetMachine> tm = llvm::cantFail (tm_builder.createTargetMachine ());
487495 if (!IsCompatibleWithHost (tm.get ())) {
You can’t perform that action at this time.
0 commit comments