Merge new_metadata into codegen_allocator
This commit is contained in:
parent
fab72301d9
commit
78c65a52db
5 changed files with 15 additions and 29 deletions
|
@ -139,14 +139,12 @@ impl CodegenBackend for GccCodegenBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExtraBackendMethods for GccCodegenBackend {
|
impl ExtraBackendMethods for GccCodegenBackend {
|
||||||
fn new_metadata<'tcx>(&self, _tcx: TyCtxt<'tcx>, _mod_name: &str) -> Self::Module {
|
fn codegen_allocator<'tcx>(&self, tcx: TyCtxt<'tcx>, module_name: &str, kind: AllocatorKind, has_alloc_error_handler: bool) -> Self::Module {
|
||||||
GccContext {
|
let mut mods = GccContext {
|
||||||
context: Context::default(),
|
context: Context::default(),
|
||||||
}
|
};
|
||||||
}
|
unsafe { allocator::codegen(tcx, &mut mods, module_name, kind, has_alloc_error_handler); }
|
||||||
|
mods
|
||||||
fn codegen_allocator<'tcx>(&self, tcx: TyCtxt<'tcx>, mods: &mut Self::Module, module_name: &str, kind: AllocatorKind, has_alloc_error_handler: bool) {
|
|
||||||
unsafe { allocator::codegen(tcx, mods, module_name, kind, has_alloc_error_handler) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compile_codegen_unit<'tcx>(&self, tcx: TyCtxt<'tcx>, cgu_name: Symbol) -> (ModuleCodegen<Self::Module>, u64) {
|
fn compile_codegen_unit<'tcx>(&self, tcx: TyCtxt<'tcx>, cgu_name: Symbol) -> (ModuleCodegen<Self::Module>, u64) {
|
||||||
|
|
|
@ -104,19 +104,18 @@ impl Drop for TimeTraceProfiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExtraBackendMethods for LlvmCodegenBackend {
|
impl ExtraBackendMethods for LlvmCodegenBackend {
|
||||||
fn new_metadata(&self, tcx: TyCtxt<'_>, mod_name: &str) -> ModuleLlvm {
|
|
||||||
ModuleLlvm::new_metadata(tcx, mod_name)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn codegen_allocator<'tcx>(
|
fn codegen_allocator<'tcx>(
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
module_llvm: &mut ModuleLlvm,
|
|
||||||
module_name: &str,
|
module_name: &str,
|
||||||
kind: AllocatorKind,
|
kind: AllocatorKind,
|
||||||
has_alloc_error_handler: bool,
|
has_alloc_error_handler: bool,
|
||||||
) {
|
) -> ModuleLlvm {
|
||||||
unsafe { allocator::codegen(tcx, module_llvm, module_name, kind, has_alloc_error_handler) }
|
let mut module_llvm = ModuleLlvm::new_metadata(tcx, module_name);
|
||||||
|
unsafe {
|
||||||
|
allocator::codegen(tcx, &mut module_llvm, module_name, kind, has_alloc_error_handler);
|
||||||
|
}
|
||||||
|
module_llvm
|
||||||
}
|
}
|
||||||
fn compile_codegen_unit(
|
fn compile_codegen_unit(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
@ -69,9 +69,7 @@ impl<B: WriteBackendMethods> LtoModuleCodegen<B> {
|
||||||
) -> Result<ModuleCodegen<B::Module>, FatalError> {
|
) -> Result<ModuleCodegen<B::Module>, FatalError> {
|
||||||
match self {
|
match self {
|
||||||
LtoModuleCodegen::Fat { mut module, .. } => {
|
LtoModuleCodegen::Fat { mut module, .. } => {
|
||||||
{
|
B::optimize_fat(cgcx, &mut module)?;
|
||||||
B::optimize_fat(cgcx, &mut module)?;
|
|
||||||
}
|
|
||||||
Ok(module)
|
Ok(module)
|
||||||
}
|
}
|
||||||
LtoModuleCodegen::Thin(thin) => B::optimize_thin(cgcx, thin),
|
LtoModuleCodegen::Thin(thin) => B::optimize_thin(cgcx, thin),
|
||||||
|
|
|
@ -575,15 +575,8 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
||||||
} else if let Some(kind) = tcx.allocator_kind(()) {
|
} else if let Some(kind) = tcx.allocator_kind(()) {
|
||||||
let llmod_id =
|
let llmod_id =
|
||||||
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string();
|
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string();
|
||||||
let mut module_llvm = backend.new_metadata(tcx, &llmod_id);
|
let module_llvm = tcx.sess.time("write_allocator_module", || {
|
||||||
tcx.sess.time("write_allocator_module", || {
|
backend.codegen_allocator(tcx, &llmod_id, kind, tcx.lang_items().oom().is_some())
|
||||||
backend.codegen_allocator(
|
|
||||||
tcx,
|
|
||||||
&mut module_llvm,
|
|
||||||
&llmod_id,
|
|
||||||
kind,
|
|
||||||
tcx.lang_items().oom().is_some(),
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Some(ModuleCodegen { name: llmod_id, module_llvm, kind: ModuleKind::Allocator })
|
Some(ModuleCodegen { name: llmod_id, module_llvm, kind: ModuleKind::Allocator })
|
||||||
|
|
|
@ -114,15 +114,13 @@ pub trait CodegenBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Send + Sync {
|
pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Send + Sync {
|
||||||
fn new_metadata(&self, sess: TyCtxt<'_>, mod_name: &str) -> Self::Module;
|
|
||||||
fn codegen_allocator<'tcx>(
|
fn codegen_allocator<'tcx>(
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
module_llvm: &mut Self::Module,
|
|
||||||
module_name: &str,
|
module_name: &str,
|
||||||
kind: AllocatorKind,
|
kind: AllocatorKind,
|
||||||
has_alloc_error_handler: bool,
|
has_alloc_error_handler: bool,
|
||||||
);
|
) -> Self::Module;
|
||||||
/// This generates the codegen unit and returns it along with
|
/// This generates the codegen unit and returns it along with
|
||||||
/// a `u64` giving an estimate of the unit's processing cost.
|
/// a `u64` giving an estimate of the unit's processing cost.
|
||||||
fn compile_codegen_unit(
|
fn compile_codegen_unit(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue