Skip to content

Commit

Permalink
Remove the new MIR phase, because codegen_mir may return normal insta…
Browse files Browse the repository at this point in the history
…nce_mir
  • Loading branch information
saethlin committed Oct 25, 2024
1 parent 6106bd5 commit 4d85f3e
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 19 deletions.
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ impl RuntimePhase {
"initial" => Self::Initial,
"post_cleanup" | "post-cleanup" | "postcleanup" => Self::PostCleanup,
"optimized" => Self::Optimized,
"codegen" => Self::Codegen,
_ => bug!("Unknown runtime phase: '{}'", phase),
}
}
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_middle/src/mir/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ impl MirPhase {
MirPhase::Runtime(RuntimePhase::Initial) => "runtime",
MirPhase::Runtime(RuntimePhase::PostCleanup) => "runtime-post-cleanup",
MirPhase::Runtime(RuntimePhase::Optimized) => "runtime-optimized",
MirPhase::Runtime(RuntimePhase::Codegen) => "codegen",
}
}

Expand Down Expand Up @@ -154,7 +153,6 @@ pub enum RuntimePhase {
/// * [`ProjectionElem::Deref`] of `Box`
PostCleanup = 1,
Optimized = 2,
Codegen = 3,
}

///////////////////////////////////////////////////////////////////////////
Expand Down
10 changes: 2 additions & 8 deletions compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,17 +743,11 @@ pub fn build_codegen_mir<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> B
let body = clone_mir(body);
let mut body = monomorphize_mir(tcx, instance, body);

pm::run_passes(
pm::run_passes_no_validate(
tcx,
ty::ParamEnv::reveal_all(),
&mut body,
&[
// Validation calls layout::fn_can_unwind to figure out if a function can unwind, which
// always returns false if the current crate is compiled with -Cpanic=abort. So when
// a crate with panic=abort compiles MIR from a panic=unwind crate, we get validation
// failures. So we rely on the fact that validation only runs after passes? It's
// probably better to just delete that validation check.
&abort_unwinding_calls::AbortUnwindingCalls,
&gvn::GVN::PostMono,
// FIXME: Enabling this InstSimplify is required to fix the MIR from the
// unreachable_unchecked precondition check that UnreachablePropagation creates, but
Expand All @@ -764,7 +758,7 @@ pub fn build_codegen_mir<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> B
&o1(simplify::SimplifyCfg::PostMono),
&add_call_guards::CriticalCallEdges,
],
Some(MirPhase::Runtime(RuntimePhase::Codegen)),
None,
);
body
}
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_mir_transform/src/pass_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,7 @@ fn run_passes_inner<'tcx>(

let validate =
(validate_each & tcx.sess.opts.unstable_opts.validate_mir & !body.should_skip())
|| matches!(
new_phase,
MirPhase::Runtime(RuntimePhase::Optimized | RuntimePhase::Codegen)
);
|| matches!(new_phase, MirPhase::Runtime(RuntimePhase::Optimized));
let lint = tcx.sess.opts.unstable_opts.lint_mir & !body.should_skip();
if validate {
validate_body(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
// the return edge from the call. FIXME(tmiasko): Since this is a strictly code
// generation concern, the code generation should be responsible for handling
// it.
if self.mir_phase >= MirPhase::Runtime(RuntimePhase::Codegen)
if self.mir_phase >= MirPhase::Runtime(RuntimePhase::Optimized)
&& self.is_critical_call_edge(target, unwind)
{
self.fail(
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/mir/validate/critical-edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#![feature(custom_mir, core_intrinsics)]
use std::intrinsics::mir::*;

#[custom_mir(dialect = "runtime", phase = "codegen")]
#[custom_mir(dialect = "runtime", phase = "optimized")]
#[inline(never)] // Force codegen so we go through codegen MIR validation
pub fn f(a: u32) -> u32 {
mir! {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/recursion_limit/zero-overflow.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//~ ERROR overflow evaluating the requirement `{closure@rt::lang_start<()>::{closure#0}}: Unsize<dyn Fn() -> i32 + Sync + RefUnwindSafe>`
//~ ERROR overflow evaluating the requirement `&mut Self: DispatchFromDyn<&mut RustaceansAreAwesome>
//~| HELP consider increasing the recursion limit
//@ build-fail

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/recursion_limit/zero-overflow.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0275]: overflow evaluating the requirement `{closure@rt::lang_start<()>::{closure#0}}: Unsize<dyn Fn() -> i32 + Sync + RefUnwindSafe>`
error[E0275]: overflow evaluating the requirement `&mut Self: DispatchFromDyn<&mut RustaceansAreAwesome>`
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`zero_overflow`)

Expand Down

0 comments on commit 4d85f3e

Please sign in to comment.