@@ -452,11 +452,11 @@ fn codegen_msvc_try<'ll>(
452
452
let ( llty, llfn) = get_rust_try_fn ( bx, & mut |mut bx| {
453
453
bx. set_personality_fn ( bx. eh_personality ( ) ) ;
454
454
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" ) ;
460
460
461
461
let try_func = llvm:: get_param ( bx. llfn ( ) , 0 ) ;
462
462
let data = llvm:: get_param ( bx. llfn ( ) , 1 ) ;
@@ -520,12 +520,13 @@ fn codegen_msvc_try<'ll>(
520
520
let ptr_align = bx. tcx ( ) . data_layout . pointer_align . abi ;
521
521
let slot = bx. alloca ( bx. type_i8p ( ) , ptr_align) ;
522
522
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 ) ;
524
524
525
+ let mut normal = Builder :: build ( bx. cx , normal) ;
525
526
normal. ret ( bx. const_i32 ( 0 ) ) ;
526
527
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] ) ;
529
530
530
531
// We can't use the TypeDescriptor defined in libpanic_unwind because it
531
532
// might be in another DLL and the SEH encoding only supports specifying
@@ -558,20 +559,23 @@ fn codegen_msvc_try<'ll>(
558
559
// since our exception object effectively contains a Box.
559
560
//
560
561
// Source: MicrosoftCXXABI::getAddrOfCXXCatchHandlerType in clang
562
+ let mut catchpad_rust = Builder :: build ( bx. cx , catchpad_rust) ;
561
563
let flags = bx. const_i32 ( 8 ) ;
562
564
let funclet = catchpad_rust. catch_pad ( cs, & [ tydesc, flags, slot] ) ;
563
565
let ptr = catchpad_rust. load ( bx. type_i8p ( ) , slot, ptr_align) ;
564
566
let catch_ty = bx. type_func ( & [ bx. type_i8p ( ) , bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
565
567
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) ;
567
569
568
570
// The flag value of 64 indicates a "catch-all".
571
+ let mut catchpad_foreign = Builder :: build ( bx. cx , catchpad_foreign) ;
569
572
let flags = bx. const_i32 ( 64 ) ;
570
573
let null = bx. const_null ( bx. type_i8p ( ) ) ;
571
574
let funclet = catchpad_foreign. catch_pad ( cs, & [ null, flags, null] ) ;
572
575
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) ;
574
577
578
+ let mut caught = Builder :: build ( bx. cx , caught) ;
575
579
caught. ret ( bx. const_i32 ( 1 ) ) ;
576
580
} ) ;
577
581
@@ -613,14 +617,16 @@ fn codegen_gnu_try<'ll>(
613
617
// (%ptr, _) = landingpad
614
618
// call %catch_func(%data, %ptr)
615
619
// 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" ) ;
618
622
619
623
let try_func = llvm:: get_param ( bx. llfn ( ) , 0 ) ;
620
624
let data = llvm:: get_param ( bx. llfn ( ) , 1 ) ;
621
625
let catch_func = llvm:: get_param ( bx. llfn ( ) , 2 ) ;
622
626
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) ;
624
630
then. ret ( bx. const_i32 ( 0 ) ) ;
625
631
626
632
// Type indicator for the exception being thrown.
@@ -629,6 +635,7 @@ fn codegen_gnu_try<'ll>(
629
635
// being thrown. The second value is a "selector" indicating which of
630
636
// the landing pad clauses the exception's type had been matched to.
631
637
// rust_try ignores the selector.
638
+ let mut catch = Builder :: build ( bx. cx , catch) ;
632
639
let lpad_ty = bx. type_struct ( & [ bx. type_i8p ( ) , bx. type_i32 ( ) ] , false ) ;
633
640
let vals = catch. landing_pad ( lpad_ty, bx. eh_personality ( ) , 1 ) ;
634
641
let tydesc = bx. const_null ( bx. type_i8p ( ) ) ;
@@ -674,21 +681,24 @@ fn codegen_emcc_try<'ll>(
674
681
// %catch_data[1] = %is_rust_panic
675
682
// call %catch_func(%data, %catch_data)
676
683
// 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" ) ;
679
686
680
687
let try_func = llvm:: get_param ( bx. llfn ( ) , 0 ) ;
681
688
let data = llvm:: get_param ( bx. llfn ( ) , 1 ) ;
682
689
let catch_func = llvm:: get_param ( bx. llfn ( ) , 2 ) ;
683
690
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) ;
685
694
then. ret ( bx. const_i32 ( 0 ) ) ;
686
695
687
696
// Type indicator for the exception being thrown.
688
697
//
689
698
// The first value in this tuple is a pointer to the exception object
690
699
// being thrown. The second value is a "selector" indicating which of
691
700
// the landing pad clauses the exception's type had been matched to.
701
+ let mut catch = Builder :: build ( bx. cx , catch) ;
692
702
let tydesc = bx. eh_catch_typeinfo ( ) ;
693
703
let lpad_ty = bx. type_struct ( & [ bx. type_i8p ( ) , bx. type_i32 ( ) ] , false ) ;
694
704
let vals = catch. landing_pad ( lpad_ty, bx. eh_personality ( ) , 2 ) ;
0 commit comments