Skip to content

Commit 68194aa

Browse files
committed
Use &mut Bx more.
For the next commit, `FunctionCx::codegen_*_terminator` need to take a `&mut Bx` instead of consuming a `Bx`. This triggers a cascade of similar changes across multiple functions. The resulting code is more concise and replaces many `&mut bx` expressions with `bx`.
1 parent a00f8ba commit 68194aa

File tree

6 files changed

+176
-218
lines changed

6 files changed

+176
-218
lines changed

compiler/rustc_codegen_gcc/src/builder.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -755,11 +755,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
755755
OperandRef { val, layout: place.layout }
756756
}
757757

758-
fn write_operand_repeatedly(mut self, cg_elem: OperandRef<'tcx, RValue<'gcc>>, count: u64, dest: PlaceRef<'tcx, RValue<'gcc>>) -> Self {
758+
fn write_operand_repeatedly(&mut self, cg_elem: OperandRef<'tcx, RValue<'gcc>>, count: u64, dest: PlaceRef<'tcx, RValue<'gcc>>) {
759759
let zero = self.const_usize(0);
760760
let count = self.const_usize(count);
761-
let start = dest.project_index(&mut self, zero).llval;
762-
let end = dest.project_index(&mut self, count).llval;
761+
let start = dest.project_index(self, zero).llval;
762+
let end = dest.project_index(self, count).llval;
763763

764764
let header_bb = self.append_sibling_block("repeat_loop_header");
765765
let body_bb = self.append_sibling_block("repeat_loop_body");
@@ -778,14 +778,13 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
778778

779779
self.switch_to_block(body_bb);
780780
let align = dest.align.restrict_for_offset(dest.layout.field(self.cx(), 0).size);
781-
cg_elem.val.store(&mut self, PlaceRef::new_sized_aligned(current_val, cg_elem.layout, align));
781+
cg_elem.val.store(self, PlaceRef::new_sized_aligned(current_val, cg_elem.layout, align));
782782

783783
let next = self.inbounds_gep(self.backend_type(cg_elem.layout), current.to_rvalue(), &[self.const_usize(1)]);
784784
self.llbb().add_assignment(None, current, next);
785785
self.br(header_bb);
786786

787787
self.switch_to_block(next_bb);
788-
self
789788
}
790789

791790
fn range_metadata(&mut self, _load: RValue<'gcc>, _range: WrappingRange) {

compiler/rustc_codegen_llvm/src/builder.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -556,15 +556,15 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
556556
}
557557

558558
fn write_operand_repeatedly(
559-
mut self,
559+
&mut self,
560560
cg_elem: OperandRef<'tcx, &'ll Value>,
561561
count: u64,
562562
dest: PlaceRef<'tcx, &'ll Value>,
563-
) -> Self {
563+
) {
564564
let zero = self.const_usize(0);
565565
let count = self.const_usize(count);
566-
let start = dest.project_index(&mut self, zero).llval;
567-
let end = dest.project_index(&mut self, count).llval;
566+
let start = dest.project_index(self, zero).llval;
567+
let end = dest.project_index(self, count).llval;
568568

569569
let header_bb = self.append_sibling_block("repeat_loop_header");
570570
let body_bb = self.append_sibling_block("repeat_loop_body");
@@ -592,7 +592,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
592592
body_bx.br(header_bb);
593593
header_bx.add_incoming_to_phi(current, next, body_bb);
594594

595-
Self::build(self.cx, next_bb)
595+
*self = Self::build(self.cx, next_bb);
596596
}
597597

598598
fn range_metadata(&mut self, load: &'ll Value, range: WrappingRange) {

0 commit comments

Comments
 (0)