@@ -452,11 +452,11 @@ fn codegen_msvc_try<'ll>(
452452 let ( llty, llfn) = get_rust_try_fn ( bx, & mut |mut bx| {
453453 bx. set_personality_fn ( bx. eh_personality ( ) ) ;
454454
455- let mut normal = bx. build_sibling_block ( "normal" ) ;
456- let mut catchswitch = bx. build_sibling_block ( "catchswitch" ) ;
457- let mut catchpad_rust = bx. build_sibling_block ( "catchpad_rust" ) ;
458- let mut catchpad_foreign = bx. build_sibling_block ( "catchpad_foreign" ) ;
459- let mut caught = bx. build_sibling_block ( "caught" ) ;
455+ let normal = bx. append_sibling_block ( "normal" ) ;
456+ let catchswitch = bx. append_sibling_block ( "catchswitch" ) ;
457+ let catchpad_rust = bx. append_sibling_block ( "catchpad_rust" ) ;
458+ let catchpad_foreign = bx. append_sibling_block ( "catchpad_foreign" ) ;
459+ let caught = bx. append_sibling_block ( "caught" ) ;
460460
461461 let try_func = llvm:: get_param ( bx. llfn ( ) , 0 ) ;
462462 let data = llvm:: get_param ( bx. llfn ( ) , 1 ) ;
@@ -520,12 +520,13 @@ fn codegen_msvc_try<'ll>(
520520 let ptr_align = bx. tcx ( ) . data_layout . pointer_align . abi ;
521521 let slot = bx. alloca ( bx. type_i8p ( ) , ptr_align) ;
522522 let try_func_ty = bx. type_func ( & [ bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
523- bx. invoke ( try_func_ty, try_func, & [ data] , normal. llbb ( ) , catchswitch. llbb ( ) , None ) ;
523+ bx. invoke ( try_func_ty, try_func, & [ data] , normal, catchswitch, None ) ;
524524
525+ let mut normal = Builder :: build ( bx. cx , normal) ;
525526 normal. ret ( bx. const_i32 ( 0 ) ) ;
526527
527- let cs =
528- catchswitch. catch_switch ( None , None , & [ catchpad_rust. llbb ( ) , catchpad_foreign. llbb ( ) ] ) ;
528+ let mut catchswitch = Builder :: build ( bx . cx , catchswitch ) ;
529+ let cs = catchswitch. catch_switch ( None , None , & [ catchpad_rust, catchpad_foreign] ) ;
529530
530531 // We can't use the TypeDescriptor defined in libpanic_unwind because it
531532 // might be in another DLL and the SEH encoding only supports specifying
@@ -558,20 +559,23 @@ fn codegen_msvc_try<'ll>(
558559 // since our exception object effectively contains a Box.
559560 //
560561 // Source: MicrosoftCXXABI::getAddrOfCXXCatchHandlerType in clang
562+ let mut catchpad_rust = Builder :: build ( bx. cx , catchpad_rust) ;
561563 let flags = bx. const_i32 ( 8 ) ;
562564 let funclet = catchpad_rust. catch_pad ( cs, & [ tydesc, flags, slot] ) ;
563565 let ptr = catchpad_rust. load ( bx. type_i8p ( ) , slot, ptr_align) ;
564566 let catch_ty = bx. type_func ( & [ bx. type_i8p ( ) , bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
565567 catchpad_rust. call ( catch_ty, catch_func, & [ data, ptr] , Some ( & funclet) ) ;
566- catchpad_rust. catch_ret ( & funclet, caught. llbb ( ) ) ;
568+ catchpad_rust. catch_ret ( & funclet, caught) ;
567569
568570 // The flag value of 64 indicates a "catch-all".
571+ let mut catchpad_foreign = Builder :: build ( bx. cx , catchpad_foreign) ;
569572 let flags = bx. const_i32 ( 64 ) ;
570573 let null = bx. const_null ( bx. type_i8p ( ) ) ;
571574 let funclet = catchpad_foreign. catch_pad ( cs, & [ null, flags, null] ) ;
572575 catchpad_foreign. call ( catch_ty, catch_func, & [ data, null] , Some ( & funclet) ) ;
573- catchpad_foreign. catch_ret ( & funclet, caught. llbb ( ) ) ;
576+ catchpad_foreign. catch_ret ( & funclet, caught) ;
574577
578+ let mut caught = Builder :: build ( bx. cx , caught) ;
575579 caught. ret ( bx. const_i32 ( 1 ) ) ;
576580 } ) ;
577581
@@ -613,14 +617,16 @@ fn codegen_gnu_try<'ll>(
613617 // (%ptr, _) = landingpad
614618 // call %catch_func(%data, %ptr)
615619 // ret 1
616- let mut then = bx. build_sibling_block ( "then" ) ;
617- let mut catch = bx. build_sibling_block ( "catch" ) ;
620+ let then = bx. append_sibling_block ( "then" ) ;
621+ let catch = bx. append_sibling_block ( "catch" ) ;
618622
619623 let try_func = llvm:: get_param ( bx. llfn ( ) , 0 ) ;
620624 let data = llvm:: get_param ( bx. llfn ( ) , 1 ) ;
621625 let catch_func = llvm:: get_param ( bx. llfn ( ) , 2 ) ;
622626 let try_func_ty = bx. type_func ( & [ bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
623- bx. invoke ( try_func_ty, try_func, & [ data] , then. llbb ( ) , catch. llbb ( ) , None ) ;
627+ bx. invoke ( try_func_ty, try_func, & [ data] , then, catch, None ) ;
628+
629+ let mut then = Builder :: build ( bx. cx , then) ;
624630 then. ret ( bx. const_i32 ( 0 ) ) ;
625631
626632 // Type indicator for the exception being thrown.
@@ -629,6 +635,7 @@ fn codegen_gnu_try<'ll>(
629635 // being thrown. The second value is a "selector" indicating which of
630636 // the landing pad clauses the exception's type had been matched to.
631637 // rust_try ignores the selector.
638+ let mut catch = Builder :: build ( bx. cx , catch) ;
632639 let lpad_ty = bx. type_struct ( & [ bx. type_i8p ( ) , bx. type_i32 ( ) ] , false ) ;
633640 let vals = catch. landing_pad ( lpad_ty, bx. eh_personality ( ) , 1 ) ;
634641 let tydesc = bx. const_null ( bx. type_i8p ( ) ) ;
@@ -674,21 +681,24 @@ fn codegen_emcc_try<'ll>(
674681 // %catch_data[1] = %is_rust_panic
675682 // call %catch_func(%data, %catch_data)
676683 // ret 1
677- let mut then = bx. build_sibling_block ( "then" ) ;
678- let mut catch = bx. build_sibling_block ( "catch" ) ;
684+ let then = bx. append_sibling_block ( "then" ) ;
685+ let catch = bx. append_sibling_block ( "catch" ) ;
679686
680687 let try_func = llvm:: get_param ( bx. llfn ( ) , 0 ) ;
681688 let data = llvm:: get_param ( bx. llfn ( ) , 1 ) ;
682689 let catch_func = llvm:: get_param ( bx. llfn ( ) , 2 ) ;
683690 let try_func_ty = bx. type_func ( & [ bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
684- bx. invoke ( try_func_ty, try_func, & [ data] , then. llbb ( ) , catch. llbb ( ) , None ) ;
691+ bx. invoke ( try_func_ty, try_func, & [ data] , then, catch, None ) ;
692+
693+ let mut then = Builder :: build ( bx. cx , then) ;
685694 then. ret ( bx. const_i32 ( 0 ) ) ;
686695
687696 // Type indicator for the exception being thrown.
688697 //
689698 // The first value in this tuple is a pointer to the exception object
690699 // being thrown. The second value is a "selector" indicating which of
691700 // the landing pad clauses the exception's type had been matched to.
701+ let mut catch = Builder :: build ( bx. cx , catch) ;
692702 let tydesc = bx. eh_catch_typeinfo ( ) ;
693703 let lpad_ty = bx. type_struct ( & [ bx. type_i8p ( ) , bx. type_i32 ( ) ] , false ) ;
694704 let vals = catch. landing_pad ( lpad_ty, bx. eh_personality ( ) , 2 ) ;
0 commit comments