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