@@ -390,11 +390,6 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
390390 bx
391391 }
392392
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-
398393 fn llbb ( & self ) -> Block < ' gcc > {
399394 self . block . expect ( "block" )
400395 }
@@ -409,6 +404,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
409404 func. new_block ( name)
410405 }
411406
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+
412412 fn ret_void ( & mut self ) {
413413 self . llbb ( ) . end_with_void_return ( None )
414414 }
@@ -747,28 +747,31 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
747747 let start = dest. project_index ( & mut self , zero) . llval ;
748748 let end = dest. project_index ( & mut self , count) . llval ;
749749
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" ) ;
753753
754754 let ptr_type = start. get_type ( ) ;
755755 let current = self . llbb ( ) . get_function ( ) . new_local ( None , ptr_type, "loop_var" ) ;
756756 let current_val = current. to_rvalue ( ) ;
757757 self . assign ( current, start) ;
758758
759- self . br ( header_bx . llbb ( ) ) ;
759+ self . br ( header_bb ) ;
760760
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) ;
763764
765+ self . switch_to_block ( body_bb) ;
764766 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) ) ;
766768
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 ) ;
770772
771- next_bx
773+ self . switch_to_block ( next_bb) ;
774+ self
772775 }
773776
774777 fn range_metadata ( & mut self , _load : RValue < ' gcc > , _range : WrappingRange ) {
0 commit comments