@@ -360,59 +360,57 @@ fn arg_local_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>,
360
360
let arg_decl = & mir. local_decls [ local] ;
361
361
let arg_ty = bcx. monomorphize ( & arg_decl. ty ) ;
362
362
363
- if let Some ( spread_local) = mir. spread_arg {
364
- if local == spread_local {
365
- // This argument (e.g. the last argument in the "rust-call" ABI)
366
- // is a tuple that was spread at the ABI level and now we have
367
- // to reconstruct it into a tuple local variable, from multiple
368
- // individual LLVM function arguments.
369
-
370
- let tupled_arg_tys = match arg_ty. sty {
371
- ty:: TyTuple ( ref tys) => tys,
372
- _ => bug ! ( "spread argument isn't a tuple?!" )
373
- } ;
363
+ if Some ( local) == mir. spread_arg {
364
+ // This argument (e.g. the last argument in the "rust-call" ABI)
365
+ // is a tuple that was spread at the ABI level and now we have
366
+ // to reconstruct it into a tuple local variable, from multiple
367
+ // individual LLVM function arguments.
368
+
369
+ let tupled_arg_tys = match arg_ty. sty {
370
+ ty:: TyTuple ( ref tys) => tys,
371
+ _ => bug ! ( "spread argument isn't a tuple?!" )
372
+ } ;
374
373
375
- let lltuplety = type_of:: type_of ( bcx. ccx ( ) , arg_ty) ;
376
- let lltemp = bcx. with_block ( |bcx| {
377
- base:: alloc_ty ( bcx, arg_ty, & format ! ( "arg{}" , arg_index) )
378
- } ) ;
379
- for ( i, & tupled_arg_ty) in tupled_arg_tys. iter ( ) . enumerate ( ) {
380
- let dst = bcx. struct_gep ( lltemp, i) ;
381
- let arg = & fcx. fn_ty . args [ idx] ;
374
+ let lltuplety = type_of:: type_of ( bcx. ccx ( ) , arg_ty) ;
375
+ let lltemp = bcx. with_block ( |bcx| {
376
+ base:: alloc_ty ( bcx, arg_ty, & format ! ( "arg{}" , arg_index) )
377
+ } ) ;
378
+ for ( i, & tupled_arg_ty) in tupled_arg_tys. iter ( ) . enumerate ( ) {
379
+ let dst = bcx. struct_gep ( lltemp, i) ;
380
+ let arg = & fcx. fn_ty . args [ idx] ;
381
+ idx += 1 ;
382
+ if common:: type_is_fat_ptr ( tcx, tupled_arg_ty) {
383
+ // We pass fat pointers as two words, but inside the tuple
384
+ // they are the two sub-fields of a single aggregate field.
385
+ let meta = & fcx. fn_ty . args [ idx] ;
382
386
idx += 1 ;
383
- if common:: type_is_fat_ptr ( tcx, tupled_arg_ty) {
384
- // We pass fat pointers as two words, but inside the tuple
385
- // they are the two sub-fields of a single aggregate field.
386
- let meta = & fcx. fn_ty . args [ idx] ;
387
- idx += 1 ;
388
- arg. store_fn_arg ( bcx, & mut llarg_idx, get_dataptr ( bcx, dst) ) ;
389
- meta. store_fn_arg ( bcx, & mut llarg_idx, get_meta ( bcx, dst) ) ;
390
- } else {
391
- arg. store_fn_arg ( bcx, & mut llarg_idx, dst) ;
392
- }
393
-
394
- bcx. with_block ( |bcx| arg_scope. map ( |scope| {
395
- let byte_offset_of_var_in_tuple =
396
- machine:: llelement_offset ( bcx. ccx ( ) , lltuplety, i) ;
397
-
398
- let ops = unsafe {
399
- [ llvm:: LLVMRustDIBuilderCreateOpDeref ( ) ,
400
- llvm:: LLVMRustDIBuilderCreateOpPlus ( ) ,
401
- byte_offset_of_var_in_tuple as i64 ]
402
- } ;
403
-
404
- let variable_access = VariableAccess :: IndirectVariable {
405
- alloca : lltemp,
406
- address_operations : & ops
407
- } ;
408
- declare_local ( bcx, keywords:: Invalid . name ( ) ,
409
- tupled_arg_ty, scope, variable_access,
410
- VariableKind :: ArgumentVariable ( arg_index + i + 1 ) ,
411
- bcx. fcx ( ) . span . unwrap_or ( DUMMY_SP ) ) ;
412
- } ) ) ;
387
+ arg. store_fn_arg ( bcx, & mut llarg_idx, get_dataptr ( bcx, dst) ) ;
388
+ meta. store_fn_arg ( bcx, & mut llarg_idx, get_meta ( bcx, dst) ) ;
389
+ } else {
390
+ arg. store_fn_arg ( bcx, & mut llarg_idx, dst) ;
413
391
}
414
- return LocalRef :: Lvalue ( LvalueRef :: new_sized ( lltemp, LvalueTy :: from_ty ( arg_ty) ) ) ;
392
+
393
+ bcx. with_block ( |bcx| arg_scope. map ( |scope| {
394
+ let byte_offset_of_var_in_tuple =
395
+ machine:: llelement_offset ( bcx. ccx ( ) , lltuplety, i) ;
396
+
397
+ let ops = unsafe {
398
+ [ llvm:: LLVMRustDIBuilderCreateOpDeref ( ) ,
399
+ llvm:: LLVMRustDIBuilderCreateOpPlus ( ) ,
400
+ byte_offset_of_var_in_tuple as i64 ]
401
+ } ;
402
+
403
+ let variable_access = VariableAccess :: IndirectVariable {
404
+ alloca : lltemp,
405
+ address_operations : & ops
406
+ } ;
407
+ declare_local ( bcx, keywords:: Invalid . name ( ) ,
408
+ tupled_arg_ty, scope, variable_access,
409
+ VariableKind :: ArgumentVariable ( arg_index + i + 1 ) ,
410
+ bcx. fcx ( ) . span . unwrap_or ( DUMMY_SP ) ) ;
411
+ } ) ) ;
415
412
}
413
+ return LocalRef :: Lvalue ( LvalueRef :: new_sized ( lltemp, LvalueTy :: from_ty ( arg_ty) ) ) ;
416
414
}
417
415
418
416
let arg = & fcx. fn_ty . args [ idx] ;
0 commit comments