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