Skip to content

Commit 251831e

Browse files
committed
Auto merge of #103138 - nnethercote:merge-BBs, r=bjorn3
Merge basic blocks where possible when generating LLVM IR. r? `@ghost`
2 parents bebd57a + 54082dd commit 251831e

File tree

9 files changed

+427
-352
lines changed

9 files changed

+427
-352
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) {

compiler/rustc_codegen_ssa/src/lib.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2-
#![feature(box_patterns)]
3-
#![feature(try_blocks)]
4-
#![feature(once_cell)]
52
#![feature(associated_type_bounds)]
6-
#![feature(strict_provenance)]
7-
#![feature(int_roundings)]
3+
#![feature(box_patterns)]
84
#![feature(if_let_guard)]
5+
#![feature(int_roundings)]
6+
#![feature(let_chains)]
97
#![feature(never_type)]
8+
#![feature(once_cell)]
9+
#![feature(strict_provenance)]
10+
#![feature(try_blocks)]
1011
#![recursion_limit = "256"]
1112
#![allow(rustc::potential_query_instability)]
1213

0 commit comments

Comments
 (0)