@@ -40,21 +40,13 @@ fn clif_sig_from_fn_abi<'tcx>(
4040 | Conv :: AvrInterrupt
4141 | Conv :: AvrNonBlockingInterrupt => todo ! ( "{:?}" , fn_abi. conv) ,
4242 } ;
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 ( ) ;
4844
4945 let ( return_ptr, returns) = fn_abi. ret . get_abi_return ( tcx) ;
5046 // Sometimes the first param is an pointer to the place where the return value needs to be stored.
5147 let params: Vec < _ > = return_ptr. into_iter ( ) . chain ( inputs) . collect ( ) ;
5248
53- Signature {
54- params,
55- returns,
56- call_conv,
57- }
49+ Signature { params, returns, call_conv }
5850}
5951
6052pub ( crate ) fn get_function_sig < ' tcx > (
@@ -63,11 +55,7 @@ pub(crate) fn get_function_sig<'tcx>(
6355 inst : Instance < ' tcx > ,
6456) -> Signature {
6557 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, & [ ] ) )
7159}
7260
7361/// Instance must be monomorphized
@@ -78,19 +66,14 @@ pub(crate) fn import_function<'tcx>(
7866) -> FuncId {
7967 let name = tcx. symbol_name ( inst) . name . to_string ( ) ;
8068 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 ( )
8470}
8571
8672impl < ' tcx > FunctionCx < ' _ , ' _ , ' tcx > {
8773 /// Instance must be monomorphized
8874 pub ( crate ) fn get_function_ref ( & mut self , inst : Instance < ' tcx > ) -> FuncRef {
8975 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 ) ;
9477
9578 #[ cfg( debug_assertions) ]
9679 self . add_comment ( func_ref, format ! ( "{:?}" , inst) ) ;
@@ -105,20 +88,9 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
10588 returns : Vec < AbiParam > ,
10689 args : & [ Value ] ,
10790 ) -> & [ 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 ) ;
12294 let call_inst = self . bcx . ins ( ) . call ( func_ref, args) ;
12395 #[ cfg( debug_assertions) ]
12496 {
@@ -138,17 +110,12 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
138110 let ( input_tys, args) : ( Vec < _ > , Vec < _ > ) = args
139111 . iter ( )
140112 . 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 ) )
145114 } )
146115 . unzip ( ) ;
147116 let return_layout = self . layout_of ( return_ty) ;
148117 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 ( )
152119 } else {
153120 vec ! [ AbiParam :: new( self . clif_type( return_ty) . unwrap( ) ) ]
154121 } ;
@@ -199,13 +166,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
199166 #[ cfg( debug_assertions) ]
200167 self :: comments:: add_args_header_comment ( fx) ;
201168
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 ( ) ;
209170 let ret_place =
210171 self :: returning:: codegen_return_param ( fx, & ssa_analyzed, & mut block_params_iter) ;
211172 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_
281242 if let Some ( ( addr, meta) ) = val. try_to_ptr ( ) {
282243 let local_decl = & fx. mir . local_decls [ local] ;
283244 // 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 ( ) ) ;
288249 if local_decl. mutability == mir:: Mutability :: Not && !internally_mutable {
289250 // We wont mutate this argument, so it is fine to borrow the backing storage
290251 // of this argument, to prevent a copy.
@@ -316,9 +277,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
316277 ArgKind :: Spread ( params) => {
317278 for ( i, param) in params. into_iter ( ) . enumerate ( ) {
318279 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) ;
322281 }
323282 }
324283 }
@@ -335,9 +294,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
335294 assert_eq ! ( fx. local_map. push( place) , local) ;
336295 }
337296
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 ( ) , & [ ] ) ;
341298}
342299
343300pub ( crate ) fn codegen_terminator_call < ' tcx > (
@@ -349,9 +306,8 @@ pub(crate) fn codegen_terminator_call<'tcx>(
349306 destination : Option < ( Place < ' tcx > , BasicBlock ) > ,
350307) {
351308 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 ) ) ;
355311
356312 let destination = destination. map ( |( place, bb) | ( codegen_place ( fx, place) , bb) ) ;
357313
@@ -399,20 +355,11 @@ pub(crate) fn codegen_terminator_call<'tcx>(
399355 let fn_abi = if let Some ( instance) = instance {
400356 FnAbi :: of_instance ( & RevealAllLayoutCx ( fx. tcx ) , instance, & extra_args)
401357 } 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)
407359 } ;
408360
409361 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 ) )
416363 . unwrap_or ( false ) ;
417364 if is_cold {
418365 fx. cold_blocks . insert ( current_block) ;
@@ -436,20 +383,15 @@ pub(crate) fn codegen_terminator_call<'tcx>(
436383 }
437384 args
438385 } 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 < _ > > ( )
442387 } ;
443388
444389 // | indirect call target
445390 // | | the first argument to be passed
446391 // v v
447392 let ( func_ref, first_arg) = match instance {
448393 // Trait object call
449- Some ( Instance {
450- def : InstanceDef :: Virtual ( _, idx) ,
451- ..
452- } ) => {
394+ Some ( Instance { def : InstanceDef :: Virtual ( _, idx) , .. } ) => {
453395 #[ cfg( debug_assertions) ]
454396 {
455397 let nop_inst = fx. bcx . ins ( ) . nop ( ) ;
@@ -506,10 +448,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
506448 )
507449 . collect :: < Vec < _ > > ( ) ;
508450
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 ) {
513452 // Pass the caller location for `#[track_caller]`.
514453 let caller_location = fx. get_caller_location ( span) ;
515454 call_args. extend (
@@ -538,10 +477,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
538477 // FIXME find a cleaner way to support varargs
539478 if fn_sig. c_variadic {
540479 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) ) ;
545481 }
546482 let sig_ref = fx. bcx . func . dfg . call_signature ( call_inst) . unwrap ( ) ;
547483 let abi_params = call_args
@@ -550,9 +486,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
550486 let ty = fx. bcx . func . dfg . value_type ( arg) ;
551487 if !ty. is_int ( ) {
552488 // 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) ) ;
556490 }
557491 AbiParam :: new ( ty)
558492 } )
@@ -606,10 +540,7 @@ pub(crate) fn codegen_drop<'tcx>(
606540 fx,
607541 fx. layout_of ( fx. tcx . mk_ref (
608542 & ty:: RegionKind :: ReErased ,
609- TypeAndMut {
610- ty,
611- mutbl : crate :: rustc_hir:: Mutability :: Mut ,
612- } ,
543+ TypeAndMut { ty, mutbl : crate :: rustc_hir:: Mutability :: Mut } ,
613544 ) ) ,
614545 ) ;
615546 let arg_value = adjust_arg_for_abi ( fx, arg_value, & fn_abi. args [ 0 ] ) ;
0 commit comments