@@ -464,45 +464,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
464
464
}
465
465
466
466
impl < ' a , ' tcx > BuilderMethods < ' a , ' tcx > for Builder < ' a , ' tcx > {
467
- fn new_block < ' b > ( cx : & ' a Self :: CodegenCx , llfn : Self :: Function , _name : & ' b str ) -> Self {
468
- let cursor_fn = cx. builder . select_function_by_id ( llfn. def_cx ( cx) ) ;
469
- let label = cx. emit_with_cursor ( cursor_fn) . begin_block ( None ) . unwrap ( ) ;
470
- let cursor = cx. builder . select_block_by_id ( label) ;
467
+ fn build ( cx : & ' a Self :: CodegenCx , llbb : Self :: BasicBlock ) -> Self {
468
+ let cursor = cx. builder . select_block_by_id ( llbb) ;
469
+ // FIXME(eddyb) change `Self::Function` to be more like a function index.
470
+ let current_fn = {
471
+ let emit = cx. emit_with_cursor ( cursor) ;
472
+ let selected_function = emit. selected_function ( ) . unwrap ( ) ;
473
+ let selected_function = & emit. module_ref ( ) . functions [ selected_function] ;
474
+ let def_inst = selected_function. def . as_ref ( ) . unwrap ( ) ;
475
+ let def = def_inst. result_id . unwrap ( ) ;
476
+ let ty = def_inst. operands [ 1 ] . unwrap_id_ref ( ) ;
477
+ def. with_type ( ty)
478
+ } ;
471
479
Self {
472
480
cx,
473
481
cursor,
474
- current_fn : llfn,
475
- basic_block : label,
476
- current_span : Default :: default ( ) ,
477
- }
478
- }
479
-
480
- fn with_cx ( cx : & ' a Self :: CodegenCx ) -> Self {
481
- // Note: all defaults here *must* be filled out by position_at_end
482
- Self {
483
- cx,
484
- cursor : Default :: default ( ) ,
485
- current_fn : 0 . with_type ( 0 ) ,
486
- basic_block : Default :: default ( ) ,
487
- current_span : Default :: default ( ) ,
488
- }
489
- }
490
-
491
- fn build_sibling_block ( & self , _name : & str ) -> Self {
492
- let mut builder = self . emit_with_cursor ( BuilderCursor {
493
- function : self . cursor . function ,
494
- block : None ,
495
- } ) ;
496
- let new_bb = builder. begin_block ( None ) . unwrap ( ) ;
497
- let new_cursor = BuilderCursor {
498
- function : self . cursor . function ,
499
- block : builder. selected_block ( ) ,
500
- } ;
501
- Self {
502
- cx : self . cx ,
503
- cursor : new_cursor,
504
- current_fn : self . current_fn ,
505
- basic_block : new_bb,
482
+ current_fn,
483
+ basic_block : llbb,
506
484
current_span : Default :: default ( ) ,
507
485
}
508
486
}
@@ -525,20 +503,42 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
525
503
. line ( file, loc. line as u32 , loc. col_display as u32 ) ;
526
504
}
527
505
528
- fn position_at_end ( & mut self , llbb : Self :: BasicBlock ) {
529
- let cursor = self . cx . builder . select_block_by_id ( llbb) ;
530
- let current_fn = {
531
- let emit = self . emit_with_cursor ( cursor) ;
532
- let selected_function = emit. selected_function ( ) . unwrap ( ) ;
533
- let selected_function = & emit. module_ref ( ) . functions [ selected_function] ;
534
- let def_inst = selected_function. def . as_ref ( ) . unwrap ( ) ;
535
- let def = def_inst. result_id . unwrap ( ) ;
536
- let ty = def_inst. operands [ 1 ] . unwrap_id_ref ( ) ;
537
- def. with_type ( ty)
506
+ // FIXME(eddyb) change `Self::Function` to be more like a function index.
507
+ fn append_block (
508
+ cx : & ' a Self :: CodegenCx ,
509
+ llfn : Self :: Function ,
510
+ _name : & str ,
511
+ ) -> Self :: BasicBlock {
512
+ let cursor_fn = cx. builder . select_function_by_id ( llfn. def_cx ( cx) ) ;
513
+ cx. emit_with_cursor ( cursor_fn) . begin_block ( None ) . unwrap ( )
514
+ }
515
+
516
+ fn append_sibling_block ( & mut self , _name : & str ) -> Self :: BasicBlock {
517
+ self . emit_with_cursor ( BuilderCursor {
518
+ function : self . cursor . function ,
519
+ block : None ,
520
+ } )
521
+ . begin_block ( None )
522
+ . unwrap ( )
523
+ }
524
+
525
+ fn build_sibling_block ( & mut self , _name : & str ) -> Self {
526
+ let mut builder = self . emit_with_cursor ( BuilderCursor {
527
+ function : self . cursor . function ,
528
+ block : None ,
529
+ } ) ;
530
+ let new_bb = builder. begin_block ( None ) . unwrap ( ) ;
531
+ let new_cursor = BuilderCursor {
532
+ function : self . cursor . function ,
533
+ block : builder. selected_block ( ) ,
538
534
} ;
539
- self . cursor = cursor;
540
- self . current_fn = current_fn;
541
- self . basic_block = llbb;
535
+ Self {
536
+ cx : self . cx ,
537
+ cursor : new_cursor,
538
+ current_fn : self . current_fn ,
539
+ basic_block : new_bb,
540
+ current_span : Default :: default ( ) ,
541
+ }
542
542
}
543
543
544
544
fn ret_void ( & mut self ) {
@@ -2207,11 +2207,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
2207
2207
self . intcast ( val, dest_ty, false )
2208
2208
}
2209
2209
2210
- unsafe fn delete_basic_block ( & mut self , _bb : Self :: BasicBlock ) {
2211
- // Ignore: If we were to delete the block, then other builder's selected_block index would become invalid, due
2212
- // to shifting blocks.
2213
- }
2214
-
2215
2210
fn do_not_inline ( & mut self , _llret : Self :: Value ) {
2216
2211
// Ignore
2217
2212
}
0 commit comments