@@ -455,8 +455,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
455455
456456 PassMode :: Direct ( _) | PassMode :: Pair ( ..) => {
457457 let op = self . codegen_consume ( bx, mir:: Place :: return_place ( ) . as_ref ( ) ) ;
458- if let Ref ( llval , _ , align ) = op. val {
459- bx. load ( bx. backend_type ( op. layout ) , llval, align)
458+ if let Ref ( place_val ) = op. val {
459+ bx. load ( bx. backend_type ( op. layout ) , place_val . llval , place_val . align )
460460 } else {
461461 op. immediate_or_packed_pair ( bx)
462462 }
@@ -466,10 +466,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
466466 let op = match self . locals [ mir:: RETURN_PLACE ] {
467467 LocalRef :: Operand ( op) => op,
468468 LocalRef :: PendingOperand => bug ! ( "use of return before def" ) ,
469- LocalRef :: Place ( cg_place) => OperandRef {
470- val : Ref ( cg_place. val . llval , None , cg_place. val . align ) ,
471- layout : cg_place. layout ,
472- } ,
469+ LocalRef :: Place ( cg_place) => {
470+ OperandRef { val : Ref ( cg_place. val ) , layout : cg_place. layout }
471+ }
473472 LocalRef :: UnsizedPlace ( _) => bug ! ( "return type must be sized" ) ,
474473 } ;
475474 let llslot = match op. val {
@@ -478,9 +477,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
478477 op. val . store ( bx, scratch) ;
479478 scratch. val . llval
480479 }
481- Ref ( llval, _, align) => {
482- assert_eq ! ( align, op. layout. align. abi, "return place is unaligned!" ) ;
483- llval
480+ Ref ( place_val) => {
481+ assert_eq ! (
482+ place_val. align, op. layout. align. abi,
483+ "return place is unaligned!"
484+ ) ;
485+ place_val. llval
484486 }
485487 ZeroSized => bug ! ( "ZST return value shouldn't be in PassMode::Cast" ) ,
486488 } ;
@@ -1032,7 +1034,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10321034 llargs. push ( data_ptr) ;
10331035 continue ' make_args;
10341036 }
1035- Ref ( data_ptr, Some ( meta) , _ ) => {
1037+ Ref ( PlaceValue { llval : data_ptr, llextra : Some ( meta) , .. } ) => {
10361038 // by-value dynamic dispatch
10371039 llfn = Some ( meth:: VirtualIndex :: from_index ( idx) . get_fn (
10381040 bx,
@@ -1079,12 +1081,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10791081 // The callee needs to own the argument memory if we pass it
10801082 // by-ref, so make a local copy of non-immediate constants.
10811083 match ( & arg. node , op. val ) {
1082- ( & mir:: Operand :: Copy ( _) , Ref ( _ , None , _ ) )
1083- | ( & mir:: Operand :: Constant ( _) , Ref ( _ , None , _ ) ) => {
1084+ ( & mir:: Operand :: Copy ( _) , Ref ( PlaceValue { llextra : None , .. } ) )
1085+ | ( & mir:: Operand :: Constant ( _) , Ref ( PlaceValue { llextra : None , .. } ) ) => {
10841086 let tmp = PlaceRef :: alloca ( bx, op. layout ) ;
10851087 bx. lifetime_start ( tmp. val . llval , tmp. layout . size ) ;
10861088 op. val . store ( bx, tmp) ;
1087- op. val = Ref ( tmp. val . llval , None , tmp . val . align ) ;
1089+ op. val = Ref ( tmp. val ) ;
10881090 copied_constant_arguments. push ( tmp) ;
10891091 }
10901092 _ => { }
@@ -1428,7 +1430,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
14281430 _ => bug ! ( "codegen_argument: {:?} invalid for pair argument" , op) ,
14291431 } ,
14301432 PassMode :: Indirect { attrs : _, meta_attrs : Some ( _) , on_stack : _ } => match op. val {
1431- Ref ( a, Some ( b) , _ ) => {
1433+ Ref ( PlaceValue { llval : a, llextra : Some ( b) , .. } ) => {
14321434 llargs. push ( a) ;
14331435 llargs. push ( b) ;
14341436 return ;
@@ -1459,28 +1461,25 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
14591461 }
14601462 _ => ( op. immediate_or_packed_pair ( bx) , arg. layout . align . abi , false ) ,
14611463 } ,
1462- Ref ( llval , llextra , align ) => match arg. mode {
1464+ Ref ( op_place_val ) => match arg. mode {
14631465 PassMode :: Indirect { attrs, .. } => {
14641466 let required_align = match attrs. pointee_align {
14651467 Some ( pointee_align) => cmp:: max ( pointee_align, arg. layout . align . abi ) ,
14661468 None => arg. layout . align . abi ,
14671469 } ;
1468- if align < required_align {
1470+ if op_place_val . align < required_align {
14691471 // For `foo(packed.large_field)`, and types with <4 byte alignment on x86,
14701472 // alignment requirements may be higher than the type's alignment, so copy
14711473 // to a higher-aligned alloca.
14721474 let scratch = PlaceRef :: alloca_aligned ( bx, arg. layout , required_align) ;
1473- let op_place = PlaceRef {
1474- val : PlaceValue { llval, llextra, align } ,
1475- layout : op. layout ,
1476- } ;
1475+ let op_place = PlaceRef { val : op_place_val, layout : op. layout } ;
14771476 bx. typed_place_copy ( scratch, op_place) ;
14781477 ( scratch. val . llval , scratch. val . align , true )
14791478 } else {
1480- ( llval, align, true )
1479+ ( op_place_val . llval , op_place_val . align , true )
14811480 }
14821481 }
1483- _ => ( llval, align, true ) ,
1482+ _ => ( op_place_val . llval , op_place_val . align , true ) ,
14841483 } ,
14851484 ZeroSized => match arg. mode {
14861485 PassMode :: Indirect { on_stack, .. } => {
@@ -1560,15 +1559,16 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
15601559 let tuple = self . codegen_operand ( bx, operand) ;
15611560
15621561 // Handle both by-ref and immediate tuples.
1563- if let Ref ( llval, None , align) = tuple. val {
1564- let tuple_ptr = PlaceRef :: new_sized_aligned ( llval, tuple. layout , align) ;
1562+ if let Ref ( place_val) = tuple. val {
1563+ if place_val. llextra . is_some ( ) {
1564+ bug ! ( "closure arguments must be sized" ) ;
1565+ }
1566+ let tuple_ptr = PlaceRef { val : place_val, layout : tuple. layout } ;
15651567 for i in 0 ..tuple. layout . fields . count ( ) {
15661568 let field_ptr = tuple_ptr. project_field ( bx, i) ;
15671569 let field = bx. load_operand ( field_ptr) ;
15681570 self . codegen_argument ( bx, field, llargs, & args[ i] ) ;
15691571 }
1570- } else if let Ref ( _, Some ( _) , _) = tuple. val {
1571- bug ! ( "closure arguments must be sized" )
15721572 } else {
15731573 // If the tuple is immediate, the elements are as well.
15741574 for i in 0 ..tuple. layout . fields . count ( ) {
0 commit comments