use crate::prelude::*;

mod code_layout;
mod stack2reg;

pub(crate) fn optimize_function<'tcx>(
    tcx: TyCtxt<'tcx>,
    #[cfg_attr(not(debug_assertions), allow(unused_variables))] instance: Instance<'tcx>,
    ctx: &mut Context,
    cold_blocks: &EntitySet<Block>,
    clif_comments: &mut crate::pretty_clif::CommentWriter,
) {
    // The code_layout optimization is very cheap.
    self::code_layout::optimize_function(ctx, cold_blocks);

    if tcx.sess.opts.optimize == rustc_session::config::OptLevel::No {
        return; // FIXME classify optimizations over opt levels
    }
    self::stack2reg::optimize_function(ctx, clif_comments);
    crate::pretty_clif::write_clif_file(tcx, "stack2reg", None, instance, &ctx, &*clif_comments);
    crate::base::verify_func(tcx, &*clif_comments, &ctx.func);
}

use crate::prelude::*;

mod code_layout;
mod stack2reg;

pub(crate) fn optimize_function<'tcx>(
    tcx: TyCtxt<'tcx>,
    instance: Instance<'tcx>,
    ctx: &mut Context,
    cold_blocks: &EntitySet<Block>,
    clif_comments: &mut crate::pretty_clif::CommentWriter,
) {
    // The code_layout optimization is very cheap.
    self::code_layout::optimize_function(ctx, cold_blocks);

    if tcx.sess.opts.optimize == rustc_session::config::OptLevel::No {
        return; // FIXME classify optimizations over opt levels
    }
    self::stack2reg::optimize_function(ctx, clif_comments);
    crate::pretty_clif::write_clif_file(tcx, "stack2reg", None, instance, &ctx, &*clif_comments);
    crate::base::verify_func(tcx, &*clif_comments, &ctx.func);
}

Remove conditional compilation on instance
optimize: Remove conditional compilation on instance

Co-authored-by: bjorn3 <de4e812b534fa9cc35c77a0c909d6ebb8ac118a3@users.noreply.github.com>