@@ -96,9 +96,10 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
96
96
97
97
debug ! ( "llblock: creating cleanup trampoline for {:?}" , target) ;
98
98
let name = & format ! ( "{:?}_cleanup_trampoline_{:?}" , self . bb, target) ;
99
- let mut trampoline = fx. new_block ( name) ;
100
- trampoline. cleanup_ret ( self . funclet ( fx) . unwrap ( ) , Some ( lltarget) ) ;
101
- trampoline. llbb ( )
99
+ let trampoline = Bx :: append_block ( fx. cx , fx. llfn , name) ;
100
+ let mut trampoline_bx = Bx :: build ( fx. cx , trampoline) ;
101
+ trampoline_bx. cleanup_ret ( self . funclet ( fx) . unwrap ( ) , Some ( lltarget) ) ;
102
+ trampoline
102
103
} else {
103
104
lltarget
104
105
}
@@ -1358,16 +1359,20 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1358
1359
// bar();
1359
1360
// }
1360
1361
Some ( & mir:: TerminatorKind :: Abort ) => {
1361
- let mut cs_bx = self . new_block ( & format ! ( "cs_funclet{:?}" , bb) ) ;
1362
- let mut cp_bx = self . new_block ( & format ! ( "cp_funclet{:?}" , bb) ) ;
1363
- ret_llbb = cs_bx. llbb ( ) ;
1362
+ let cs_bb =
1363
+ Bx :: append_block ( self . cx , self . llfn , & format ! ( "cs_funclet{:?}" , bb) ) ;
1364
+ let cp_bb =
1365
+ Bx :: append_block ( self . cx , self . llfn , & format ! ( "cp_funclet{:?}" , bb) ) ;
1366
+ ret_llbb = cs_bb;
1364
1367
1365
- let cs = cs_bx. catch_switch ( None , None , & [ cp_bx. llbb ( ) ] ) ;
1368
+ let mut cs_bx = Bx :: build ( self . cx , cs_bb) ;
1369
+ let cs = cs_bx. catch_switch ( None , None , & [ cp_bb] ) ;
1366
1370
1367
1371
// The "null" here is actually a RTTI type descriptor for the
1368
1372
// C++ personality function, but `catch (...)` has no type so
1369
1373
// it's null. The 64 here is actually a bitfield which
1370
1374
// represents that this is a catch-all block.
1375
+ let mut cp_bx = Bx :: build ( self . cx , cp_bb) ;
1371
1376
let null = cp_bx. const_null (
1372
1377
cp_bx. type_i8p_ext ( cp_bx. cx ( ) . data_layout ( ) . instruction_address_space ) ,
1373
1378
) ;
@@ -1376,16 +1381,19 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1376
1381
cp_bx. br ( llbb) ;
1377
1382
}
1378
1383
_ => {
1379
- let mut cleanup_bx = self . new_block ( & format ! ( "funclet_{:?}" , bb) ) ;
1380
- ret_llbb = cleanup_bx. llbb ( ) ;
1384
+ let cleanup_bb =
1385
+ Bx :: append_block ( self . cx , self . llfn , & format ! ( "funclet_{:?}" , bb) ) ;
1386
+ ret_llbb = cleanup_bb;
1387
+ let mut cleanup_bx = Bx :: build ( self . cx , cleanup_bb) ;
1381
1388
funclet = cleanup_bx. cleanup_pad ( None , & [ ] ) ;
1382
1389
cleanup_bx. br ( llbb) ;
1383
1390
}
1384
1391
}
1385
1392
self . funclets [ bb] = Some ( funclet) ;
1386
1393
ret_llbb
1387
1394
} else {
1388
- let mut bx = self . new_block ( "cleanup" ) ;
1395
+ let bb = Bx :: append_block ( self . cx , self . llfn , "cleanup" ) ;
1396
+ let mut bx = Bx :: build ( self . cx , bb) ;
1389
1397
1390
1398
let llpersonality = self . cx . eh_personality ( ) ;
1391
1399
let llretty = self . landing_pad_type ( ) ;
@@ -1407,18 +1415,20 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1407
1415
1408
1416
fn unreachable_block ( & mut self ) -> Bx :: BasicBlock {
1409
1417
self . unreachable_block . unwrap_or_else ( || {
1410
- let mut bx = self . new_block ( "unreachable" ) ;
1418
+ let llbb = Bx :: append_block ( self . cx , self . llfn , "unreachable" ) ;
1419
+ let mut bx = Bx :: build ( self . cx , llbb) ;
1411
1420
bx. unreachable ( ) ;
1412
- self . unreachable_block = Some ( bx . llbb ( ) ) ;
1413
- bx . llbb ( )
1421
+ self . unreachable_block = Some ( llbb) ;
1422
+ llbb
1414
1423
} )
1415
1424
}
1416
1425
1417
1426
fn double_unwind_guard ( & mut self ) -> Bx :: BasicBlock {
1418
1427
self . double_unwind_guard . unwrap_or_else ( || {
1419
1428
assert ! ( !base:: wants_msvc_seh( self . cx. sess( ) ) ) ;
1420
1429
1421
- let mut bx = self . new_block ( "abort" ) ;
1430
+ let llbb = Bx :: append_block ( self . cx , self . llfn , "abort" ) ;
1431
+ let mut bx = Bx :: build ( self . cx , llbb) ;
1422
1432
self . set_debug_loc ( & mut bx, mir:: SourceInfo :: outermost ( self . mir . span ) ) ;
1423
1433
1424
1434
let llpersonality = self . cx . eh_personality ( ) ;
@@ -1436,20 +1446,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1436
1446
bx. apply_attrs_to_cleanup_callsite ( llret) ;
1437
1447
1438
1448
bx. unreachable ( ) ;
1439
- let llbb = bx. llbb ( ) ;
1440
1449
1441
1450
self . double_unwind_guard = Some ( llbb) ;
1442
1451
llbb
1443
1452
} )
1444
1453
}
1445
1454
1446
- // FIXME(eddyb) replace with `append_sibling_block`
1447
- // (which requires having a `Bx` already, and not all callers do).
1448
- fn new_block ( & self , name : & str ) -> Bx {
1449
- let llbb = Bx :: append_block ( self . cx , self . llfn , name) ;
1450
- Bx :: build ( self . cx , llbb)
1451
- }
1452
-
1453
1455
/// Get the backend `BasicBlock` for a MIR `BasicBlock`, either already
1454
1456
/// cached in `self.cached_llbbs`, or created on demand (and cached).
1455
1457
// FIXME(eddyb) rename `llbb` and other `ll`-prefixed things to use a
0 commit comments