Skip to content

Commit

Permalink
Enable post-mono GVN in debug builds
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Nov 2, 2024
1 parent 47e357b commit 2035d35
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ pub fn build_codegen_mir<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> B
ty::ParamEnv::reveal_all(),
&mut body,
&[
&gvn::GVN::PostMono,
&o1(gvn::GVN::PostMono),
// FIXME: Enabling this InstSimplify is required to fix the MIR from the
// unreachable_unchecked precondition check that UnreachablePropagation creates, but
// also enabling it breaks tests/codegen/issues/issue-122600-ptr-discriminant-update.rs
Expand Down
2 changes: 1 addition & 1 deletion tests/crashes/131342-2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ known-bug: #131342
//@ compile-flags: -Copt-level=0
//@ compile-flags: -Copt-level=0 -Zmir-opt-level=0
// see also: 131342.rs

fn main() {
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/consts/mono-reachable-invalid-const.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ error[E0080]: evaluation of `Bar::<0>::ASSERT` failed
LL | ["oops"][b];
| ^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1

note: erroneous constant encountered
--> $DIR/mono-reachable-invalid-const.rs:9:9
|
LL | ["oops"][b];
| ^^^^^^^^^^^

note: erroneous constant encountered
--> $DIR/mono-reachable-invalid-const.rs:14:19
|
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/inline-const/const-expr-generic-err.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ error[E0080]: evaluation of `bar::<0>::{constant#0}` failed
LL | const { N - 1 }
| ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow

note: erroneous constant encountered
--> $DIR/const-expr-generic-err.rs:9:13
|
LL | const { N - 1 }
| ^^^^^

note: erroneous constant encountered
--> $DIR/const-expr-generic-err.rs:9:5
|
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/layout/layout-cycle.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ build-fail
//~^ ERROR: a cycle occurred during layout computation
//~| ERROR: cycle detected when computing layout of
//~^ ERROR: cycle detected when computing layout of

// Issue #111176 -- ensure that we do not emit ICE on layout cycles

Expand Down
10 changes: 8 additions & 2 deletions tests/ui/layout/layout-cycle.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ error[E0391]: cycle detected when computing layout of `S<S<()>>`
|
= note: ...which requires computing layout of `<S<()> as Tr>::I`...
= note: ...which again requires computing layout of `S<S<()>>`, completing the cycle
note: cycle used when finalizing codegen MIR for `core::mem::size_of::<S<S<()>>>`
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: failed to get layout for S<S<()>>: a cycle occurred during layout computation
note: the above error was encountered while instantiating `fn std::mem::size_of::<S<S<()>>>`
--> $DIR/layout-cycle.rs:25:5
|
LL | mem::size_of::<S<T>>()
| ^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0391`.
1 change: 0 additions & 1 deletion tests/ui/layout/post-mono-layout-cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ struct Wrapper<T: Trait> {
}

fn abi<T: Trait>(_: Option<Wrapper<T>>) {}
//~^ ERROR a cycle occurred during layout computation

fn indirect<T: Trait>() {
abi::<T>(None);
Expand Down
10 changes: 5 additions & 5 deletions tests/ui/layout/post-mono-layout-cycle.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ error[E0391]: cycle detected when computing layout of `Wrapper<()>`
= note: cycle used when computing layout of `core::option::Option<Wrapper<()>>`
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: a cycle occurred during layout computation
--> $DIR/post-mono-layout-cycle.rs:16:1
note: the above error was encountered while instantiating `fn indirect::<()>`
--> $DIR/post-mono-layout-cycle.rs:23:5
|
LL | fn abi<T: Trait>(_: Option<Wrapper<T>>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | indirect::<()>();
| ^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0391`.
8 changes: 4 additions & 4 deletions tests/ui/lint/large_assignments/copy_into_fn.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ LL | #![deny(large_assignments)]
| ^^^^^^^^^^^^^^^^^

error: moving 9999 bytes
--> $DIR/copy_into_fn.rs:17:15
--> $DIR/copy_into_fn.rs:17:20
|
LL | many_args(Data([0; 9999]), true, Data([0; 9999]));
| ^^^^^^^^^^^^^^^ value moved from here
| ^^^^^^^^^ value moved from here
|
= note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`

error: moving 9999 bytes
--> $DIR/copy_into_fn.rs:17:38
--> $DIR/copy_into_fn.rs:17:43
|
LL | many_args(Data([0; 9999]), true, Data([0; 9999]));
| ^^^^^^^^^^^^^^^ value moved from here
| ^^^^^^^^^ value moved from here
|
= note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`

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 `&mut Self: DispatchFromDyn<&mut RustaceansAreAwesome>
//~ ERROR overflow evaluating the requirement
//~| 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 `&mut Self: DispatchFromDyn<&mut RustaceansAreAwesome>`
error[E0275]: overflow evaluating the requirement `{closure@rt::lang_start<()>::{closure#0}}: Freeze`
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`zero_overflow`)

Expand Down

0 comments on commit 2035d35

Please sign in to comment.