Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLVM][RUNTIME] Fix RISC-V CodeModel propagation to ORCJIT runtime executor #17347

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/target/llvm/llvm_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ class LLVMTargetInfo {
* \return `llvm::TargetOptions` object for this target
*/
const llvm::TargetOptions& GetTargetOptions() const { return target_options_; }
/*!
* \brief Get the LLVM target reloc model
* \return `llvm::Reloc::Model` object for this target
*/
const llvm::Reloc::Model& GetTargetRelocModel() const { return reloc_model_; }
/*!
* \brief Get the LLVM target code model
* \return `llvm::CodeModel::Model` object for this target
*/
const llvm::CodeModel::Model& GetTargetCodeModel() const { return code_model_; }
/*!
* \brief Get fast math flags
* \return `llvm::FastMathFlags` for this target
Expand Down
8 changes: 8 additions & 0 deletions src/target/llvm/llvm_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,14 @@ void LLVMModuleNode::InitORCJIT() {
tm_builder.setCodeGenOptLevel(llvm::CodeGenOptLevel::Aggressive);
#endif

// Default is no explicit JIT code & reloc model
// Propagate instance code & reloc for RISCV case.
auto arch = tm_builder.getTargetTriple().getArch();
if (arch == llvm::Triple::riscv32 || arch == llvm::Triple::riscv64) {
tm_builder.setRelocationModel(llvm_target->GetTargetRelocModel());
tm_builder.setCodeModel(llvm_target->GetTargetCodeModel());
}

// create the taget machine
std::unique_ptr<llvm::TargetMachine> tm = llvm::cantFail(tm_builder.createTargetMachine());
if (!IsCompatibleWithHost(tm.get())) {
Expand Down
Loading