@@ -28,7 +28,7 @@ use rustc_session::lint::builtin::DEPRECATED_LLVM_INTRINSIC;
2828use rustc_span:: { ErrorGuaranteed , Span , Symbol , sym} ;
2929use rustc_symbol_mangling:: { mangle_internal_symbol, symbol_name_for_instance_in_crate} ;
3030use rustc_target:: callconv:: PassMode ;
31- use rustc_target:: spec:: { Arch , Os } ;
31+ use rustc_target:: spec:: Arch ;
3232use tracing:: debug;
3333
3434use crate :: abi:: FnAbiLlvmExt ;
@@ -1356,8 +1356,6 @@ fn catch_unwind_intrinsic<'ll, 'tcx>(
13561356 codegen_msvc_try ( bx, try_func, data, catch_func)
13571357 } else if wants_wasm_eh ( bx. sess ( ) ) {
13581358 codegen_wasm_try ( bx, try_func, data, catch_func)
1359- } else if bx. sess ( ) . target . os == Os :: Emscripten {
1360- codegen_emcc_try ( bx, try_func, data, catch_func)
13611359 } else {
13621360 codegen_gnu_try ( bx, try_func, data, catch_func)
13631361 }
@@ -1654,87 +1652,6 @@ fn codegen_gnu_try<'ll, 'tcx>(
16541652 ret
16551653}
16561654
1657- // Variant of codegen_gnu_try used for emscripten where Rust panics are
1658- // implemented using C++ exceptions. Here we use exceptions of a specific type
1659- // (`struct rust_panic`) to represent Rust panics.
1660- fn codegen_emcc_try < ' ll , ' tcx > (
1661- bx : & mut Builder < ' _ , ' ll , ' tcx > ,
1662- try_func : & ' ll Value ,
1663- data : & ' ll Value ,
1664- catch_func : & ' ll Value ,
1665- ) -> & ' ll Value {
1666- let ( llty, llfn) = get_rust_try_fn ( bx, & mut |mut bx| {
1667- // Codegens the shims described above:
1668- //
1669- // bx:
1670- // invoke %try_func(%data) normal %normal unwind %catch
1671- //
1672- // normal:
1673- // ret 0
1674- //
1675- // catch:
1676- // (%ptr, %selector) = landingpad
1677- // %rust_typeid = @llvm.eh.typeid.for(@_ZTI10rust_panic)
1678- // %is_rust_panic = %selector == %rust_typeid
1679- // %catch_data = alloca { i8*, i8 }
1680- // %catch_data[0] = %ptr
1681- // %catch_data[1] = %is_rust_panic
1682- // call %catch_func(%data, %catch_data)
1683- // ret 1
1684- let then = bx. append_sibling_block ( "then" ) ;
1685- let catch = bx. append_sibling_block ( "catch" ) ;
1686-
1687- let try_func = llvm:: get_param ( bx. llfn ( ) , 0 ) ;
1688- let data = llvm:: get_param ( bx. llfn ( ) , 1 ) ;
1689- let catch_func = llvm:: get_param ( bx. llfn ( ) , 2 ) ;
1690- let try_func_ty = bx. type_func ( & [ bx. type_ptr ( ) ] , bx. type_void ( ) ) ;
1691- bx. invoke ( try_func_ty, None , None , try_func, & [ data] , then, catch, None , None ) ;
1692-
1693- bx. switch_to_block ( then) ;
1694- bx. ret ( bx. const_bool ( false ) ) ;
1695-
1696- // Type indicator for the exception being thrown.
1697- //
1698- // The first value in this tuple is a pointer to the exception object
1699- // being thrown. The second value is a "selector" indicating which of
1700- // the landing pad clauses the exception's type had been matched to.
1701- bx. switch_to_block ( catch) ;
1702- let tydesc = bx. eh_catch_typeinfo ( ) ;
1703- let lpad_ty = bx. type_struct ( & [ bx. type_ptr ( ) , bx. type_i32 ( ) ] , false ) ;
1704- let vals = bx. landing_pad ( lpad_ty, bx. eh_personality ( ) , 2 ) ;
1705- bx. add_clause ( vals, tydesc) ;
1706- bx. add_clause ( vals, bx. const_null ( bx. type_ptr ( ) ) ) ;
1707- let ptr = bx. extract_value ( vals, 0 ) ;
1708- let selector = bx. extract_value ( vals, 1 ) ;
1709-
1710- // Check if the typeid we got is the one for a Rust panic.
1711- let rust_typeid = bx. call_intrinsic ( "llvm.eh.typeid.for" , & [ bx. val_ty ( tydesc) ] , & [ tydesc] ) ;
1712- let is_rust_panic = bx. icmp ( IntPredicate :: IntEQ , selector, rust_typeid) ;
1713- let is_rust_panic = bx. zext ( is_rust_panic, bx. type_bool ( ) ) ;
1714-
1715- // We need to pass two values to catch_func (ptr and is_rust_panic), so
1716- // create an alloca and pass a pointer to that.
1717- let ptr_size = bx. tcx ( ) . data_layout . pointer_size ( ) ;
1718- let ptr_align = bx. tcx ( ) . data_layout . pointer_align ( ) . abi ;
1719- let i8_align = bx. tcx ( ) . data_layout . i8_align ;
1720- // Required in order for there to be no padding between the fields.
1721- assert ! ( i8_align <= ptr_align) ;
1722- let catch_data = bx. alloca ( 2 * ptr_size, ptr_align) ;
1723- bx. store ( ptr, catch_data, ptr_align) ;
1724- let catch_data_1 = bx. inbounds_ptradd ( catch_data, bx. const_usize ( ptr_size. bytes ( ) ) ) ;
1725- bx. store ( is_rust_panic, catch_data_1, i8_align) ;
1726-
1727- let catch_ty = bx. type_func ( & [ bx. type_ptr ( ) , bx. type_ptr ( ) ] , bx. type_void ( ) ) ;
1728- bx. call ( catch_ty, None , None , catch_func, & [ data, catch_data] , None , None ) ;
1729- bx. ret ( bx. const_bool ( true ) ) ;
1730- } ) ;
1731-
1732- // Note that no invoke is used here because by definition this function
1733- // can't panic (that's what it's catching).
1734- let ret = bx. call ( llty, None , None , llfn, & [ try_func, data, catch_func] , None , None ) ;
1735- ret
1736- }
1737-
17381655// Helper function to give a Block to a closure to codegen a shim function.
17391656// This is currently primarily used for the `try` intrinsic functions above.
17401657fn gen_fn < ' a , ' ll , ' tcx > (
0 commit comments