@@ -174,11 +174,11 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
174174 // Non-power-of-two vectors have padding up to the next power-of-two.
175175 // If we're a packed repr, remove the padding while keeping the alignment as close
176176 // to a vector as possible.
177- ( BackendRepr :: Memory { sized : true } , AbiAlign { abi : Align :: max_aligned_factor ( size) } )
177+ ( BackendRepr :: Memory { sized : true } , Align :: max_aligned_factor ( size) )
178178 } else {
179179 ( BackendRepr :: SimdVector { element : e_repr, count } , dl. llvmlike_vector_align ( size) )
180180 } ;
181- let size = size. align_to ( align. abi ) ;
181+ let size = size. align_to ( align) ;
182182
183183 Ok ( LayoutData {
184184 variants : Variants :: Single { index : VariantIdx :: new ( 0 ) } ,
@@ -190,7 +190,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
190190 largest_niche : elt. largest_niche ,
191191 uninhabited : false ,
192192 size,
193- align,
193+ align : AbiAlign :: new ( align ) ,
194194 max_repr_align : None ,
195195 unadjusted_abi_align : elt. align . abi ,
196196 randomization_seed : elt. randomization_seed . wrapping_add ( Hash64 :: new ( count) ) ,
@@ -388,7 +388,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
388388 return Err ( LayoutCalculatorError :: UnexpectedUnsized ( * field) ) ;
389389 }
390390
391- align = align. max ( field. align ) ;
391+ align = align. max ( field. align . abi ) ;
392392 max_repr_align = max_repr_align. max ( field. max_repr_align ) ;
393393 size = cmp:: max ( size, field. size ) ;
394394
@@ -423,13 +423,13 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
423423 }
424424
425425 if let Some ( pack) = repr. pack {
426- align = align. min ( AbiAlign :: new ( pack) ) ;
426+ align = align. min ( pack) ;
427427 }
428428 // The unadjusted ABI alignment does not include repr(align), but does include repr(pack).
429429 // See documentation on `LayoutData::unadjusted_abi_align`.
430- let unadjusted_abi_align = align. abi ;
430+ let unadjusted_abi_align = align;
431431 if let Some ( repr_align) = repr. align {
432- align = align. max ( AbiAlign :: new ( repr_align) ) ;
432+ align = align. max ( repr_align) ;
433433 }
434434 // `align` must not be modified after this, or `unadjusted_abi_align` could be inaccurate.
435435 let align = align;
@@ -441,14 +441,12 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
441441 Ok ( Some ( ( repr, _) ) ) => match repr {
442442 // Mismatched alignment (e.g. union is #[repr(packed)]): disable opt
443443 BackendRepr :: Scalar ( _) | BackendRepr :: ScalarPair ( _, _)
444- if repr. scalar_align ( dl) . unwrap ( ) != align. abi =>
444+ if repr. scalar_align ( dl) . unwrap ( ) != align =>
445445 {
446446 BackendRepr :: Memory { sized : true }
447447 }
448448 // Vectors require at least element alignment, else disable the opt
449- BackendRepr :: SimdVector { element, count : _ }
450- if element. align ( dl) . abi > align. abi =>
451- {
449+ BackendRepr :: SimdVector { element, count : _ } if element. align ( dl) . abi > align => {
452450 BackendRepr :: Memory { sized : true }
453451 }
454452 // the alignment tests passed and we can use this
@@ -474,8 +472,8 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
474472 backend_repr,
475473 largest_niche : None ,
476474 uninhabited : false ,
477- align,
478- size : size. align_to ( align. abi ) ,
475+ align : AbiAlign :: new ( align ) ,
476+ size : size. align_to ( align) ,
479477 max_repr_align,
480478 unadjusted_abi_align,
481479 randomization_seed : combined_seed,
@@ -611,15 +609,15 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
611609
612610 let mut align = dl. aggregate_align ;
613611 let mut max_repr_align = repr. align ;
614- let mut unadjusted_abi_align = align. abi ;
612+ let mut unadjusted_abi_align = align;
615613
616614 let mut variant_layouts = variants
617615 . iter_enumerated ( )
618616 . map ( |( j, v) | {
619617 let mut st = self . univariant ( v, repr, StructKind :: AlwaysSized ) . ok ( ) ?;
620618 st. variants = Variants :: Single { index : j } ;
621619
622- align = align. max ( st. align ) ;
620+ align = align. max ( st. align . abi ) ;
623621 max_repr_align = max_repr_align. max ( st. max_repr_align ) ;
624622 unadjusted_abi_align = unadjusted_abi_align. max ( st. unadjusted_abi_align ) ;
625623
@@ -646,7 +644,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
646644 let ( niche_start, niche_scalar) = niche. reserve ( dl, count) ?;
647645 let niche_offset = niche. offset ;
648646 let niche_size = niche. value . size ( dl) ;
649- let size = variant_layouts[ largest_variant_index] . size . align_to ( align. abi ) ;
647+ let size = variant_layouts[ largest_variant_index] . size . align_to ( align) ;
650648
651649 let all_variants_fit = variant_layouts. iter_enumerated_mut ( ) . all ( |( i, layout) | {
652650 if i == largest_variant_index {
@@ -699,7 +697,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
699697 . iter_enumerated ( )
700698 . all ( |( i, layout) | i == largest_variant_index || layout. size == Size :: ZERO ) ;
701699 let same_size = size == variant_layouts[ largest_variant_index] . size ;
702- let same_align = align == variant_layouts[ largest_variant_index] . align ;
700+ let same_align = align == variant_layouts[ largest_variant_index] . align . abi ;
703701
704702 let uninhabited = variant_layouts. iter ( ) . all ( |v| v. is_uninhabited ( ) ) ;
705703 let abi = if same_size && same_align && others_zst {
@@ -746,7 +744,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
746744 largest_niche,
747745 uninhabited,
748746 size,
749- align,
747+ align : AbiAlign :: new ( align ) ,
750748 max_repr_align,
751749 unadjusted_abi_align,
752750 randomization_seed : combined_seed,
@@ -818,7 +816,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
818816
819817 let mut align = dl. aggregate_align ;
820818 let mut max_repr_align = repr. align ;
821- let mut unadjusted_abi_align = align. abi ;
819+ let mut unadjusted_abi_align = align;
822820
823821 let mut size = Size :: ZERO ;
824822
@@ -860,15 +858,15 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
860858 }
861859 }
862860 size = cmp:: max ( size, st. size ) ;
863- align = align. max ( st. align ) ;
861+ align = align. max ( st. align . abi ) ;
864862 max_repr_align = max_repr_align. max ( st. max_repr_align ) ;
865863 unadjusted_abi_align = unadjusted_abi_align. max ( st. unadjusted_abi_align ) ;
866864 Ok ( st)
867865 } )
868866 . collect :: < Result < IndexVec < VariantIdx , _ > , _ > > ( ) ?;
869867
870868 // Align the maximum variant size to the largest alignment.
871- size = size. align_to ( align. abi ) ;
869+ size = size. align_to ( align) ;
872870
873871 // FIXME(oli-obk): deduplicate and harden these checks
874872 if size. bytes ( ) >= dl. obj_size_bound ( ) {
@@ -1042,7 +1040,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
10421040 } ;
10431041 if pair_offsets[ FieldIdx :: new ( 0 ) ] == Size :: ZERO
10441042 && pair_offsets[ FieldIdx :: new ( 1 ) ] == * offset
1045- && align == pair. align
1043+ && align == pair. align . abi
10461044 && size == pair. size
10471045 {
10481046 // We can use `ScalarPair` only when it matches our
@@ -1066,7 +1064,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
10661064 // Also need to bump up the size and alignment, so that the entire value fits
10671065 // in here.
10681066 variant. size = cmp:: max ( variant. size , size) ;
1069- variant. align . abi = cmp:: max ( variant. align . abi , align. abi ) ;
1067+ variant. align . abi = cmp:: max ( variant. align . abi , align) ;
10701068 }
10711069 }
10721070 }
@@ -1092,7 +1090,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
10921090 largest_niche,
10931091 uninhabited,
10941092 backend_repr : abi,
1095- align,
1093+ align : AbiAlign :: new ( align ) ,
10961094 size,
10971095 max_repr_align,
10981096 unadjusted_abi_align,
@@ -1169,7 +1167,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
11691167 // To allow unsizing `&Foo<Type>` -> `&Foo<dyn Trait>`, the layout of the struct must
11701168 // not depend on the layout of the tail.
11711169 let max_field_align =
1172- fields_excluding_tail. iter ( ) . map ( |f| f. align . abi . bytes ( ) ) . max ( ) . unwrap_or ( 1 ) ;
1170+ fields_excluding_tail. iter ( ) . map ( |f| f. align . bytes ( ) ) . max ( ) . unwrap_or ( 1 ) ;
11731171 let largest_niche_size = fields_excluding_tail
11741172 . iter ( )
11751173 . filter_map ( |f| f. largest_niche )
@@ -1189,7 +1187,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
11891187 } else {
11901188 // Returns `log2(effective-align)`. The calculation assumes that size is an
11911189 // integer multiple of align, except for ZSTs.
1192- let align = layout. align . abi . bytes ( ) ;
1190+ let align = layout. align . bytes ( ) ;
11931191 let size = layout. size . bytes ( ) ;
11941192 let niche_size = layout. largest_niche . map ( |n| n. available ( dl) ) . unwrap_or ( 0 ) ;
11951193 // Group [u8; 4] with align-4 or [u8; 6] with align-2 fields.
@@ -1288,7 +1286,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
12881286 if let StructKind :: Prefixed ( prefix_size, prefix_align) = kind {
12891287 let prefix_align =
12901288 if let Some ( pack) = pack { prefix_align. min ( pack) } else { prefix_align } ;
1291- align = align. max ( AbiAlign :: new ( prefix_align) ) ;
1289+ align = align. max ( prefix_align) ;
12921290 offset = prefix_size. align_to ( prefix_align) ;
12931291 }
12941292 for & i in & inverse_memory_index {
@@ -1312,7 +1310,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
13121310 field. align
13131311 } ;
13141312 offset = offset. align_to ( field_align. abi ) ;
1315- align = align. max ( field_align) ;
1313+ align = align. max ( field_align. abi ) ;
13161314 max_repr_align = max_repr_align. max ( field. max_repr_align ) ;
13171315
13181316 debug ! ( "univariant offset: {:?} field: {:#?}" , offset, field) ;
@@ -1339,9 +1337,9 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
13391337
13401338 // The unadjusted ABI alignment does not include repr(align), but does include repr(pack).
13411339 // See documentation on `LayoutData::unadjusted_abi_align`.
1342- let unadjusted_abi_align = align. abi ;
1340+ let unadjusted_abi_align = align;
13431341 if let Some ( repr_align) = repr. align {
1344- align = align. max ( AbiAlign :: new ( repr_align) ) ;
1342+ align = align. max ( repr_align) ;
13451343 }
13461344 // `align` must not be modified after this point, or `unadjusted_abi_align` could be inaccurate.
13471345 let align = align;
@@ -1360,7 +1358,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
13601358 debug_assert ! ( inverse_memory_index. iter( ) . copied( ) . eq( fields. indices( ) ) ) ;
13611359 inverse_memory_index. into_iter ( ) . map ( |it| it. index ( ) as u32 ) . collect ( )
13621360 } ;
1363- let size = min_size. align_to ( align. abi ) ;
1361+ let size = min_size. align_to ( align) ;
13641362 // FIXME(oli-obk): deduplicate and harden these checks
13651363 if size. bytes ( ) >= dl. obj_size_bound ( ) {
13661364 return Err ( LayoutCalculatorError :: SizeOverflow ) ;
@@ -1383,8 +1381,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
13831381 layout_of_single_non_zst_field = Some ( field) ;
13841382
13851383 // Field fills the struct and it has a scalar or scalar pair ABI.
1386- if offsets[ i] . bytes ( ) == 0 && align. abi == field. align . abi && size == field. size
1387- {
1384+ if offsets[ i] . bytes ( ) == 0 && align == field. align . abi && size == field. size {
13881385 match field. backend_repr {
13891386 // For plain scalars, or vectors of them, we can't unpack
13901387 // newtypes for `#[repr(C)]`, as that affects C ABIs.
@@ -1428,7 +1425,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
14281425 } ;
14291426 if offsets[ i] == pair_offsets[ FieldIdx :: new ( 0 ) ]
14301427 && offsets[ j] == pair_offsets[ FieldIdx :: new ( 1 ) ]
1431- && align == pair. align
1428+ && align == pair. align . abi
14321429 && size == pair. size
14331430 {
14341431 // We can use `ScalarPair` only when it matches our
@@ -1450,7 +1447,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
14501447 Some ( l) => l. unadjusted_abi_align ,
14511448 None => {
14521449 // `repr(transparent)` with all ZST fields.
1453- align. abi
1450+ align
14541451 }
14551452 }
14561453 } else {
@@ -1465,7 +1462,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
14651462 backend_repr : abi,
14661463 largest_niche,
14671464 uninhabited,
1468- align,
1465+ align : AbiAlign :: new ( align ) ,
14691466 size,
14701467 max_repr_align,
14711468 unadjusted_abi_align,
@@ -1488,7 +1485,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
14881485 for i in layout. fields . index_by_increasing_offset ( ) {
14891486 let offset = layout. fields . offset ( i) ;
14901487 let f = & fields[ FieldIdx :: new ( i) ] ;
1491- write ! ( s, "[o{}a{}s{}" , offset. bytes( ) , f. align. abi . bytes( ) , f. size. bytes( ) ) . unwrap ( ) ;
1488+ write ! ( s, "[o{}a{}s{}" , offset. bytes( ) , f. align. bytes( ) , f. size. bytes( ) ) . unwrap ( ) ;
14921489 if let Some ( n) = f. largest_niche {
14931490 write ! (
14941491 s,
0 commit comments