@@ -18,7 +18,7 @@ use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf};
1818use rustc_middle:: ty:: { self , GenericArgsRef , Ty } ;
1919use rustc_middle:: { bug, span_bug} ;
2020use rustc_span:: { sym, Span , Symbol } ;
21- use rustc_target:: abi:: { self , Align , HasDataLayout , Primitive } ;
21+ use rustc_target:: abi:: { self , Align , HasDataLayout , Primitive , Size } ;
2222use rustc_target:: spec:: { HasTargetSpec , PanicStrategy } ;
2323
2424use std:: cmp:: Ordering ;
@@ -637,8 +637,9 @@ fn codegen_msvc_try<'ll>(
637637 // }
638638 //
639639 // More information can be found in libstd's seh.rs implementation.
640+ let ptr_size = bx. tcx ( ) . data_layout . pointer_size ;
640641 let ptr_align = bx. tcx ( ) . data_layout . pointer_align . abi ;
641- let slot = bx. alloca ( bx . type_ptr ( ) , ptr_align) ;
642+ let slot = bx. alloca ( ptr_size , ptr_align) ;
642643 let try_func_ty = bx. type_func ( & [ bx. type_ptr ( ) ] , bx. type_void ( ) ) ;
643644 bx. invoke ( try_func_ty, None , None , try_func, & [ data] , normal, catchswitch, None ) ;
644645
@@ -908,15 +909,14 @@ fn codegen_emcc_try<'ll>(
908909
909910 // We need to pass two values to catch_func (ptr and is_rust_panic), so
910911 // create an alloca and pass a pointer to that.
912+ let ptr_size = bx. tcx ( ) . data_layout . pointer_size ;
911913 let ptr_align = bx. tcx ( ) . data_layout . pointer_align . abi ;
912914 let i8_align = bx. tcx ( ) . data_layout . i8_align . abi ;
913- let catch_data_type = bx. type_struct ( & [ bx. type_ptr ( ) , bx. type_bool ( ) ] , false ) ;
914- let catch_data = bx. alloca ( catch_data_type, ptr_align) ;
915- let catch_data_0 =
916- bx. inbounds_gep ( catch_data_type, catch_data, & [ bx. const_usize ( 0 ) , bx. const_usize ( 0 ) ] ) ;
917- bx. store ( ptr, catch_data_0, ptr_align) ;
918- let catch_data_1 =
919- bx. inbounds_gep ( catch_data_type, catch_data, & [ bx. const_usize ( 0 ) , bx. const_usize ( 1 ) ] ) ;
915+ // Required in order for there to be no padding between the fields.
916+ assert ! ( i8_align <= ptr_align) ;
917+ let catch_data = bx. alloca ( 2 * ptr_size, ptr_align) ;
918+ bx. store ( ptr, catch_data, ptr_align) ;
919+ let catch_data_1 = bx. inbounds_ptradd ( catch_data, bx. const_usize ( ptr_size. bytes ( ) ) ) ;
920920 bx. store ( is_rust_panic, catch_data_1, i8_align) ;
921921
922922 let catch_ty = bx. type_func ( & [ bx. type_ptr ( ) , bx. type_ptr ( ) ] , bx. type_void ( ) ) ;
@@ -1362,7 +1362,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
13621362 let ze = bx. zext ( i_, bx. type_ix ( expected_bytes * 8 ) ) ;
13631363
13641364 // Convert the integer to a byte array
1365- let ptr = bx. alloca ( bx . type_ix ( expected_bytes * 8 ) , Align :: ONE ) ;
1365+ let ptr = bx. alloca ( Size :: from_bytes ( expected_bytes) , Align :: ONE ) ;
13661366 bx. store ( ze, ptr, Align :: ONE ) ;
13671367 let array_ty = bx. type_array ( bx. type_i8 ( ) , expected_bytes) ;
13681368 return Ok ( bx. load ( array_ty, ptr, Align :: ONE ) ) ;
0 commit comments