@@ -40,21 +40,13 @@ fn clif_sig_from_fn_abi<'tcx>(
40
40
| Conv :: AvrInterrupt
41
41
| Conv :: AvrNonBlockingInterrupt => todo ! ( "{:?}" , fn_abi. conv) ,
42
42
} ;
43
- let inputs = fn_abi
44
- . args
45
- . iter ( )
46
- . map ( |arg_abi| arg_abi. get_abi_param ( tcx) . into_iter ( ) )
47
- . flatten ( ) ;
43
+ let inputs = fn_abi. args . iter ( ) . map ( |arg_abi| arg_abi. get_abi_param ( tcx) . into_iter ( ) ) . flatten ( ) ;
48
44
49
45
let ( return_ptr, returns) = fn_abi. ret . get_abi_return ( tcx) ;
50
46
// Sometimes the first param is an pointer to the place where the return value needs to be stored.
51
47
let params: Vec < _ > = return_ptr. into_iter ( ) . chain ( inputs) . collect ( ) ;
52
48
53
- Signature {
54
- params,
55
- returns,
56
- call_conv,
57
- }
49
+ Signature { params, returns, call_conv }
58
50
}
59
51
60
52
pub ( crate ) fn get_function_sig < ' tcx > (
@@ -63,11 +55,7 @@ pub(crate) fn get_function_sig<'tcx>(
63
55
inst : Instance < ' tcx > ,
64
56
) -> Signature {
65
57
assert ! ( !inst. substs. needs_infer( ) ) ;
66
- clif_sig_from_fn_abi (
67
- tcx,
68
- triple,
69
- & FnAbi :: of_instance ( & RevealAllLayoutCx ( tcx) , inst, & [ ] ) ,
70
- )
58
+ clif_sig_from_fn_abi ( tcx, triple, & FnAbi :: of_instance ( & RevealAllLayoutCx ( tcx) , inst, & [ ] ) )
71
59
}
72
60
73
61
/// Instance must be monomorphized
@@ -78,19 +66,14 @@ pub(crate) fn import_function<'tcx>(
78
66
) -> FuncId {
79
67
let name = tcx. symbol_name ( inst) . name . to_string ( ) ;
80
68
let sig = get_function_sig ( tcx, module. isa ( ) . triple ( ) , inst) ;
81
- module
82
- . declare_function ( & name, Linkage :: Import , & sig)
83
- . unwrap ( )
69
+ module. declare_function ( & name, Linkage :: Import , & sig) . unwrap ( )
84
70
}
85
71
86
72
impl < ' tcx > FunctionCx < ' _ , ' _ , ' tcx > {
87
73
/// Instance must be monomorphized
88
74
pub ( crate ) fn get_function_ref ( & mut self , inst : Instance < ' tcx > ) -> FuncRef {
89
75
let func_id = import_function ( self . tcx , self . cx . module , inst) ;
90
- let func_ref = self
91
- . cx
92
- . module
93
- . declare_func_in_func ( func_id, & mut self . bcx . func ) ;
76
+ let func_ref = self . cx . module . declare_func_in_func ( func_id, & mut self . bcx . func ) ;
94
77
95
78
#[ cfg( debug_assertions) ]
96
79
self . add_comment ( func_ref, format ! ( "{:?}" , inst) ) ;
@@ -105,20 +88,9 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
105
88
returns : Vec < AbiParam > ,
106
89
args : & [ Value ] ,
107
90
) -> & [ Value ] {
108
- let sig = Signature {
109
- params,
110
- returns,
111
- call_conv : CallConv :: triple_default ( self . triple ( ) ) ,
112
- } ;
113
- let func_id = self
114
- . cx
115
- . module
116
- . declare_function ( & name, Linkage :: Import , & sig)
117
- . unwrap ( ) ;
118
- let func_ref = self
119
- . cx
120
- . module
121
- . declare_func_in_func ( func_id, & mut self . bcx . func ) ;
91
+ let sig = Signature { params, returns, call_conv : CallConv :: triple_default ( self . triple ( ) ) } ;
92
+ let func_id = self . cx . module . declare_function ( & name, Linkage :: Import , & sig) . unwrap ( ) ;
93
+ let func_ref = self . cx . module . declare_func_in_func ( func_id, & mut self . bcx . func ) ;
122
94
let call_inst = self . bcx . ins ( ) . call ( func_ref, args) ;
123
95
#[ cfg( debug_assertions) ]
124
96
{
@@ -138,17 +110,12 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
138
110
let ( input_tys, args) : ( Vec < _ > , Vec < _ > ) = args
139
111
. iter ( )
140
112
. map ( |arg| {
141
- (
142
- AbiParam :: new ( self . clif_type ( arg. layout ( ) . ty ) . unwrap ( ) ) ,
143
- arg. load_scalar ( self ) ,
144
- )
113
+ ( AbiParam :: new ( self . clif_type ( arg. layout ( ) . ty ) . unwrap ( ) ) , arg. load_scalar ( self ) )
145
114
} )
146
115
. unzip ( ) ;
147
116
let return_layout = self . layout_of ( return_ty) ;
148
117
let return_tys = if let ty:: Tuple ( tup) = return_ty. kind ( ) {
149
- tup. types ( )
150
- . map ( |ty| AbiParam :: new ( self . clif_type ( ty) . unwrap ( ) ) )
151
- . collect ( )
118
+ tup. types ( ) . map ( |ty| AbiParam :: new ( self . clif_type ( ty) . unwrap ( ) ) ) . collect ( )
152
119
} else {
153
120
vec ! [ AbiParam :: new( self . clif_type( return_ty) . unwrap( ) ) ]
154
121
} ;
@@ -199,13 +166,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
199
166
#[ cfg( debug_assertions) ]
200
167
self :: comments:: add_args_header_comment ( fx) ;
201
168
202
- let mut block_params_iter = fx
203
- . bcx
204
- . func
205
- . dfg
206
- . block_params ( start_block)
207
- . to_vec ( )
208
- . into_iter ( ) ;
169
+ let mut block_params_iter = fx. bcx . func . dfg . block_params ( start_block) . to_vec ( ) . into_iter ( ) ;
209
170
let ret_place =
210
171
self :: returning:: codegen_return_param ( fx, & ssa_analyzed, & mut block_params_iter) ;
211
172
assert_eq ! ( fx. local_map. push( ret_place) , RETURN_PLACE ) ;
@@ -281,10 +242,10 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
281
242
if let Some ( ( addr, meta) ) = val. try_to_ptr ( ) {
282
243
let local_decl = & fx. mir . local_decls [ local] ;
283
244
// v this ! is important
284
- let internally_mutable = !val. layout ( ) . ty . is_freeze (
285
- fx . tcx . at ( local_decl . source_info . span ) ,
286
- ParamEnv :: reveal_all ( ) ,
287
- ) ;
245
+ let internally_mutable = !val
246
+ . layout ( )
247
+ . ty
248
+ . is_freeze ( fx . tcx . at ( local_decl . source_info . span ) , ParamEnv :: reveal_all ( ) ) ;
288
249
if local_decl. mutability == mir:: Mutability :: Not && !internally_mutable {
289
250
// We wont mutate this argument, so it is fine to borrow the backing storage
290
251
// of this argument, to prevent a copy.
@@ -316,9 +277,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
316
277
ArgKind :: Spread ( params) => {
317
278
for ( i, param) in params. into_iter ( ) . enumerate ( ) {
318
279
if let Some ( param) = param {
319
- place
320
- . place_field ( fx, mir:: Field :: new ( i) )
321
- . write_cvalue ( fx, param) ;
280
+ place. place_field ( fx, mir:: Field :: new ( i) ) . write_cvalue ( fx, param) ;
322
281
}
323
282
}
324
283
}
@@ -335,9 +294,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
335
294
assert_eq ! ( fx. local_map. push( place) , local) ;
336
295
}
337
296
338
- fx. bcx
339
- . ins ( )
340
- . jump ( * fx. block_map . get ( START_BLOCK ) . unwrap ( ) , & [ ] ) ;
297
+ fx. bcx . ins ( ) . jump ( * fx. block_map . get ( START_BLOCK ) . unwrap ( ) , & [ ] ) ;
341
298
}
342
299
343
300
pub ( crate ) fn codegen_terminator_call < ' tcx > (
@@ -349,9 +306,8 @@ pub(crate) fn codegen_terminator_call<'tcx>(
349
306
destination : Option < ( Place < ' tcx > , BasicBlock ) > ,
350
307
) {
351
308
let fn_ty = fx. monomorphize ( func. ty ( fx. mir , fx. tcx ) ) ;
352
- let fn_sig = fx
353
- . tcx
354
- . normalize_erasing_late_bound_regions ( ParamEnv :: reveal_all ( ) , fn_ty. fn_sig ( fx. tcx ) ) ;
309
+ let fn_sig =
310
+ fx. tcx . normalize_erasing_late_bound_regions ( ParamEnv :: reveal_all ( ) , fn_ty. fn_sig ( fx. tcx ) ) ;
355
311
356
312
let destination = destination. map ( |( place, bb) | ( codegen_place ( fx, place) , bb) ) ;
357
313
@@ -399,20 +355,11 @@ pub(crate) fn codegen_terminator_call<'tcx>(
399
355
let fn_abi = if let Some ( instance) = instance {
400
356
FnAbi :: of_instance ( & RevealAllLayoutCx ( fx. tcx ) , instance, & extra_args)
401
357
} else {
402
- FnAbi :: of_fn_ptr (
403
- & RevealAllLayoutCx ( fx. tcx ) ,
404
- fn_ty. fn_sig ( fx. tcx ) ,
405
- & extra_args,
406
- )
358
+ FnAbi :: of_fn_ptr ( & RevealAllLayoutCx ( fx. tcx ) , fn_ty. fn_sig ( fx. tcx ) , & extra_args)
407
359
} ;
408
360
409
361
let is_cold = instance
410
- . map ( |inst| {
411
- fx. tcx
412
- . codegen_fn_attrs ( inst. def_id ( ) )
413
- . flags
414
- . contains ( CodegenFnAttrFlags :: COLD )
415
- } )
362
+ . map ( |inst| fx. tcx . codegen_fn_attrs ( inst. def_id ( ) ) . flags . contains ( CodegenFnAttrFlags :: COLD ) )
416
363
. unwrap_or ( false ) ;
417
364
if is_cold {
418
365
fx. cold_blocks . insert ( current_block) ;
@@ -436,20 +383,15 @@ pub(crate) fn codegen_terminator_call<'tcx>(
436
383
}
437
384
args
438
385
} else {
439
- args. iter ( )
440
- . map ( |arg| codegen_operand ( fx, arg) )
441
- . collect :: < Vec < _ > > ( )
386
+ args. iter ( ) . map ( |arg| codegen_operand ( fx, arg) ) . collect :: < Vec < _ > > ( )
442
387
} ;
443
388
444
389
// | indirect call target
445
390
// | | the first argument to be passed
446
391
// v v
447
392
let ( func_ref, first_arg) = match instance {
448
393
// Trait object call
449
- Some ( Instance {
450
- def : InstanceDef :: Virtual ( _, idx) ,
451
- ..
452
- } ) => {
394
+ Some ( Instance { def : InstanceDef :: Virtual ( _, idx) , .. } ) => {
453
395
#[ cfg( debug_assertions) ]
454
396
{
455
397
let nop_inst = fx. bcx . ins ( ) . nop ( ) ;
@@ -506,10 +448,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
506
448
)
507
449
. collect :: < Vec < _ > > ( ) ;
508
450
509
- if instance
510
- . map ( |inst| inst. def . requires_caller_location ( fx. tcx ) )
511
- . unwrap_or ( false )
512
- {
451
+ if instance. map ( |inst| inst. def . requires_caller_location ( fx. tcx ) ) . unwrap_or ( false ) {
513
452
// Pass the caller location for `#[track_caller]`.
514
453
let caller_location = fx. get_caller_location ( span) ;
515
454
call_args. extend (
@@ -538,10 +477,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
538
477
// FIXME find a cleaner way to support varargs
539
478
if fn_sig. c_variadic {
540
479
if fn_sig. abi != Abi :: C {
541
- fx. tcx . sess . span_fatal (
542
- span,
543
- & format ! ( "Variadic call for non-C abi {:?}" , fn_sig. abi) ,
544
- ) ;
480
+ fx. tcx . sess . span_fatal ( span, & format ! ( "Variadic call for non-C abi {:?}" , fn_sig. abi) ) ;
545
481
}
546
482
let sig_ref = fx. bcx . func . dfg . call_signature ( call_inst) . unwrap ( ) ;
547
483
let abi_params = call_args
@@ -550,9 +486,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
550
486
let ty = fx. bcx . func . dfg . value_type ( arg) ;
551
487
if !ty. is_int ( ) {
552
488
// FIXME set %al to upperbound on float args once floats are supported
553
- fx. tcx
554
- . sess
555
- . span_fatal ( span, & format ! ( "Non int ty {:?} for variadic call" , ty) ) ;
489
+ fx. tcx . sess . span_fatal ( span, & format ! ( "Non int ty {:?} for variadic call" , ty) ) ;
556
490
}
557
491
AbiParam :: new ( ty)
558
492
} )
@@ -606,10 +540,7 @@ pub(crate) fn codegen_drop<'tcx>(
606
540
fx,
607
541
fx. layout_of ( fx. tcx . mk_ref (
608
542
& ty:: RegionKind :: ReErased ,
609
- TypeAndMut {
610
- ty,
611
- mutbl : crate :: rustc_hir:: Mutability :: Mut ,
612
- } ,
543
+ TypeAndMut { ty, mutbl : crate :: rustc_hir:: Mutability :: Mut } ,
613
544
) ) ,
614
545
) ;
615
546
let arg_value = adjust_arg_for_abi ( fx, arg_value, & fn_abi. args [ 0 ] ) ;
0 commit comments