Rollup merge of #69934 - andjo403:inlinecost, r=wesleywiser
Update the mir inline costs handle that when mir is lowered to llvm-ir more code is generated. Landingpads generates 10 llvm-ir instructions and resume 9 llvm-ir instructions. r? @wesleywiser
This commit is contained in:
commit
426a4cc930
@ -22,6 +22,8 @@ const HINT_THRESHOLD: usize = 100;
|
|||||||
|
|
||||||
const INSTR_COST: usize = 5;
|
const INSTR_COST: usize = 5;
|
||||||
const CALL_PENALTY: usize = 25;
|
const CALL_PENALTY: usize = 25;
|
||||||
|
const LANDINGPAD_PENALTY: usize = 50;
|
||||||
|
const RESUME_PENALTY: usize = 45;
|
||||||
|
|
||||||
const UNKNOWN_SIZE_COST: usize = 10;
|
const UNKNOWN_SIZE_COST: usize = 10;
|
||||||
|
|
||||||
@ -325,6 +327,7 @@ impl Inliner<'tcx> {
|
|||||||
if ty.needs_drop(tcx, param_env) {
|
if ty.needs_drop(tcx, param_env) {
|
||||||
cost += CALL_PENALTY;
|
cost += CALL_PENALTY;
|
||||||
if let Some(unwind) = unwind {
|
if let Some(unwind) = unwind {
|
||||||
|
cost += LANDINGPAD_PENALTY;
|
||||||
work_list.push(unwind);
|
work_list.push(unwind);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -340,7 +343,7 @@ impl Inliner<'tcx> {
|
|||||||
threshold = 0;
|
threshold = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminatorKind::Call { func: Operand::Constant(ref f), .. } => {
|
TerminatorKind::Call { func: Operand::Constant(ref f), cleanup, .. } => {
|
||||||
if let ty::FnDef(def_id, _) = f.literal.ty.kind {
|
if let ty::FnDef(def_id, _) = f.literal.ty.kind {
|
||||||
// Don't give intrinsics the extra penalty for calls
|
// Don't give intrinsics the extra penalty for calls
|
||||||
let f = tcx.fn_sig(def_id);
|
let f = tcx.fn_sig(def_id);
|
||||||
@ -349,9 +352,21 @@ impl Inliner<'tcx> {
|
|||||||
} else {
|
} else {
|
||||||
cost += CALL_PENALTY;
|
cost += CALL_PENALTY;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
cost += CALL_PENALTY;
|
||||||
|
}
|
||||||
|
if cleanup.is_some() {
|
||||||
|
cost += LANDINGPAD_PENALTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TerminatorKind::Assert { .. } => cost += CALL_PENALTY,
|
TerminatorKind::Assert { cleanup, .. } => {
|
||||||
|
cost += CALL_PENALTY;
|
||||||
|
|
||||||
|
if cleanup.is_some() {
|
||||||
|
cost += LANDINGPAD_PENALTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TerminatorKind::Resume => cost += RESUME_PENALTY,
|
||||||
_ => cost += INSTR_COST,
|
_ => cost += INSTR_COST,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user