Skip to content

Commit

Permalink
Auto merge of #98961 - zeevm:issue-98958-fix, r=oli-obk
Browse files Browse the repository at this point in the history
Only enable ConstProp on opt level >= 1

r? `@JakobDegen`
  • Loading branch information
bors committed Jul 9, 2022
2 parents 47575bb + 728fb05 commit db78ab7
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions compiler/rustc_mir_transform/src/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,8 @@ macro_rules! throw_machine_stop_str {
pub struct ConstProp;

impl<'tcx> MirPass<'tcx> for ConstProp {
fn is_enabled(&self, _sess: &rustc_session::Session) -> bool {
// FIXME(#70073): Unlike the other passes in "optimizations", this one emits errors, so it
// runs even when MIR optimizations are disabled. We should separate the lint out from the
// transform and move the lint as early in the pipeline as possible.
true
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
sess.mir_opt_level() >= 1
}

#[instrument(skip(self, tcx), level = "debug")]
Expand Down Expand Up @@ -794,12 +791,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {

/// Returns `true` if and only if this `op` should be const-propagated into.
fn should_const_prop(&mut self, op: &OpTy<'tcx>) -> bool {
let mir_opt_level = self.tcx.sess.mir_opt_level();

if mir_opt_level == 0 {
return false;
}

if !self.tcx.consider_optimizing(|| format!("ConstantPropagation - OpTy: {:?}", op)) {
return false;
}
Expand Down

0 comments on commit db78ab7

Please sign in to comment.