Skip to content

Commit 6f6737a

Browse files
committed
Try to improve compile times
1 parent a211812 commit 6f6737a

File tree

13 files changed

+24
-46
lines changed

13 files changed

+24
-46
lines changed

compiler/rustc_middle/src/query/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,8 @@ rustc_queries! {
566566
/// and with extra transforms applied.
567567
query build_codegen_mir(key: ty::Instance<'tcx>) -> &'tcx mir::Body<'tcx> {
568568
desc { |tcx| "finalizing codegen MIR for `{}`", tcx.def_path_str_with_args(key.def_id(), key.args) }
569+
cache_on_disk_if { true }
570+
arena_cache
569571
}
570572

571573
/// Checks for the nearest `#[coverage(off)]` or `#[coverage(on)]` on

compiler/rustc_mir_transform/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> {
688688
body
689689
}
690690

691-
pub fn build_codegen_mir<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> &'tcx Body<'tcx> {
691+
pub fn build_codegen_mir<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Body<'tcx> {
692692
let body = tcx.instance_mir(instance.def);
693693
let mut body = instance.instantiate_mir_and_normalize_erasing_regions(
694694
tcx,
@@ -705,19 +705,19 @@ pub fn build_codegen_mir<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> &
705705
// failures. So we rely on the fact that validation only runs after passes? It's
706706
// probably better to just delete that validation check.
707707
&abort_unwinding_calls::AbortUnwindingCalls,
708-
&o1(gvn::GVN::PostMono),
708+
&gvn::GVN::PostMono,
709709
// FIXME: Enabling this InstSimplify is required to fix the MIR from the
710710
// unreachable_unchecked precondition check that UnreachablePropagation creates, but
711711
// also enabling it breaks tests/codegen/issues/issue-122600-ptr-discriminant-update.rs
712712
// LLVM appears to handle switches on i64 better than it handles icmp eq + br.
713-
&o1(instsimplify::InstSimplify::PostMono),
713+
&instsimplify::InstSimplify::PostMono,
714714
&o1(simplify_branches::SimplifyConstCondition::PostMono),
715715
&o1(simplify::SimplifyCfg::PostMono),
716716
&add_call_guards::CriticalCallEdges,
717717
],
718718
Some(MirPhase::Runtime(RuntimePhase::Codegen)),
719719
);
720-
tcx.arena.alloc(body)
720+
body
721721
}
722722

723723
/// Fetch all the promoteds of an item and prepare their MIR bodies to be ready for

tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub fn foo5(a: &dyn Trait5<Type5, 32>) {
156156
let b = &[Type5; 32];
157157
a.quux(&b);
158158
// CHECK-LABEL: define{{.*}}4foo5{{.*}}!{{<unknown kind #36>|kcfi_type}} !{{[0-9]+}}
159-
// CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ]
159+
// CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%_[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ]
160160
}
161161

162162
pub fn bar5() {
@@ -165,7 +165,7 @@ pub fn bar5() {
165165
let b = &a as &dyn Trait5<Type5, 32>;
166166
b.quux(&a);
167167
// CHECK-LABEL: define{{.*}}4bar5{{.*}}!{{<unknown kind #36>|kcfi_type}} !{{[0-9]+}}
168-
// CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ]
168+
// CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%_[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ]
169169
}
170170

171171
// CHECK: !{{[0-9]+}} = !{i32 [[TYPE1]]}

tests/ui/consts/const-eval/issue-50814.stderr

-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@ note: erroneous constant encountered
1010
LL | &Sum::<U8, U8>::MAX
1111
| ^^^^^^^^^^^^^^^^^^
1212

13-
note: erroneous constant encountered
14-
--> $DIR/issue-50814.rs:21:6
15-
|
16-
LL | &Sum::<U8, U8>::MAX
17-
| ^^^^^^^^^^^^^^^^^^
18-
|
19-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
20-
2113
error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
2214
--> $DIR/issue-50814.rs:15:21
2315
|

tests/ui/consts/mono-reachable-invalid-const.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ error[E0080]: evaluation of `Bar::<0>::ASSERT` failed
44
LL | ["oops"][b];
55
| ^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1
66

7-
note: erroneous constant encountered
8-
--> $DIR/mono-reachable-invalid-const.rs:9:9
9-
|
10-
LL | ["oops"][b];
11-
| ^^^^^^^^^^^
12-
137
note: erroneous constant encountered
148
--> $DIR/mono-reachable-invalid-const.rs:14:19
159
|

tests/ui/inline-const/const-expr-generic-err.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ error[E0080]: evaluation of `bar::<0>::{constant#0}` failed
2424
LL | const { N - 1 }
2525
| ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
2626

27-
note: erroneous constant encountered
28-
--> $DIR/const-expr-generic-err.rs:9:13
29-
|
30-
LL | const { N - 1 }
31-
| ^^^^^
32-
3327
note: erroneous constant encountered
3428
--> $DIR/const-expr-generic-err.rs:9:5
3529
|

tests/ui/layout/layout-cycle.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@ build-fail
2-
//~^ ERROR: cycle detected when computing layout of
2+
//~^ ERROR: a cycle occurred during layout computation
3+
//~| ERROR: cycle detected when computing layout of
34

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

tests/ui/layout/layout-cycle.stderr

+2-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@ error[E0391]: cycle detected when computing layout of `S<S<()>>`
22
|
33
= note: ...which requires computing layout of `<S<()> as Tr>::I`...
44
= note: ...which again requires computing layout of `S<S<()>>`, completing the cycle
5-
note: cycle used when finalizing codegen MIR for `core::mem::size_of::<S<S<()>>>`
6-
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
75
= 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
86

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

15-
error: aborting due to 1 previous error
9+
error: aborting due to 2 previous errors
1610

1711
For more information about this error, try `rustc --explain E0391`.

tests/ui/layout/post-mono-layout-cycle.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ struct Wrapper<T: Trait> {
1414
}
1515

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

1819
fn indirect<T: Trait>() {
1920
abi::<T>(None);

tests/ui/layout/post-mono-layout-cycle.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ error[E0391]: cycle detected when computing layout of `Wrapper<()>`
55
= note: cycle used when computing layout of `core::option::Option<Wrapper<()>>`
66
= 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
77

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

14-
error: aborting due to 1 previous error
14+
error: aborting due to 2 previous errors
1515

1616
For more information about this error, try `rustc --explain E0391`.

tests/ui/lint/large_assignments/copy_into_fn.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ LL | #![deny(large_assignments)]
1212
| ^^^^^^^^^^^^^^^^^
1313

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

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

tests/ui/recursion_limit/zero-overflow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//~ ERROR overflow evaluating the requirement `{closure@rt::lang_start<()>::{closure#0}}: Freeze`
1+
//~ ERROR overflow evaluating the requirement `{closure@rt::lang_start<()>::{closure#0}}: Unsize<dyn Fn() -> i32 + Sync + RefUnwindSafe>`
22
//~| HELP consider increasing the recursion limit
33
//@ build-fail
44

tests/ui/recursion_limit/zero-overflow.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0275]: overflow evaluating the requirement `{closure@rt::lang_start<()>::{closure#0}}: Freeze`
1+
error[E0275]: overflow evaluating the requirement `{closure@rt::lang_start<()>::{closure#0}}: Unsize<dyn Fn() -> i32 + Sync + RefUnwindSafe>`
22
|
33
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`zero_overflow`)
44

0 commit comments

Comments
 (0)