@@ -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 ;
@@ -638,8 +638,9 @@ fn codegen_msvc_try<'ll>(
638638 // }
639639 //
640640 // More information can be found in libstd's seh.rs implementation.
641+ let ptr_size = bx. tcx ( ) . data_layout . pointer_size ;
641642 let ptr_align = bx. tcx ( ) . data_layout . pointer_align . abi ;
642- let slot = bx. alloca ( bx . type_ptr ( ) , ptr_align) ;
643+ let slot = bx. alloca ( ptr_size , ptr_align) ;
643644 let try_func_ty = bx. type_func ( & [ bx. type_ptr ( ) ] , bx. type_void ( ) ) ;
644645 bx. invoke ( try_func_ty, None , None , try_func, & [ data] , normal, catchswitch, None , None ) ;
645646
@@ -909,15 +910,14 @@ fn codegen_emcc_try<'ll>(
909910
910911 // We need to pass two values to catch_func (ptr and is_rust_panic), so
911912 // create an alloca and pass a pointer to that.
913+ let ptr_size = bx. tcx ( ) . data_layout . pointer_size ;
912914 let ptr_align = bx. tcx ( ) . data_layout . pointer_align . abi ;
913915 let i8_align = bx. tcx ( ) . data_layout . i8_align . abi ;
914- let catch_data_type = bx. type_struct ( & [ bx. type_ptr ( ) , bx. type_bool ( ) ] , false ) ;
915- let catch_data = bx. alloca ( catch_data_type, ptr_align) ;
916- let catch_data_0 =
917- bx. inbounds_gep ( catch_data_type, catch_data, & [ bx. const_usize ( 0 ) , bx. const_usize ( 0 ) ] ) ;
918- bx. store ( ptr, catch_data_0, ptr_align) ;
919- let catch_data_1 =
920- bx. inbounds_gep ( catch_data_type, catch_data, & [ bx. const_usize ( 0 ) , bx. const_usize ( 1 ) ] ) ;
916+ // Required in order for there to be no padding between the fields.
917+ assert ! ( i8_align <= ptr_align) ;
918+ let catch_data = bx. alloca ( 2 * ptr_size, ptr_align) ;
919+ bx. store ( ptr, catch_data, ptr_align) ;
920+ let catch_data_1 = bx. inbounds_ptradd ( catch_data, bx. const_usize ( ptr_size. bytes ( ) ) ) ;
921921 bx. store ( is_rust_panic, catch_data_1, i8_align) ;
922922
923923 let catch_ty = bx. type_func ( & [ bx. type_ptr ( ) , bx. type_ptr ( ) ] , bx. type_void ( ) ) ;
@@ -1363,7 +1363,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
13631363 let ze = bx. zext ( i_, bx. type_ix ( expected_bytes * 8 ) ) ;
13641364
13651365 // Convert the integer to a byte array
1366- let ptr = bx. alloca ( bx . type_ix ( expected_bytes * 8 ) , Align :: ONE ) ;
1366+ let ptr = bx. alloca ( Size :: from_bytes ( expected_bytes) , Align :: ONE ) ;
13671367 bx. store ( ze, ptr, Align :: ONE ) ;
13681368 let array_ty = bx. type_array ( bx. type_i8 ( ) , expected_bytes) ;
13691369 return Ok ( bx. load ( array_ty, ptr, Align :: ONE ) ) ;
0 commit comments