From 6e5dacbd5e8aab43cdc4c2f1d4ec66fe0b8d4bed Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Wed, 7 Feb 2018 17:28:32 +0200 Subject: [PATCH] rustc_mir: always run the deaggregator. --- src/librustc_mir/transform/deaggregator.rs | 5 ----- src/librustc_mir/transform/mod.rs | 6 +++++- src/test/codegen/lifetime_start_end.rs | 8 ++++---- src/test/codegen/match.rs | 6 +++--- src/test/incremental/hashes/closure_expressions.rs | 2 +- src/test/incremental/issue-38222.rs | 2 +- src/test/ui/print_type_sizes/generics.rs | 2 +- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/librustc_mir/transform/deaggregator.rs b/src/librustc_mir/transform/deaggregator.rs index 179c196f26f..44c35960aba 100644 --- a/src/librustc_mir/transform/deaggregator.rs +++ b/src/librustc_mir/transform/deaggregator.rs @@ -39,11 +39,6 @@ impl MirPass for Deaggregator { } } - // We only run when the MIR optimization level is > 2. - if tcx.sess.opts.debugging_opts.mir_opt_level <= 2 { - return; - } - let can_deaggregate = |statement: &Statement| { if let StatementKind::Assign(_, ref rhs) = statement.kind { if let Rvalue::Aggregate(..) = *rhs { diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index 7ed250e94c5..b16c1436a1c 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -258,6 +258,11 @@ fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx // Optimizations begin. inline::Inline, + + // Lowering generator control-flow and variables + // has to happen before we do anything else to them. + generator::StateTransform, + instcombine::InstCombine, deaggregator::Deaggregator, copy_prop::CopyPropagation, @@ -265,7 +270,6 @@ fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx simplify::SimplifyCfg::new("final"), simplify::SimplifyLocals, - generator::StateTransform, add_call_guards::CriticalCallEdges, dump_mir::Marker("PreTrans"), ]; diff --git a/src/test/codegen/lifetime_start_end.rs b/src/test/codegen/lifetime_start_end.rs index 1f900a3770e..62aa93398ac 100644 --- a/src/test/codegen/lifetime_start_end.rs +++ b/src/test/codegen/lifetime_start_end.rs @@ -28,14 +28,14 @@ pub fn test() { // CHECK: [[S_b:%[0-9]+]] = bitcast %"core::option::Option"** %b to i8* // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, i8* [[S_b]]) -// CHECK: [[S__5:%[0-9]+]] = bitcast %"core::option::Option"* %_5 to i8* -// CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, i8* [[S__5]]) +// CHECK: [[S__4:%[0-9]+]] = bitcast %"core::option::Option"* %_4 to i8* +// CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, i8* [[S__4]]) // CHECK: [[E_b:%[0-9]+]] = bitcast %"core::option::Option"** %b to i8* // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, i8* [[E_b]]) -// CHECK: [[E__5:%[0-9]+]] = bitcast %"core::option::Option"* %_5 to i8* -// CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, i8* [[E__5]]) +// CHECK: [[E__4:%[0-9]+]] = bitcast %"core::option::Option"* %_4 to i8* +// CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, i8* [[E__4]]) } let c = 1; diff --git a/src/test/codegen/match.rs b/src/test/codegen/match.rs index 660b6346c57..c9d0427dd0a 100644 --- a/src/test/codegen/match.rs +++ b/src/test/codegen/match.rs @@ -19,7 +19,7 @@ pub enum E { // CHECK-LABEL: @exhaustive_match #[no_mangle] -pub fn exhaustive_match(e: E) { +pub fn exhaustive_match(e: E, unit: ()) { // CHECK: switch{{.*}}, label %[[OTHERWISE:[a-zA-Z0-9_]+]] [ // CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[A:[a-zA-Z0-9_]+]] // CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[B:[a-zA-Z0-9_]+]] @@ -31,7 +31,7 @@ pub fn exhaustive_match(e: E) { // CHECK: [[OTHERWISE]]: // CHECK-NEXT: unreachable match e { - E::A => (), - E::B => (), + E::A => unit, + E::B => unit, } } diff --git a/src/test/incremental/hashes/closure_expressions.rs b/src/test/incremental/hashes/closure_expressions.rs index d8a87da5918..73418f48860 100644 --- a/src/test/incremental/hashes/closure_expressions.rs +++ b/src/test/incremental/hashes/closure_expressions.rs @@ -64,7 +64,7 @@ pub fn change_parameter_pattern() { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized, TypeckTables")] +#[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, TypeckTables")] #[rustc_clean(cfg="cfail3")] pub fn change_parameter_pattern() { let _ = |&x: &u32| x; diff --git a/src/test/incremental/issue-38222.rs b/src/test/incremental/issue-38222.rs index 7bb8af74eeb..f890672aa8f 100644 --- a/src/test/incremental/issue-38222.rs +++ b/src/test/incremental/issue-38222.rs @@ -18,7 +18,7 @@ #![feature(rustc_attrs)] -#![rustc_partition_translated(module="issue_38222-mod1", cfg="rpass2")] +#![rustc_partition_reused(module="issue_38222-mod1", cfg="rpass2")] // If trans had added a dependency edge to the Krate dep-node, nothing would // be re-used, so checking that this module was re-used is sufficient. diff --git a/src/test/ui/print_type_sizes/generics.rs b/src/test/ui/print_type_sizes/generics.rs index d0e5bd1d92a..21fdbb3f5a1 100644 --- a/src/test/ui/print_type_sizes/generics.rs +++ b/src/test/ui/print_type_sizes/generics.rs @@ -72,7 +72,7 @@ pub fn f1(x: T) { fn start(_: isize, _: *const *const u8) -> isize { let _b: Pair = Pair::new(0, 0); let _s: Pair = Pair::new(SevenBytes::new(), SevenBytes::new()); - let _z: ZeroSized = ZeroSized; + let ref _z: ZeroSized = ZeroSized; f1::(SevenBytes::new()); 0 }