@@ -455,8 +455,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
455
455
456
456
PassMode :: Direct ( _) | PassMode :: Pair ( ..) => {
457
457
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 )
460
460
} else {
461
461
op. immediate_or_packed_pair ( bx)
462
462
}
@@ -466,10 +466,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
466
466
let op = match self . locals [ mir:: RETURN_PLACE ] {
467
467
LocalRef :: Operand ( op) => op,
468
468
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
+ }
473
472
LocalRef :: UnsizedPlace ( _) => bug ! ( "return type must be sized" ) ,
474
473
} ;
475
474
let llslot = match op. val {
@@ -478,9 +477,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
478
477
op. val . store ( bx, scratch) ;
479
478
scratch. val . llval
480
479
}
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
484
486
}
485
487
ZeroSized => bug ! ( "ZST return value shouldn't be in PassMode::Cast" ) ,
486
488
} ;
@@ -1032,7 +1034,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1032
1034
llargs. push ( data_ptr) ;
1033
1035
continue ' make_args;
1034
1036
}
1035
- Ref ( data_ptr, Some ( meta) , _ ) => {
1037
+ Ref ( PlaceValue { llval : data_ptr, llextra : Some ( meta) , .. } ) => {
1036
1038
// by-value dynamic dispatch
1037
1039
llfn = Some ( meth:: VirtualIndex :: from_index ( idx) . get_fn (
1038
1040
bx,
@@ -1079,12 +1081,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1079
1081
// The callee needs to own the argument memory if we pass it
1080
1082
// by-ref, so make a local copy of non-immediate constants.
1081
1083
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 , .. } ) ) => {
1084
1086
let tmp = PlaceRef :: alloca ( bx, op. layout ) ;
1085
1087
bx. lifetime_start ( tmp. val . llval , tmp. layout . size ) ;
1086
1088
op. val . store ( bx, tmp) ;
1087
- op. val = Ref ( tmp. val . llval , None , tmp . val . align ) ;
1089
+ op. val = Ref ( tmp. val ) ;
1088
1090
copied_constant_arguments. push ( tmp) ;
1089
1091
}
1090
1092
_ => { }
@@ -1428,7 +1430,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1428
1430
_ => bug ! ( "codegen_argument: {:?} invalid for pair argument" , op) ,
1429
1431
} ,
1430
1432
PassMode :: Indirect { attrs : _, meta_attrs : Some ( _) , on_stack : _ } => match op. val {
1431
- Ref ( a, Some ( b) , _ ) => {
1433
+ Ref ( PlaceValue { llval : a, llextra : Some ( b) , .. } ) => {
1432
1434
llargs. push ( a) ;
1433
1435
llargs. push ( b) ;
1434
1436
return ;
@@ -1459,28 +1461,25 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1459
1461
}
1460
1462
_ => ( op. immediate_or_packed_pair ( bx) , arg. layout . align . abi , false ) ,
1461
1463
} ,
1462
- Ref ( llval , llextra , align ) => match arg. mode {
1464
+ Ref ( op_place_val ) => match arg. mode {
1463
1465
PassMode :: Indirect { attrs, .. } => {
1464
1466
let required_align = match attrs. pointee_align {
1465
1467
Some ( pointee_align) => cmp:: max ( pointee_align, arg. layout . align . abi ) ,
1466
1468
None => arg. layout . align . abi ,
1467
1469
} ;
1468
- if align < required_align {
1470
+ if op_place_val . align < required_align {
1469
1471
// For `foo(packed.large_field)`, and types with <4 byte alignment on x86,
1470
1472
// alignment requirements may be higher than the type's alignment, so copy
1471
1473
// to a higher-aligned alloca.
1472
1474
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 } ;
1477
1476
bx. typed_place_copy ( scratch, op_place) ;
1478
1477
( scratch. val . llval , scratch. val . align , true )
1479
1478
} else {
1480
- ( llval, align, true )
1479
+ ( op_place_val . llval , op_place_val . align , true )
1481
1480
}
1482
1481
}
1483
- _ => ( llval, align, true ) ,
1482
+ _ => ( op_place_val . llval , op_place_val . align , true ) ,
1484
1483
} ,
1485
1484
ZeroSized => match arg. mode {
1486
1485
PassMode :: Indirect { on_stack, .. } => {
@@ -1560,15 +1559,16 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1560
1559
let tuple = self . codegen_operand ( bx, operand) ;
1561
1560
1562
1561
// 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 } ;
1565
1567
for i in 0 ..tuple. layout . fields . count ( ) {
1566
1568
let field_ptr = tuple_ptr. project_field ( bx, i) ;
1567
1569
let field = bx. load_operand ( field_ptr) ;
1568
1570
self . codegen_argument ( bx, field, llargs, & args[ i] ) ;
1569
1571
}
1570
- } else if let Ref ( _, Some ( _) , _) = tuple. val {
1571
- bug ! ( "closure arguments must be sized" )
1572
1572
} else {
1573
1573
// If the tuple is immediate, the elements are as well.
1574
1574
for i in 0 ..tuple. layout . fields . count ( ) {
0 commit comments