@@ -231,20 +231,23 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
231
231
lvalue. project_index ( & bcx, C_uint ( bcx. ccx , 0u64 ) ) ,
232
232
ety,
233
233
lvalue. len ( bcx. ccx ) ,
234
- |bcx, llval, loop_bb| {
234
+ |mut bcx, llval, loop_bb| {
235
235
self . set_debug_loc ( & bcx, terminator. source_info ) ;
236
236
if let Some ( unwind) = unwind {
237
- bcx. invoke (
237
+ let old_bcx = bcx;
238
+ bcx = old_bcx. build_sibling_block ( "drop-next" ) ;
239
+ old_bcx. invoke (
238
240
drop_fn,
239
241
& [ llval] ,
240
- loop_bb ,
241
- llblock ( self , unwind) ,
242
+ bcx . llbb ( ) ,
243
+ self . landing_pad_to ( unwind) ,
242
244
cleanup_bundle
243
245
) ;
244
246
} else {
245
247
bcx. call ( drop_fn, & [ llval] , cleanup_bundle) ;
246
- bcx. br ( loop_bb) ;
247
248
}
249
+ bcx. br ( loop_bb) ;
250
+ bcx
248
251
} ) ;
249
252
funclet_br ( self , bcx, target) ;
250
253
return
@@ -253,17 +256,19 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
253
256
} ;
254
257
let args = & [ lvalue. llval , lvalue. llextra ] [ ..1 + need_extra as usize ] ;
255
258
if let Some ( unwind) = unwind {
256
- bcx. invoke (
259
+ let old_bcx = bcx;
260
+ bcx = old_bcx. build_sibling_block ( "drop-next" ) ;
261
+ old_bcx. invoke (
257
262
drop_fn,
258
263
args,
259
- self . blocks [ target ] ,
260
- llblock ( self , unwind) ,
264
+ bcx . llbb ( ) ,
265
+ self . landing_pad_to ( unwind) ,
261
266
cleanup_bundle
262
267
) ;
263
268
} else {
264
269
bcx. call ( drop_fn, args, cleanup_bundle) ;
265
- funclet_br ( self , bcx, target) ;
266
270
}
271
+ funclet_br ( self , bcx, target) ;
267
272
}
268
273
269
274
mir:: TerminatorKind :: Assert { ref cond, expected, ref msg, target, cleanup } => {
@@ -297,12 +302,12 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
297
302
let cond = bcx. call ( expect, & [ cond, C_bool ( bcx. ccx , expected) ] , None ) ;
298
303
299
304
// Create the failure block and the conditional branch to it.
300
- let lltarget = llblock ( self , target ) ;
305
+ let success_block = self . new_block ( "success" ) ;
301
306
let panic_block = self . new_block ( "panic" ) ;
302
307
if expected {
303
- bcx. cond_br ( cond, lltarget , panic_block. llbb ( ) ) ;
308
+ bcx. cond_br ( cond, success_block . llbb ( ) , panic_block. llbb ( ) ) ;
304
309
} else {
305
- bcx. cond_br ( cond, panic_block. llbb ( ) , lltarget ) ;
310
+ bcx. cond_br ( cond, panic_block. llbb ( ) , success_block . llbb ( ) ) ;
306
311
}
307
312
308
313
// After this point, bcx is the block for the call to panic.
@@ -377,12 +382,14 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
377
382
bcx. invoke ( llfn,
378
383
& args,
379
384
self . unreachable_block ( ) ,
380
- llblock ( self , unwind) ,
385
+ self . landing_pad_to ( unwind) ,
381
386
cleanup_bundle) ;
382
387
} else {
383
388
bcx. call ( llfn, & args, cleanup_bundle) ;
384
389
bcx. unreachable ( ) ;
385
390
}
391
+
392
+ success_block. br ( self . blocks [ target] ) ;
386
393
}
387
394
388
395
mir:: TerminatorKind :: DropAndReplace { .. } => {
@@ -552,42 +559,33 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
552
559
_ => span_bug ! ( span, "no llfn for call" ) ,
553
560
} ;
554
561
555
- // Many different ways to call a function handled here
556
- if let & Some ( cleanup) = cleanup {
557
- let ret_bcx = if let Some ( ( _, target) ) = * destination {
558
- self . blocks [ target]
559
- } else {
560
- self . unreachable_block ( )
561
- } ;
562
- let invokeret = bcx. invoke ( fn_ptr,
563
- & llargs,
564
- ret_bcx,
565
- llblock ( self , cleanup) ,
566
- cleanup_bundle) ;
567
- fn_ty. apply_attrs_callsite ( invokeret) ;
562
+ let llret = if let & Some ( cleanup) = cleanup {
563
+ let old_bcx = bcx;
564
+ bcx = old_bcx. build_sibling_block ( "call-next" ) ;
565
+ self . set_debug_loc ( & bcx, terminator. source_info ) ;
566
+ old_bcx. invoke (
567
+ fn_ptr,
568
+ & llargs,
569
+ bcx. llbb ( ) ,
570
+ self . landing_pad_to ( cleanup) ,
571
+ cleanup_bundle,
572
+ )
573
+ } else {
574
+ bcx. call ( fn_ptr, & llargs, cleanup_bundle)
575
+ } ;
568
576
569
- if let Some ( ( _, target) ) = * destination {
570
- let ret_bcx = self . get_builder ( target) ;
571
- self . set_debug_loc ( & ret_bcx, terminator. source_info ) ;
572
- let op = OperandRef {
573
- val : Immediate ( invokeret) ,
574
- ty : sig. output ( ) ,
575
- } ;
576
- self . store_return ( & ret_bcx, ret_dest, fn_ty. ret , op) ;
577
- }
577
+ fn_ty. apply_attrs_callsite ( llret) ;
578
+
579
+ let op = OperandRef {
580
+ val : Immediate ( llret) ,
581
+ ty : sig. output ( ) ,
582
+ } ;
583
+ self . store_return ( & bcx, ret_dest, fn_ty. ret , op) ;
584
+
585
+ if let Some ( ( _, target) ) = * destination {
586
+ funclet_br ( self , bcx, target) ;
578
587
} else {
579
- let llret = bcx. call ( fn_ptr, & llargs, cleanup_bundle) ;
580
- fn_ty. apply_attrs_callsite ( llret) ;
581
- if let Some ( ( _, target) ) = * destination {
582
- let op = OperandRef {
583
- val : Immediate ( llret) ,
584
- ty : sig. output ( ) ,
585
- } ;
586
- self . store_return ( & bcx, ret_dest, fn_ty. ret , op) ;
587
- funclet_br ( self , bcx, target) ;
588
- } else {
589
- bcx. unreachable ( ) ;
590
- }
588
+ bcx. unreachable ( ) ;
591
589
}
592
590
}
593
591
}
0 commit comments