about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2022-02-18 15:37:31 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2022-02-24 12:18:21 +0100
commit96cf7999ab64ead0c06384da51eb8586ffebfc1e (patch)
treecdfaed89f7ad40550e40560013125b9026d8a8b8 /compiler/rustc_codegen_gcc
parent0edcf1e2496caed074187c3c5ffac14537e633cf (diff)
downloadrust-96cf7999ab64ead0c06384da51eb8586ffebfc1e.tar.gz
rust-96cf7999ab64ead0c06384da51eb8586ffebfc1e.zip
Introduce Bx::switch_to_block
Diffstat (limited to 'compiler/rustc_codegen_gcc')
-rw-r--r--compiler/rustc_codegen_gcc/src/builder.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_gcc/src/builder.rs b/compiler/rustc_codegen_gcc/src/builder.rs
index a576291cd51..b430dc329cb 100644
--- a/compiler/rustc_codegen_gcc/src/builder.rs
+++ b/compiler/rustc_codegen_gcc/src/builder.rs
@@ -404,6 +404,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
         func.new_block(name)
     }
 
+    fn switch_to_block(&mut self, block: Self::BasicBlock) {
+        *self.cx.current_block.borrow_mut() = Some(block);
+        self.block = Some(block);
+    }
+
     fn ret_void(&mut self) {
         self.llbb().end_with_void_return(None)
     }
@@ -886,19 +891,20 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
 
         self.br(header_bb);
 
-        let mut header_bx = Builder::build(self.cx, header_bb);
-        let keep_going = header_bx.icmp(IntPredicate::IntNE, current_val, end);
-        header_bx.cond_br(keep_going, body_bb, next_bb);
+        self.switch_to_block(header_bb);
+        let keep_going = self.icmp(IntPredicate::IntNE, current_val, end);
+        self.cond_br(keep_going, body_bb, next_bb);
 
-        let mut body_bx = Builder::build(self.cx, body_bb);
+        self.switch_to_block(body_bb);
         let align = dest.align.restrict_for_offset(dest.layout.field(self.cx(), 0).size);
-        cg_elem.val.store(&mut body_bx, PlaceRef::new_sized_aligned(current_val, cg_elem.layout, align));
+        cg_elem.val.store(&mut self, PlaceRef::new_sized_aligned(current_val, cg_elem.layout, align));
 
-        let next = body_bx.inbounds_gep(self.backend_type(cg_elem.layout), current.to_rvalue(), &[self.const_usize(1)]);
-        body_bx.llbb().add_assignment(None, current, next);
-        body_bx.br(header_bb);
+        let next = self.inbounds_gep(self.backend_type(cg_elem.layout), current.to_rvalue(), &[self.const_usize(1)]);
+        self.llbb().add_assignment(None, current, next);
+        self.br(header_bb);
 
-        Builder::build(self.cx, next_bb)
+        self.switch_to_block(next_bb);
+        self
     }
 
     fn range_metadata(&mut self, _load: RValue<'gcc>, _range: WrappingRange) {