@@ -522,11 +522,11 @@ fn codegen_msvc_try<'ll>(
522
522
let try_func_ty = bx. type_func ( & [ bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
523
523
bx. invoke ( try_func_ty, try_func, & [ data] , normal, catchswitch, None ) ;
524
524
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 ) ) ;
527
527
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] ) ;
530
530
531
531
// We can't use the TypeDescriptor defined in libpanic_unwind because it
532
532
// might be in another DLL and the SEH encoding only supports specifying
@@ -559,24 +559,24 @@ fn codegen_msvc_try<'ll>(
559
559
// since our exception object effectively contains a Box.
560
560
//
561
561
// Source: MicrosoftCXXABI::getAddrOfCXXCatchHandlerType in clang
562
- let mut catchpad_rust = Builder :: build ( bx. cx , catchpad_rust) ;
562
+ bx. switch_to_block ( catchpad_rust) ;
563
563
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) ;
566
566
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) ;
569
569
570
570
// 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) ;
572
572
let flags = bx. const_i32 ( 64 ) ;
573
573
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) ;
577
577
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 ) ) ;
580
580
} ) ;
581
581
582
582
// Note that no invoke is used here because by definition this function
@@ -626,24 +626,24 @@ fn codegen_gnu_try<'ll>(
626
626
let try_func_ty = bx. type_func ( & [ bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
627
627
bx. invoke ( try_func_ty, try_func, & [ data] , then, catch, None ) ;
628
628
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 ) ) ;
631
631
632
632
// Type indicator for the exception being thrown.
633
633
//
634
634
// The first value in this tuple is a pointer to the exception object
635
635
// being thrown. The second value is a "selector" indicating which of
636
636
// the landing pad clauses the exception's type had been matched to.
637
637
// rust_try ignores the selector.
638
- let mut catch = Builder :: build ( bx. cx , catch) ;
638
+ bx. switch_to_block ( catch) ;
639
639
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 ) ;
641
641
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 ) ;
644
644
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 ) ) ;
647
647
} ) ;
648
648
649
649
// Note that no invoke is used here because by definition this function
@@ -690,51 +690,45 @@ fn codegen_emcc_try<'ll>(
690
690
let try_func_ty = bx. type_func ( & [ bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
691
691
bx. invoke ( try_func_ty, try_func, & [ data] , then, catch, None ) ;
692
692
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 ) ) ;
695
695
696
696
// Type indicator for the exception being thrown.
697
697
//
698
698
// The first value in this tuple is a pointer to the exception object
699
699
// being thrown. The second value is a "selector" indicating which of
700
700
// 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) ;
702
702
let tydesc = bx. eh_catch_typeinfo ( ) ;
703
703
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 ) ;
709
709
710
710
// 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 ( ) ) ;
714
714
715
715
// We need to pass two values to catch_func (ptr and is_rust_panic), so
716
716
// create an alloca and pass a pointer to that.
717
717
let ptr_align = bx. tcx ( ) . data_layout . pointer_align . abi ;
718
718
let i8_align = bx. tcx ( ) . data_layout . i8_align . abi ;
719
719
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 ( ) ) ;
734
728
735
729
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 ) ) ;
738
732
} ) ;
739
733
740
734
// Note that no invoke is used here because by definition this function
0 commit comments