Skip to content

Commit 7a5ff95

Browse files
committed
validator: move force inline check
1 parent c9f3793 commit 7a5ff95

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

compiler/rustc_mir_transform/src/validate.rs

+10-23
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'tcx> crate::MirPass<'tcx> for Validator {
8080
cfg_checker.fail(location, msg);
8181
}
8282

83-
if let MirPhase::Runtime(phase) = body.phase {
83+
if let MirPhase::Runtime(_) = body.phase {
8484
if let ty::InstanceKind::Item(_) = body.source.instance {
8585
if body.has_free_regions() {
8686
cfg_checker.fail(
@@ -89,27 +89,6 @@ impl<'tcx> crate::MirPass<'tcx> for Validator {
8989
);
9090
}
9191
}
92-
93-
if phase >= RuntimePhase::Optimized
94-
&& body
95-
.basic_blocks
96-
.iter()
97-
.filter_map(|bb| match &bb.terminator().kind {
98-
TerminatorKind::Call { func, .. }
99-
| TerminatorKind::TailCall { func, .. } => Some(func),
100-
_ => None,
101-
})
102-
.filter_map(|func| match func.ty(&body.local_decls, tcx).kind() {
103-
ty::FnDef(did, ..) => Some(did),
104-
_ => None,
105-
})
106-
.any(|did| matches!(tcx.codegen_fn_attrs(did).inline, InlineAttr::Force { .. }))
107-
{
108-
cfg_checker.fail(
109-
Location::START,
110-
"`#[rustc_force_inline]`-annotated function not inlined",
111-
);
112-
}
11392
}
11493
}
11594
}
@@ -388,7 +367,8 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
388367
self.check_edge(location, *target, EdgeKind::Normal);
389368
self.check_unwind_edge(location, *unwind);
390369
}
391-
TerminatorKind::Call { args, .. } | TerminatorKind::TailCall { args, .. } => {
370+
TerminatorKind::Call { func, args, .. }
371+
| TerminatorKind::TailCall { func, args, .. } => {
392372
// FIXME(explicit_tail_calls): refactor this & add tail-call specific checks
393373
if let TerminatorKind::Call { target, unwind, destination, .. } = terminator.kind {
394374
if let Some(target) = target {
@@ -441,6 +421,13 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
441421
}
442422
}
443423
}
424+
425+
if let ty::FnDef(did, ..) = func.ty(&self.body.local_decls, self.tcx).kind()
426+
&& self.body.phase >= MirPhase::Runtime(RuntimePhase::Optimized)
427+
&& matches!(self.tcx.codegen_fn_attrs(did).inline, InlineAttr::Force { .. })
428+
{
429+
self.fail(location, "`#[rustc_force_inline]`-annotated function not inlined");
430+
}
444431
}
445432
TerminatorKind::Assert { target, unwind, .. } => {
446433
self.check_edge(location, *target, EdgeKind::Normal);

0 commit comments

Comments
 (0)