Skip to content

Commit 36f18f2

Browse files
committed
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).
1 parent f66e469 commit 36f18f2

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/librustc_codegen_llvm/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ impl ExtraBackendMethods for LlvmCodegenBackend {
120120
fn write_metadata<'b, 'gcx>(
121121
&self,
122122
tcx: TyCtxt<'b, 'gcx, 'gcx>,
123-
metadata: &ModuleLlvm
123+
metadata: &mut ModuleLlvm
124124
) -> EncodedMetadata {
125125
base::write_metadata(tcx, metadata)
126126
}
127-
fn codegen_allocator(&self, tcx: TyCtxt, mods: &ModuleLlvm, kind: AllocatorKind) {
127+
fn codegen_allocator(&self, tcx: TyCtxt, mods: &mut ModuleLlvm, kind: AllocatorKind) {
128128
unsafe { allocator::codegen(tcx, mods, kind) }
129129
}
130130
fn compile_codegen_unit<'a, 'tcx: 'a>(

src/librustc_codegen_ssa/base.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,9 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
551551
&["crate"],
552552
Some("metadata")).as_str()
553553
.to_string();
554-
let metadata_llvm_module = backend.new_metadata(tcx, &metadata_cgu_name);
554+
let mut metadata_llvm_module = backend.new_metadata(tcx, &metadata_cgu_name);
555555
let metadata = time(tcx.sess, "write metadata", || {
556-
backend.write_metadata(tcx, &metadata_llvm_module)
556+
backend.write_metadata(tcx, &mut metadata_llvm_module)
557557
});
558558
tcx.sess.profiler(|p| p.end_activity(ProfileCategory::Codegen));
559559

@@ -636,9 +636,9 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
636636
&["crate"],
637637
Some("allocator")).as_str()
638638
.to_string();
639-
let modules = backend.new_metadata(tcx, &llmod_id);
639+
let mut modules = backend.new_metadata(tcx, &llmod_id);
640640
time(tcx.sess, "write allocator module", || {
641-
backend.codegen_allocator(tcx, &modules, kind)
641+
backend.codegen_allocator(tcx, &mut modules, kind)
642642
});
643643

644644
Some(ModuleCodegen {

src/librustc_codegen_ssa/traits/backend.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Se
3636
fn write_metadata<'b, 'gcx>(
3737
&self,
3838
tcx: TyCtxt<'b, 'gcx, 'gcx>,
39-
metadata: &Self::Module,
39+
metadata: &mut Self::Module,
4040
) -> EncodedMetadata;
41-
fn codegen_allocator(&self, tcx: TyCtxt, mods: &Self::Module, kind: AllocatorKind);
41+
fn codegen_allocator(&self, tcx: TyCtxt, mods: &mut Self::Module, kind: AllocatorKind);
4242
fn compile_codegen_unit<'a, 'tcx: 'a>(
4343
&self,
4444
tcx: TyCtxt<'a, 'tcx, 'tcx>,

0 commit comments

Comments
 (0)