inliner: Remove redundant loop
No functional changes intended.
This commit is contained in:
parent
234099d1d1
commit
c0cbf6368d
1 changed files with 60 additions and 77 deletions
|
@ -93,20 +93,13 @@ impl Inliner<'tcx> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut local_change;
|
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
|
|
||||||
loop {
|
|
||||||
local_change = false;
|
|
||||||
while let Some(callsite) = callsites.pop_front() {
|
while let Some(callsite) = callsites.pop_front() {
|
||||||
debug!("checking whether to inline callsite {:?}", callsite);
|
debug!("checking whether to inline callsite {:?}", callsite);
|
||||||
|
|
||||||
if let InstanceDef::Item(_) = callsite.callee.def {
|
if let InstanceDef::Item(_) = callsite.callee.def {
|
||||||
if !self.tcx.is_mir_available(callsite.callee.def_id()) {
|
if !self.tcx.is_mir_available(callsite.callee.def_id()) {
|
||||||
debug!(
|
debug!("checking whether to inline callsite {:?} - MIR unavailable", callsite,);
|
||||||
"checking whether to inline callsite {:?} - MIR unavailable",
|
|
||||||
callsite,
|
|
||||||
);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,11 +143,9 @@ impl Inliner<'tcx> {
|
||||||
// Although we are only pushing `ConstKind::Unevaluated` consts to
|
// Although we are only pushing `ConstKind::Unevaluated` consts to
|
||||||
// `required_consts`, here we may not only have `ConstKind::Unevaluated`
|
// `required_consts`, here we may not only have `ConstKind::Unevaluated`
|
||||||
// because we are calling `subst_and_normalize_erasing_regions`.
|
// because we are calling `subst_and_normalize_erasing_regions`.
|
||||||
caller_body.required_consts.extend(
|
caller_body.required_consts.extend(callee_body.required_consts.iter().copied().filter(
|
||||||
callee_body.required_consts.iter().copied().filter(|&constant| {
|
|&constant| matches!(constant.literal.val, ConstKind::Unevaluated(_, _, _)),
|
||||||
matches!(constant.literal.val, ConstKind::Unevaluated(_, _, _))
|
));
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
let start = caller_body.basic_blocks().len();
|
let start = caller_body.basic_blocks().len();
|
||||||
debug!("attempting to inline callsite {:?} - body={:?}", callsite, callee_body);
|
debug!("attempting to inline callsite {:?} - body={:?}", callsite, callee_body);
|
||||||
|
@ -166,9 +157,7 @@ impl Inliner<'tcx> {
|
||||||
|
|
||||||
// Add callsites from inlined function
|
// Add callsites from inlined function
|
||||||
for (bb, bb_data) in caller_body.basic_blocks().iter_enumerated().skip(start) {
|
for (bb, bb_data) in caller_body.basic_blocks().iter_enumerated().skip(start) {
|
||||||
if let Some(new_callsite) =
|
if let Some(new_callsite) = self.get_valid_function_call(bb, bb_data, caller_body) {
|
||||||
self.get_valid_function_call(bb, bb_data, caller_body)
|
|
||||||
{
|
|
||||||
// Don't inline the same function multiple times.
|
// Don't inline the same function multiple times.
|
||||||
if callsite.callee != new_callsite.callee {
|
if callsite.callee != new_callsite.callee {
|
||||||
callsites.push_back(new_callsite);
|
callsites.push_back(new_callsite);
|
||||||
|
@ -176,15 +165,9 @@ impl Inliner<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local_change = true;
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !local_change {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simplify if we inlined anything.
|
// Simplify if we inlined anything.
|
||||||
if changed {
|
if changed {
|
||||||
debug!("running simplify cfg on {:?}", caller_body.source);
|
debug!("running simplify cfg on {:?}", caller_body.source);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue