@@ -431,8 +431,6 @@ fn try_intrinsic<'ll>(
431
431
bx. store ( bx. const_i32 ( 0 ) , dest, ret_align) ;
432
432
} else if wants_msvc_seh ( bx. sess ( ) ) {
433
433
codegen_msvc_try ( bx, try_func, data, catch_func, dest) ;
434
- } else if bx. sess ( ) . target . is_like_emscripten {
435
- codegen_emcc_try ( bx, try_func, data, catch_func, dest) ;
436
434
} else {
437
435
codegen_gnu_try ( bx, try_func, data, catch_func, dest) ;
438
436
}
@@ -656,91 +654,6 @@ fn codegen_gnu_try<'ll>(
656
654
bx. store ( ret, dest, i32_align) ;
657
655
}
658
656
659
- // Variant of codegen_gnu_try used for emscripten where Rust panics are
660
- // implemented using C++ exceptions. Here we use exceptions of a specific type
661
- // (`struct rust_panic`) to represent Rust panics.
662
- fn codegen_emcc_try < ' ll > (
663
- bx : & mut Builder < ' _ , ' ll , ' _ > ,
664
- try_func : & ' ll Value ,
665
- data : & ' ll Value ,
666
- catch_func : & ' ll Value ,
667
- dest : & ' ll Value ,
668
- ) {
669
- let ( llty, llfn) = get_rust_try_fn ( bx, & mut |mut bx| {
670
- // Codegens the shims described above:
671
- //
672
- // bx:
673
- // invoke %try_func(%data) normal %normal unwind %catch
674
- //
675
- // normal:
676
- // ret 0
677
- //
678
- // catch:
679
- // (%ptr, %selector) = landingpad
680
- // %rust_typeid = @llvm.eh.typeid.for(@_ZTI10rust_panic)
681
- // %is_rust_panic = %selector == %rust_typeid
682
- // %catch_data = alloca { i8*, i8 }
683
- // %catch_data[0] = %ptr
684
- // %catch_data[1] = %is_rust_panic
685
- // call %catch_func(%data, %catch_data)
686
- // ret 1
687
- let then = bx. append_sibling_block ( "then" ) ;
688
- let catch = bx. append_sibling_block ( "catch" ) ;
689
-
690
- let try_func = llvm:: get_param ( bx. llfn ( ) , 0 ) ;
691
- let data = llvm:: get_param ( bx. llfn ( ) , 1 ) ;
692
- let catch_func = llvm:: get_param ( bx. llfn ( ) , 2 ) ;
693
- let try_func_ty = bx. type_func ( & [ bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
694
- bx. invoke ( try_func_ty, try_func, & [ data] , then, catch, None ) ;
695
-
696
- bx. switch_to_block ( then) ;
697
- bx. ret ( bx. const_i32 ( 0 ) ) ;
698
-
699
- // Type indicator for the exception being thrown.
700
- //
701
- // The first value in this tuple is a pointer to the exception object
702
- // being thrown. The second value is a "selector" indicating which of
703
- // the landing pad clauses the exception's type had been matched to.
704
- bx. switch_to_block ( catch) ;
705
- let tydesc = bx. eh_catch_typeinfo ( ) ;
706
- let lpad_ty = bx. type_struct ( & [ bx. type_i8p ( ) , bx. type_i32 ( ) ] , false ) ;
707
- let vals = bx. landing_pad ( lpad_ty, bx. eh_personality ( ) , 2 ) ;
708
- bx. add_clause ( vals, tydesc) ;
709
- bx. add_clause ( vals, bx. const_null ( bx. type_i8p ( ) ) ) ;
710
- let ptr = bx. extract_value ( vals, 0 ) ;
711
- let selector = bx. extract_value ( vals, 1 ) ;
712
-
713
- // Check if the typeid we got is the one for a Rust panic.
714
- let rust_typeid = bx. call_intrinsic ( "llvm.eh.typeid.for" , & [ tydesc] ) ;
715
- let is_rust_panic = bx. icmp ( IntPredicate :: IntEQ , selector, rust_typeid) ;
716
- let is_rust_panic = bx. zext ( is_rust_panic, bx. type_bool ( ) ) ;
717
-
718
- // We need to pass two values to catch_func (ptr and is_rust_panic), so
719
- // create an alloca and pass a pointer to that.
720
- let ptr_align = bx. tcx ( ) . data_layout . pointer_align . abi ;
721
- let i8_align = bx. tcx ( ) . data_layout . i8_align . abi ;
722
- let catch_data_type = bx. type_struct ( & [ bx. type_i8p ( ) , bx. type_bool ( ) ] , false ) ;
723
- let catch_data = bx. alloca ( catch_data_type, ptr_align) ;
724
- let catch_data_0 =
725
- bx. inbounds_gep ( catch_data_type, catch_data, & [ bx. const_usize ( 0 ) , bx. const_usize ( 0 ) ] ) ;
726
- bx. store ( ptr, catch_data_0, ptr_align) ;
727
- let catch_data_1 =
728
- bx. inbounds_gep ( catch_data_type, catch_data, & [ bx. const_usize ( 0 ) , bx. const_usize ( 1 ) ] ) ;
729
- bx. store ( is_rust_panic, catch_data_1, i8_align) ;
730
- let catch_data = bx. bitcast ( catch_data, bx. type_i8p ( ) ) ;
731
-
732
- let catch_ty = bx. type_func ( & [ bx. type_i8p ( ) , bx. type_i8p ( ) ] , bx. type_void ( ) ) ;
733
- bx. call ( catch_ty, catch_func, & [ data, catch_data] , None ) ;
734
- bx. ret ( bx. const_i32 ( 1 ) ) ;
735
- } ) ;
736
-
737
- // Note that no invoke is used here because by definition this function
738
- // can't panic (that's what it's catching).
739
- let ret = bx. call ( llty, llfn, & [ try_func, data, catch_func] , None ) ;
740
- let i32_align = bx. tcx ( ) . data_layout . i32_align . abi ;
741
- bx. store ( ret, dest, i32_align) ;
742
- }
743
-
744
657
// Helper function to give a Block to a closure to codegen a shim function.
745
658
// This is currently primarily used for the `try` intrinsic functions above.
746
659
fn gen_fn < ' ll , ' tcx > (
0 commit comments