@@ -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 ;
@@ -649,8 +649,9 @@ fn codegen_msvc_try<'ll>(
649649 // }
650650 //
651651 // More information can be found in libstd's seh.rs implementation.
652+ let ptr_size = bx. tcx ( ) . data_layout . pointer_size ;
652653 let ptr_align = bx. tcx ( ) . data_layout . pointer_align . abi ;
653- let slot = bx. alloca ( bx . type_ptr ( ) , ptr_align) ;
654+ let slot = bx. alloca ( ptr_size , ptr_align) ;
654655 let try_func_ty = bx. type_func ( & [ bx. type_ptr ( ) ] , bx. type_void ( ) ) ;
655656 bx. invoke ( try_func_ty, None , None , try_func, & [ data] , normal, catchswitch, None , None ) ;
656657
@@ -920,15 +921,14 @@ fn codegen_emcc_try<'ll>(
920921
921922 // We need to pass two values to catch_func (ptr and is_rust_panic), so
922923 // create an alloca and pass a pointer to that.
924+ let ptr_size = bx. tcx ( ) . data_layout . pointer_size ;
923925 let ptr_align = bx. tcx ( ) . data_layout . pointer_align . abi ;
924926 let i8_align = bx. tcx ( ) . data_layout . i8_align . abi ;
925- let catch_data_type = bx. type_struct ( & [ bx. type_ptr ( ) , bx. type_bool ( ) ] , false ) ;
926- let catch_data = bx. alloca ( catch_data_type, ptr_align) ;
927- let catch_data_0 =
928- bx. inbounds_gep ( catch_data_type, catch_data, & [ bx. const_usize ( 0 ) , bx. const_usize ( 0 ) ] ) ;
929- bx. store ( ptr, catch_data_0, ptr_align) ;
930- let catch_data_1 =
931- bx. inbounds_gep ( catch_data_type, catch_data, & [ bx. const_usize ( 0 ) , bx. const_usize ( 1 ) ] ) ;
927+ // Required in order for there to be no padding between the fields.
928+ assert ! ( i8_align <= ptr_align) ;
929+ let catch_data = bx. alloca ( 2 * ptr_size, ptr_align) ;
930+ bx. store ( ptr, catch_data, ptr_align) ;
931+ let catch_data_1 = bx. inbounds_ptradd ( catch_data, bx. const_usize ( ptr_size. bytes ( ) ) ) ;
932932 bx. store ( is_rust_panic, catch_data_1, i8_align) ;
933933
934934 let catch_ty = bx. type_func ( & [ bx. type_ptr ( ) , bx. type_ptr ( ) ] , bx. type_void ( ) ) ;
@@ -1374,7 +1374,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
13741374 let ze = bx. zext ( i_, bx. type_ix ( expected_bytes * 8 ) ) ;
13751375
13761376 // Convert the integer to a byte array
1377- let ptr = bx. alloca ( bx . type_ix ( expected_bytes * 8 ) , Align :: ONE ) ;
1377+ let ptr = bx. alloca ( Size :: from_bytes ( expected_bytes) , Align :: ONE ) ;
13781378 bx. store ( ze, ptr, Align :: ONE ) ;
13791379 let array_ty = bx. type_array ( bx. type_i8 ( ) , expected_bytes) ;
13801380 return Ok ( bx. load ( array_ty, ptr, Align :: ONE ) ) ;
0 commit comments