Skip to content

Commit

Permalink
Try to read #[inline(always)] MIR bodies but don't actually inline
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad20012 committed Apr 19, 2023
1 parent df0d9b4 commit 796cafe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler/rustc_mir_transform/src/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ impl<'tcx> MirPass<'tcx> for Inline {
}

match sess.mir_opt_level() {
0 | 1 => false,
0 => false,
1 => true,
2 => {
(sess.opts.optimize == OptLevel::Default
|| sess.opts.optimize == OptLevel::Aggressive)
Expand Down Expand Up @@ -173,6 +174,10 @@ impl<'tcx> Inliner<'tcx> {
let callee_body = self.tcx.instance_mir(callsite.callee.def);
self.check_mir_body(callsite, callee_body, callee_attrs)?;

if self.tcx.sess.mir_opt_level() == 1 {
return Err("mir_opt_level == 1");
}

if !self.tcx.consider_optimizing(|| {
format!("Inline {:?} into {:?}", callsite.callee, caller_body.source)
}) {
Expand Down

0 comments on commit 796cafe

Please sign in to comment.