@@ -4,6 +4,7 @@ mod pass_mode;
4
4
mod returning;
5
5
6
6
use rustc_target:: spec:: abi:: Abi ;
7
+ use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
7
8
8
9
use cranelift_codegen:: ir:: AbiParam ;
9
10
@@ -431,6 +432,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>(
431
432
pub ( crate ) fn codegen_terminator_call < ' tcx > (
432
433
fx : & mut FunctionCx < ' _ , ' tcx , impl Backend > ,
433
434
span : Span ,
435
+ current_block : Block ,
434
436
func : & Operand < ' tcx > ,
435
437
args : & [ Operand < ' tcx > ] ,
436
438
destination : Option < ( Place < ' tcx > , BasicBlock ) > ,
@@ -440,8 +442,6 @@ pub(crate) fn codegen_terminator_call<'tcx>(
440
442
. tcx
441
443
. normalize_erasing_late_bound_regions ( ParamEnv :: reveal_all ( ) , & fn_ty. fn_sig ( fx. tcx ) ) ;
442
444
443
- // FIXME mark the current block as cold when calling a `#[cold]` function.
444
-
445
445
let destination = destination. map ( |( place, bb) | ( trans_place ( fx, place) , bb) ) ;
446
446
447
447
// Handle special calls like instrinsics and empty drop glue.
@@ -479,6 +479,15 @@ pub(crate) fn codegen_terminator_call<'tcx>(
479
479
None
480
480
} ;
481
481
482
+ let is_cold =
483
+ instance. map ( |inst|
484
+ fx. tcx . codegen_fn_attrs ( inst. def_id ( ) )
485
+ . flags . contains ( CodegenFnAttrFlags :: COLD ) )
486
+ . unwrap_or ( false ) ;
487
+ if is_cold {
488
+ fx. cold_blocks . insert ( current_block) ;
489
+ }
490
+
482
491
// Unpack arguments tuple for closures
483
492
let args = if fn_sig. abi == Abi :: RustCall {
484
493
assert_eq ! ( args. len( ) , 2 , "rust-call abi requires two arguments" ) ;
0 commit comments