@@ -522,11 +522,11 @@ fn codegen_msvc_try<'ll>(
522522 let try_func_ty = bx. type_func ( & [ bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
523523 bx. invoke ( try_func_ty, try_func, & [ data] , normal, catchswitch, None ) ;
524524
525- let mut normal = Builder :: build ( bx. cx , normal) ;
526- normal . ret ( bx. const_i32 ( 0 ) ) ;
525+ bx. switch_to_block ( normal) ;
526+ bx . ret ( bx. const_i32 ( 0 ) ) ;
527527
528- let mut catchswitch = Builder :: build ( bx. cx , catchswitch) ;
529- let cs = catchswitch . catch_switch ( None , None , & [ catchpad_rust, catchpad_foreign] ) ;
528+ bx. switch_to_block ( catchswitch) ;
529+ let cs = bx . catch_switch ( None , None , & [ catchpad_rust, catchpad_foreign] ) ;
530530
531531 // We can't use the TypeDescriptor defined in libpanic_unwind because it
532532 // might be in another DLL and the SEH encoding only supports specifying
@@ -559,24 +559,24 @@ fn codegen_msvc_try<'ll>(
559559 // since our exception object effectively contains a Box.
560560 //
561561 // Source: MicrosoftCXXABI::getAddrOfCXXCatchHandlerType in clang
562- let mut catchpad_rust = Builder :: build ( bx. cx , catchpad_rust) ;
562+ bx. switch_to_block ( catchpad_rust) ;
563563 let flags = bx. const_i32 ( 8 ) ;
564- let funclet = catchpad_rust . catch_pad ( cs, & [ tydesc, flags, slot] ) ;
565- let ptr = catchpad_rust . load ( bx. type_i8p ( ) , slot, ptr_align) ;
564+ let funclet = bx . catch_pad ( cs, & [ tydesc, flags, slot] ) ;
565+ let ptr = bx . load ( bx. type_i8p ( ) , slot, ptr_align) ;
566566 let catch_ty = bx. type_func ( & [ bx. type_i8p ( ) , bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
567- catchpad_rust . call ( catch_ty, catch_func, & [ data, ptr] , Some ( & funclet) ) ;
568- catchpad_rust . catch_ret ( & funclet, caught) ;
567+ bx . call ( catch_ty, catch_func, & [ data, ptr] , Some ( & funclet) ) ;
568+ bx . catch_ret ( & funclet, caught) ;
569569
570570 // The flag value of 64 indicates a "catch-all".
571- let mut catchpad_foreign = Builder :: build ( bx. cx , catchpad_foreign) ;
571+ bx. switch_to_block ( catchpad_foreign) ;
572572 let flags = bx. const_i32 ( 64 ) ;
573573 let null = bx. const_null ( bx. type_i8p ( ) ) ;
574- let funclet = catchpad_foreign . catch_pad ( cs, & [ null, flags, null] ) ;
575- catchpad_foreign . call ( catch_ty, catch_func, & [ data, null] , Some ( & funclet) ) ;
576- catchpad_foreign . catch_ret ( & funclet, caught) ;
574+ let funclet = bx . catch_pad ( cs, & [ null, flags, null] ) ;
575+ bx . call ( catch_ty, catch_func, & [ data, null] , Some ( & funclet) ) ;
576+ bx . catch_ret ( & funclet, caught) ;
577577
578- let mut caught = Builder :: build ( bx. cx , caught) ;
579- caught . ret ( bx. const_i32 ( 1 ) ) ;
578+ bx. switch_to_block ( caught) ;
579+ bx . ret ( bx. const_i32 ( 1 ) ) ;
580580 } ) ;
581581
582582 // Note that no invoke is used here because by definition this function
@@ -626,24 +626,24 @@ fn codegen_gnu_try<'ll>(
626626 let try_func_ty = bx. type_func ( & [ bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
627627 bx. invoke ( try_func_ty, try_func, & [ data] , then, catch, None ) ;
628628
629- let mut then = Builder :: build ( bx. cx , then) ;
630- then . ret ( bx. const_i32 ( 0 ) ) ;
629+ bx. switch_to_block ( then) ;
630+ bx . ret ( bx. const_i32 ( 0 ) ) ;
631631
632632 // Type indicator for the exception being thrown.
633633 //
634634 // The first value in this tuple is a pointer to the exception object
635635 // being thrown. The second value is a "selector" indicating which of
636636 // the landing pad clauses the exception's type had been matched to.
637637 // rust_try ignores the selector.
638- let mut catch = Builder :: build ( bx. cx , catch) ;
638+ bx. switch_to_block ( catch) ;
639639 let lpad_ty = bx. type_struct ( & [ bx. type_i8p ( ) , bx. type_i32 ( ) ] , false ) ;
640- let vals = catch . landing_pad ( lpad_ty, bx. eh_personality ( ) , 1 ) ;
640+ let vals = bx . landing_pad ( lpad_ty, bx. eh_personality ( ) , 1 ) ;
641641 let tydesc = bx. const_null ( bx. type_i8p ( ) ) ;
642- catch . add_clause ( vals, tydesc) ;
643- let ptr = catch . extract_value ( vals, 0 ) ;
642+ bx . add_clause ( vals, tydesc) ;
643+ let ptr = bx . extract_value ( vals, 0 ) ;
644644 let catch_ty = bx. type_func ( & [ bx. type_i8p ( ) , bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
645- catch . call ( catch_ty, catch_func, & [ data, ptr] , None ) ;
646- catch . ret ( bx. const_i32 ( 1 ) ) ;
645+ bx . call ( catch_ty, catch_func, & [ data, ptr] , None ) ;
646+ bx . ret ( bx. const_i32 ( 1 ) ) ;
647647 } ) ;
648648
649649 // Note that no invoke is used here because by definition this function
@@ -690,51 +690,45 @@ fn codegen_emcc_try<'ll>(
690690 let try_func_ty = bx. type_func ( & [ bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
691691 bx. invoke ( try_func_ty, try_func, & [ data] , then, catch, None ) ;
692692
693- let mut then = Builder :: build ( bx. cx , then) ;
694- then . ret ( bx. const_i32 ( 0 ) ) ;
693+ bx. switch_to_block ( then) ;
694+ bx . ret ( bx. const_i32 ( 0 ) ) ;
695695
696696 // Type indicator for the exception being thrown.
697697 //
698698 // The first value in this tuple is a pointer to the exception object
699699 // being thrown. The second value is a "selector" indicating which of
700700 // the landing pad clauses the exception's type had been matched to.
701- let mut catch = Builder :: build ( bx. cx , catch) ;
701+ bx. switch_to_block ( catch) ;
702702 let tydesc = bx. eh_catch_typeinfo ( ) ;
703703 let lpad_ty = bx. type_struct ( & [ bx. type_i8p ( ) , bx. type_i32 ( ) ] , false ) ;
704- let vals = catch . landing_pad ( lpad_ty, bx. eh_personality ( ) , 2 ) ;
705- catch . add_clause ( vals, tydesc) ;
706- catch . add_clause ( vals, bx. const_null ( bx. type_i8p ( ) ) ) ;
707- let ptr = catch . extract_value ( vals, 0 ) ;
708- let selector = catch . extract_value ( vals, 1 ) ;
704+ let vals = bx . landing_pad ( lpad_ty, bx. eh_personality ( ) , 2 ) ;
705+ bx . add_clause ( vals, tydesc) ;
706+ bx . add_clause ( vals, bx. const_null ( bx. type_i8p ( ) ) ) ;
707+ let ptr = bx . extract_value ( vals, 0 ) ;
708+ let selector = bx . extract_value ( vals, 1 ) ;
709709
710710 // Check if the typeid we got is the one for a Rust panic.
711- let rust_typeid = catch . call_intrinsic ( "llvm.eh.typeid.for" , & [ tydesc] ) ;
712- let is_rust_panic = catch . icmp ( IntPredicate :: IntEQ , selector, rust_typeid) ;
713- let is_rust_panic = catch . zext ( is_rust_panic, bx. type_bool ( ) ) ;
711+ let rust_typeid = bx . call_intrinsic ( "llvm.eh.typeid.for" , & [ tydesc] ) ;
712+ let is_rust_panic = bx . icmp ( IntPredicate :: IntEQ , selector, rust_typeid) ;
713+ let is_rust_panic = bx . zext ( is_rust_panic, bx. type_bool ( ) ) ;
714714
715715 // We need to pass two values to catch_func (ptr and is_rust_panic), so
716716 // create an alloca and pass a pointer to that.
717717 let ptr_align = bx. tcx ( ) . data_layout . pointer_align . abi ;
718718 let i8_align = bx. tcx ( ) . data_layout . i8_align . abi ;
719719 let catch_data_type = bx. type_struct ( & [ bx. type_i8p ( ) , bx. type_bool ( ) ] , false ) ;
720- let catch_data = catch. alloca ( catch_data_type, ptr_align) ;
721- let catch_data_0 = catch. inbounds_gep (
722- catch_data_type,
723- catch_data,
724- & [ bx. const_usize ( 0 ) , bx. const_usize ( 0 ) ] ,
725- ) ;
726- catch. store ( ptr, catch_data_0, ptr_align) ;
727- let catch_data_1 = catch. inbounds_gep (
728- catch_data_type,
729- catch_data,
730- & [ bx. const_usize ( 0 ) , bx. const_usize ( 1 ) ] ,
731- ) ;
732- catch. store ( is_rust_panic, catch_data_1, i8_align) ;
733- let catch_data = catch. bitcast ( catch_data, bx. type_i8p ( ) ) ;
720+ let catch_data = bx. alloca ( catch_data_type, ptr_align) ;
721+ let catch_data_0 =
722+ bx. inbounds_gep ( catch_data_type, catch_data, & [ bx. const_usize ( 0 ) , bx. const_usize ( 0 ) ] ) ;
723+ bx. store ( ptr, catch_data_0, ptr_align) ;
724+ let catch_data_1 =
725+ bx. inbounds_gep ( catch_data_type, catch_data, & [ bx. const_usize ( 0 ) , bx. const_usize ( 1 ) ] ) ;
726+ bx. store ( is_rust_panic, catch_data_1, i8_align) ;
727+ let catch_data = bx. bitcast ( catch_data, bx. type_i8p ( ) ) ;
734728
735729 let catch_ty = bx. type_func ( & [ bx. type_i8p ( ) , bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
736- catch . call ( catch_ty, catch_func, & [ data, catch_data] , None ) ;
737- catch . ret ( bx. const_i32 ( 1 ) ) ;
730+ bx . call ( catch_ty, catch_func, & [ data, catch_data] , None ) ;
731+ bx . ret ( bx. const_i32 ( 1 ) ) ;
738732 } ) ;
739733
740734 // Note that no invoke is used here because by definition this function
0 commit comments