@@ -25,6 +25,8 @@ const HINT_THRESHOLD: usize = 100;
25
25
26
26
const INSTR_COST : usize = 5 ;
27
27
const CALL_PENALTY : usize = 25 ;
28
+ const LANDINGPAD_PENALTY : usize = 50 ;
29
+ const RESUME_PENALTY : usize = 45 ;
28
30
29
31
const UNKNOWN_SIZE_COST : usize = 10 ;
30
32
@@ -328,6 +330,7 @@ impl Inliner<'tcx> {
328
330
if ty. needs_drop ( tcx, param_env) {
329
331
cost += CALL_PENALTY ;
330
332
if let Some ( unwind) = unwind {
333
+ cost += LANDINGPAD_PENALTY ;
331
334
work_list. push ( unwind) ;
332
335
}
333
336
} else {
@@ -343,7 +346,7 @@ impl Inliner<'tcx> {
343
346
threshold = 0 ;
344
347
}
345
348
346
- TerminatorKind :: Call { func : Operand :: Constant ( ref f) , .. } => {
349
+ TerminatorKind :: Call { func : Operand :: Constant ( ref f) , cleanup , .. } => {
347
350
if let ty:: FnDef ( def_id, _) = f. literal . ty . kind {
348
351
// Don't give intrinsics the extra penalty for calls
349
352
let f = tcx. fn_sig ( def_id) ;
@@ -352,9 +355,21 @@ impl Inliner<'tcx> {
352
355
} else {
353
356
cost += CALL_PENALTY ;
354
357
}
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 ;
355
370
}
356
371
}
357
- TerminatorKind :: Assert { .. } => cost += CALL_PENALTY ,
372
+ TerminatorKind :: Resume => cost += RESUME_PENALTY ,
358
373
_ => cost += INSTR_COST ,
359
374
}
360
375
0 commit comments