@@ -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 ;
@@ -637,8 +637,9 @@ fn codegen_msvc_try<'ll>(
637
637
// }
638
638
//
639
639
// More information can be found in libstd's seh.rs implementation.
640
+ let ptr_size = bx. tcx ( ) . data_layout . pointer_size ;
640
641
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) ;
642
643
let try_func_ty = bx. type_func ( & [ bx. type_ptr ( ) ] , bx. type_void ( ) ) ;
643
644
bx. invoke ( try_func_ty, None , None , try_func, & [ data] , normal, catchswitch, None ) ;
644
645
@@ -908,15 +909,14 @@ fn codegen_emcc_try<'ll>(
908
909
909
910
// We need to pass two values to catch_func (ptr and is_rust_panic), so
910
911
// create an alloca and pass a pointer to that.
912
+ let ptr_size = bx. tcx ( ) . data_layout . pointer_size ;
911
913
let ptr_align = bx. tcx ( ) . data_layout . pointer_align . abi ;
912
914
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 ( ) ) ) ;
920
920
bx. store ( is_rust_panic, catch_data_1, i8_align) ;
921
921
922
922
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>(
1362
1362
let ze = bx. zext ( i_, bx. type_ix ( expected_bytes * 8 ) ) ;
1363
1363
1364
1364
// 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 ) ;
1366
1366
bx. store ( ze, ptr, Align :: ONE ) ;
1367
1367
let array_ty = bx. type_array ( bx. type_i8 ( ) , expected_bytes) ;
1368
1368
return Ok ( bx. load ( array_ty, ptr, Align :: ONE ) ) ;
0 commit comments