Skip to content

Commit 4a89c9f

Browse files
committed
Remove duplicated to_llvm_code_model function
1 parent b99a08a commit 4a89c9f

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

src/librustc_codegen_llvm/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ fn to_llvm_relocation_model(relocation_model: RelocModel) -> llvm::RelocModel {
108108
}
109109
}
110110

111-
fn to_llvm_code_model(code_model: Option<CodeModel>) -> llvm::CodeModel {
111+
pub fn to_llvm_code_model(code_model: Option<CodeModel>) -> llvm::CodeModel {
112112
match code_model {
113113
Some(CodeModel::Tiny) => llvm::CodeModel::Tiny,
114114
Some(CodeModel::Small) => llvm::CodeModel::Small,

src/librustc_codegen_llvm/context.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::attributes;
2+
use crate::back::write::to_llvm_code_model;
23
use crate::callee::get_fn;
34
use crate::coverageinfo;
45
use crate::debuginfo;
@@ -22,7 +23,7 @@ use rustc_session::Session;
2223
use rustc_span::source_map::{Span, DUMMY_SP};
2324
use rustc_span::symbol::Symbol;
2425
use rustc_target::abi::{HasDataLayout, LayoutOf, PointeeInfo, Size, TargetDataLayout, VariantIdx};
25-
use rustc_target::spec::{CodeModel, HasTargetSpec, RelocModel, Target, TlsModel};
26+
use rustc_target::spec::{HasTargetSpec, RelocModel, Target, TlsModel};
2627

2728
use std::cell::{Cell, RefCell};
2829
use std::ffi::CStr;
@@ -99,16 +100,6 @@ fn to_llvm_tls_model(tls_model: TlsModel) -> llvm::ThreadLocalMode {
99100
}
100101
}
101102

102-
fn to_llvm_code_model(code_model: CodeModel) -> llvm::CodeModel {
103-
match code_model {
104-
CodeModel::Tiny => llvm::CodeModel::Tiny,
105-
CodeModel::Small => llvm::CodeModel::Small,
106-
CodeModel::Kernel => llvm::CodeModel::Kernel,
107-
CodeModel::Medium => llvm::CodeModel::Medium,
108-
CodeModel::Large => llvm::CodeModel::Large,
109-
}
110-
}
111-
112103
fn strip_function_ptr_alignment(data_layout: String) -> String {
113104
// FIXME: Make this more general.
114105
data_layout.replace("-Fi8-", "-")
@@ -191,9 +182,7 @@ pub unsafe fn create_module(
191182
}
192183
}
193184

194-
if let Some(code_model) = sess.code_model() {
195-
llvm::LLVMRustSetModuleCodeModel(llmod, to_llvm_code_model(code_model));
196-
}
185+
llvm::LLVMRustSetModuleCodeModel(llmod, to_llvm_code_model(sess.code_model()));
197186

198187
// If skipping the PLT is enabled, we need to add some module metadata
199188
// to ensure intrinsic calls don't use it.

0 commit comments

Comments
 (0)