@@ -390,11 +390,6 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
390
390
bx
391
391
}
392
392
393
- fn build_sibling_block ( & mut self , name : & str ) -> Self {
394
- let block = self . append_sibling_block ( name) ;
395
- Self :: build ( self . cx , block)
396
- }
397
-
398
393
fn llbb ( & self ) -> Block < ' gcc > {
399
394
self . block . expect ( "block" )
400
395
}
@@ -409,6 +404,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
409
404
func. new_block ( name)
410
405
}
411
406
407
+ fn switch_to_block ( & mut self , block : Self :: BasicBlock ) {
408
+ * self . cx . current_block . borrow_mut ( ) = Some ( block) ;
409
+ self . block = Some ( block) ;
410
+ }
411
+
412
412
fn ret_void ( & mut self ) {
413
413
self . llbb ( ) . end_with_void_return ( None )
414
414
}
@@ -747,28 +747,31 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
747
747
let start = dest. project_index ( & mut self , zero) . llval ;
748
748
let end = dest. project_index ( & mut self , count) . llval ;
749
749
750
- let mut header_bx = self . build_sibling_block ( "repeat_loop_header" ) ;
751
- let mut body_bx = self . build_sibling_block ( "repeat_loop_body" ) ;
752
- let next_bx = self . build_sibling_block ( "repeat_loop_next" ) ;
750
+ let header_bb = self . append_sibling_block ( "repeat_loop_header" ) ;
751
+ let body_bb = self . append_sibling_block ( "repeat_loop_body" ) ;
752
+ let next_bb = self . append_sibling_block ( "repeat_loop_next" ) ;
753
753
754
754
let ptr_type = start. get_type ( ) ;
755
755
let current = self . llbb ( ) . get_function ( ) . new_local ( None , ptr_type, "loop_var" ) ;
756
756
let current_val = current. to_rvalue ( ) ;
757
757
self . assign ( current, start) ;
758
758
759
- self . br ( header_bx . llbb ( ) ) ;
759
+ self . br ( header_bb ) ;
760
760
761
- let keep_going = header_bx. icmp ( IntPredicate :: IntNE , current_val, end) ;
762
- header_bx. cond_br ( keep_going, body_bx. llbb ( ) , next_bx. llbb ( ) ) ;
761
+ self . switch_to_block ( header_bb) ;
762
+ let keep_going = self . icmp ( IntPredicate :: IntNE , current_val, end) ;
763
+ self . cond_br ( keep_going, body_bb, next_bb) ;
763
764
765
+ self . switch_to_block ( body_bb) ;
764
766
let align = dest. align . restrict_for_offset ( dest. layout . field ( self . cx ( ) , 0 ) . size ) ;
765
- cg_elem. val . store ( & mut body_bx , PlaceRef :: new_sized_aligned ( current_val, cg_elem. layout , align) ) ;
767
+ cg_elem. val . store ( & mut self , PlaceRef :: new_sized_aligned ( current_val, cg_elem. layout , align) ) ;
766
768
767
- let next = body_bx . inbounds_gep ( self . backend_type ( cg_elem. layout ) , current. to_rvalue ( ) , & [ self . const_usize ( 1 ) ] ) ;
768
- body_bx . llbb ( ) . add_assignment ( None , current, next) ;
769
- body_bx . br ( header_bx . llbb ( ) ) ;
769
+ let next = self . inbounds_gep ( self . backend_type ( cg_elem. layout ) , current. to_rvalue ( ) , & [ self . const_usize ( 1 ) ] ) ;
770
+ self . llbb ( ) . add_assignment ( None , current, next) ;
771
+ self . br ( header_bb ) ;
770
772
771
- next_bx
773
+ self . switch_to_block ( next_bb) ;
774
+ self
772
775
}
773
776
774
777
fn range_metadata ( & mut self , _load : RValue < ' gcc > , _range : WrappingRange ) {
0 commit comments