@@ -18,7 +18,7 @@ use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf};
18
18
use rustc_middle:: ty:: { self , GenericArgsRef , Ty } ;
19
19
use rustc_middle:: { bug, span_bug} ;
20
20
use rustc_span:: { sym, Span , Symbol } ;
21
- use rustc_target:: abi:: { self , Align , HasDataLayout , Primitive } ;
21
+ use rustc_target:: abi:: { self , Align , HasDataLayout , Primitive , Size } ;
22
22
use rustc_target:: spec:: { HasTargetSpec , PanicStrategy } ;
23
23
24
24
use std:: cmp:: Ordering ;
@@ -649,8 +649,9 @@ fn codegen_msvc_try<'ll>(
649
649
// }
650
650
//
651
651
// More information can be found in libstd's seh.rs implementation.
652
+ let ptr_size = bx. tcx ( ) . data_layout . pointer_size ;
652
653
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) ;
654
655
let try_func_ty = bx. type_func ( & [ bx. type_ptr ( ) ] , bx. type_void ( ) ) ;
655
656
bx. invoke ( try_func_ty, None , None , try_func, & [ data] , normal, catchswitch, None , None ) ;
656
657
@@ -920,15 +921,14 @@ fn codegen_emcc_try<'ll>(
920
921
921
922
// We need to pass two values to catch_func (ptr and is_rust_panic), so
922
923
// create an alloca and pass a pointer to that.
924
+ let ptr_size = bx. tcx ( ) . data_layout . pointer_size ;
923
925
let ptr_align = bx. tcx ( ) . data_layout . pointer_align . abi ;
924
926
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 ( ) ) ) ;
932
932
bx. store ( is_rust_panic, catch_data_1, i8_align) ;
933
933
934
934
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>(
1374
1374
let ze = bx. zext ( i_, bx. type_ix ( expected_bytes * 8 ) ) ;
1375
1375
1376
1376
// 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 ) ;
1378
1378
bx. store ( ze, ptr, Align :: ONE ) ;
1379
1379
let array_ty = bx. type_array ( bx. type_i8 ( ) , expected_bytes) ;
1380
1380
return Ok ( bx. load ( array_ty, ptr, Align :: ONE ) ) ;
0 commit comments