@@ -1663,21 +1663,30 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> {
1663
1663
arg_ty,
1664
1664
datum:: Lvalue :: new ( "FunctionContext::bind_args" ) )
1665
1665
} else {
1666
- unpack_datum ! ( bcx, datum:: lvalue_scratch_datum( bcx, arg_ty, "" ,
1667
- uninit_reason,
1668
- arg_scope_id, |bcx, dst| {
1669
- debug!( "FunctionContext::bind_args: {:?}: {:?}" , hir_arg, arg_ty) ;
1666
+ let lltmp = if common:: type_is_fat_ptr ( bcx. tcx ( ) , arg_ty) {
1667
+ let lltemp = alloc_ty ( bcx, arg_ty, "" ) ;
1670
1668
let b = & bcx. build ( ) ;
1671
- if common:: type_is_fat_ptr( bcx. tcx( ) , arg_ty) {
1672
- let meta = & self . fn_ty. args[ idx] ;
1673
- idx += 1 ;
1674
- arg. store_fn_arg( b, & mut llarg_idx, expr:: get_dataptr( bcx, dst) ) ;
1675
- meta. store_fn_arg( b, & mut llarg_idx, expr:: get_meta( bcx, dst) ) ;
1676
- } else {
1677
- arg. store_fn_arg( b, & mut llarg_idx, dst) ;
1678
- }
1679
- bcx
1680
- } ) )
1669
+ // we pass fat pointers as two words, but we want to
1670
+ // represent them internally as a pointer to two words,
1671
+ // so make an alloca to store them in.
1672
+ let meta = & self . fn_ty . args [ idx] ;
1673
+ idx += 1 ;
1674
+ arg. store_fn_arg ( b, & mut llarg_idx, expr:: get_dataptr ( bcx, lltemp) ) ;
1675
+ meta. store_fn_arg ( b, & mut llarg_idx, expr:: get_meta ( bcx, lltemp) ) ;
1676
+ lltemp
1677
+ } else {
1678
+ // otherwise, arg is passed by value, so store it into a temporary.
1679
+ let llarg_ty = arg. cast . unwrap_or ( arg. memory_ty ( bcx. ccx ( ) ) ) ;
1680
+ let lltemp = alloca ( bcx, llarg_ty, "" ) ;
1681
+ let b = & bcx. build ( ) ;
1682
+ arg. store_fn_arg ( b, & mut llarg_idx, lltemp) ;
1683
+ // And coerce the temporary into the type we expect.
1684
+ b. pointercast ( lltemp, arg. memory_ty ( bcx. ccx ( ) ) . ptr_to ( ) )
1685
+ } ;
1686
+
1687
+ // FIXME: hacky lol?
1688
+ datum:: Datum :: new ( lltmp, arg_ty,
1689
+ datum:: Lvalue :: new ( "datum::lvalue_scratch_datum" ) )
1681
1690
}
1682
1691
} else {
1683
1692
// FIXME(pcwalton): Reduce the amount of code bloat this is responsible for.
0 commit comments