@@ -25,6 +25,8 @@ const HINT_THRESHOLD: usize = 100;
2525
2626const INSTR_COST : usize = 5 ;
2727const CALL_PENALTY : usize = 25 ;
28+ const LANDINGPAD_PENALTY : usize = 50 ;
29+ const RESUME_PENALTY : usize = 45 ;
2830
2931const UNKNOWN_SIZE_COST : usize = 10 ;
3032
@@ -328,6 +330,7 @@ impl Inliner<'tcx> {
328330 if ty. needs_drop ( tcx, param_env) {
329331 cost += CALL_PENALTY ;
330332 if let Some ( unwind) = unwind {
333+ cost += LANDINGPAD_PENALTY ;
331334 work_list. push ( unwind) ;
332335 }
333336 } else {
@@ -343,7 +346,7 @@ impl Inliner<'tcx> {
343346 threshold = 0 ;
344347 }
345348
346- TerminatorKind :: Call { func : Operand :: Constant ( ref f) , .. } => {
349+ TerminatorKind :: Call { func : Operand :: Constant ( ref f) , cleanup , .. } => {
347350 if let ty:: FnDef ( def_id, _) = f. literal . ty . kind {
348351 // Don't give intrinsics the extra penalty for calls
349352 let f = tcx. fn_sig ( def_id) ;
@@ -352,9 +355,21 @@ impl Inliner<'tcx> {
352355 } else {
353356 cost += CALL_PENALTY ;
354357 }
358+ } else {
359+ cost += CALL_PENALTY ;
360+ }
361+ if cleanup. is_some ( ) {
362+ cost += LANDINGPAD_PENALTY ;
363+ }
364+ }
365+ TerminatorKind :: Assert { cleanup, .. } => {
366+ cost += CALL_PENALTY ;
367+
368+ if cleanup. is_some ( ) {
369+ cost += LANDINGPAD_PENALTY ;
355370 }
356371 }
357- TerminatorKind :: Assert { .. } => cost += CALL_PENALTY ,
372+ TerminatorKind :: Resume => cost += RESUME_PENALTY ,
358373 _ => cost += INSTR_COST ,
359374 }
360375
0 commit comments