Allow Self::Module to be mutated.
`codegen_allocator` and `write_metadata` mutate the underlying LLVM module. As such, it makes sense for these two functions to receive a mutable reference to the module (as opposed to an immutable one).
This commit is contained in:
parent
f66e4697ae
commit
36f18f2d3a
3 changed files with 8 additions and 8 deletions
|
@ -120,11 +120,11 @@ impl ExtraBackendMethods for LlvmCodegenBackend {
|
|||
fn write_metadata<'b, 'gcx>(
|
||||
&self,
|
||||
tcx: TyCtxt<'b, 'gcx, 'gcx>,
|
||||
metadata: &ModuleLlvm
|
||||
metadata: &mut ModuleLlvm
|
||||
) -> EncodedMetadata {
|
||||
base::write_metadata(tcx, metadata)
|
||||
}
|
||||
fn codegen_allocator(&self, tcx: TyCtxt, mods: &ModuleLlvm, kind: AllocatorKind) {
|
||||
fn codegen_allocator(&self, tcx: TyCtxt, mods: &mut ModuleLlvm, kind: AllocatorKind) {
|
||||
unsafe { allocator::codegen(tcx, mods, kind) }
|
||||
}
|
||||
fn compile_codegen_unit<'a, 'tcx: 'a>(
|
||||
|
|
|
@ -551,9 +551,9 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
|||
&["crate"],
|
||||
Some("metadata")).as_str()
|
||||
.to_string();
|
||||
let metadata_llvm_module = backend.new_metadata(tcx, &metadata_cgu_name);
|
||||
let mut metadata_llvm_module = backend.new_metadata(tcx, &metadata_cgu_name);
|
||||
let metadata = time(tcx.sess, "write metadata", || {
|
||||
backend.write_metadata(tcx, &metadata_llvm_module)
|
||||
backend.write_metadata(tcx, &mut metadata_llvm_module)
|
||||
});
|
||||
tcx.sess.profiler(|p| p.end_activity(ProfileCategory::Codegen));
|
||||
|
||||
|
@ -636,9 +636,9 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
|||
&["crate"],
|
||||
Some("allocator")).as_str()
|
||||
.to_string();
|
||||
let modules = backend.new_metadata(tcx, &llmod_id);
|
||||
let mut modules = backend.new_metadata(tcx, &llmod_id);
|
||||
time(tcx.sess, "write allocator module", || {
|
||||
backend.codegen_allocator(tcx, &modules, kind)
|
||||
backend.codegen_allocator(tcx, &mut modules, kind)
|
||||
});
|
||||
|
||||
Some(ModuleCodegen {
|
||||
|
|
|
@ -36,9 +36,9 @@ pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Se
|
|||
fn write_metadata<'b, 'gcx>(
|
||||
&self,
|
||||
tcx: TyCtxt<'b, 'gcx, 'gcx>,
|
||||
metadata: &Self::Module,
|
||||
metadata: &mut Self::Module,
|
||||
) -> EncodedMetadata;
|
||||
fn codegen_allocator(&self, tcx: TyCtxt, mods: &Self::Module, kind: AllocatorKind);
|
||||
fn codegen_allocator(&self, tcx: TyCtxt, mods: &mut Self::Module, kind: AllocatorKind);
|
||||
fn compile_codegen_unit<'a, 'tcx: 'a>(
|
||||
&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue