rustc_mir: always run the deaggregator.

This commit is contained in:
Eduard-Mihai Burtescu 2018-02-07 17:28:32 +02:00
parent e598bdfaa0
commit 6e5dacbd5e
7 changed files with 15 additions and 16 deletions

View File

@ -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| { let can_deaggregate = |statement: &Statement| {
if let StatementKind::Assign(_, ref rhs) = statement.kind { if let StatementKind::Assign(_, ref rhs) = statement.kind {
if let Rvalue::Aggregate(..) = *rhs { if let Rvalue::Aggregate(..) = *rhs {

View File

@ -258,6 +258,11 @@ fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx
// Optimizations begin. // Optimizations begin.
inline::Inline, inline::Inline,
// Lowering generator control-flow and variables
// has to happen before we do anything else to them.
generator::StateTransform,
instcombine::InstCombine, instcombine::InstCombine,
deaggregator::Deaggregator, deaggregator::Deaggregator,
copy_prop::CopyPropagation, 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::SimplifyCfg::new("final"),
simplify::SimplifyLocals, simplify::SimplifyLocals,
generator::StateTransform,
add_call_guards::CriticalCallEdges, add_call_guards::CriticalCallEdges,
dump_mir::Marker("PreTrans"), dump_mir::Marker("PreTrans"),
]; ];

View File

@ -28,14 +28,14 @@ pub fn test() {
// CHECK: [[S_b:%[0-9]+]] = bitcast %"core::option::Option<i32>"** %b to i8* // CHECK: [[S_b:%[0-9]+]] = bitcast %"core::option::Option<i32>"** %b to i8*
// CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, i8* [[S_b]]) // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, i8* [[S_b]])
// CHECK: [[S__5:%[0-9]+]] = bitcast %"core::option::Option<i32>"* %_5 to i8* // CHECK: [[S__4:%[0-9]+]] = bitcast %"core::option::Option<i32>"* %_4 to i8*
// CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, i8* [[S__5]]) // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, i8* [[S__4]])
// CHECK: [[E_b:%[0-9]+]] = bitcast %"core::option::Option<i32>"** %b to i8* // CHECK: [[E_b:%[0-9]+]] = bitcast %"core::option::Option<i32>"** %b to i8*
// CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, i8* [[E_b]]) // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, i8* [[E_b]])
// CHECK: [[E__5:%[0-9]+]] = bitcast %"core::option::Option<i32>"* %_5 to i8* // CHECK: [[E__4:%[0-9]+]] = bitcast %"core::option::Option<i32>"* %_4 to i8*
// CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, i8* [[E__5]]) // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, i8* [[E__4]])
} }
let c = 1; let c = 1;

View File

@ -19,7 +19,7 @@ pub enum E {
// CHECK-LABEL: @exhaustive_match // CHECK-LABEL: @exhaustive_match
#[no_mangle] #[no_mangle]
pub fn exhaustive_match(e: E) { pub fn exhaustive_match(e: E, unit: ()) {
// CHECK: switch{{.*}}, label %[[OTHERWISE:[a-zA-Z0-9_]+]] [ // 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 %[[A:[a-zA-Z0-9_]+]]
// CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[B:[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: [[OTHERWISE]]:
// CHECK-NEXT: unreachable // CHECK-NEXT: unreachable
match e { match e {
E::A => (), E::A => unit,
E::B => (), E::B => unit,
} }
} }

View File

@ -64,7 +64,7 @@ pub fn change_parameter_pattern() {
} }
#[cfg(not(cfail1))] #[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized, TypeckTables")] #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, TypeckTables")]
#[rustc_clean(cfg="cfail3")] #[rustc_clean(cfg="cfail3")]
pub fn change_parameter_pattern() { pub fn change_parameter_pattern() {
let _ = |&x: &u32| x; let _ = |&x: &u32| x;

View File

@ -18,7 +18,7 @@
#![feature(rustc_attrs)] #![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 // 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. // be re-used, so checking that this module was re-used is sufficient.

View File

@ -72,7 +72,7 @@ pub fn f1<T:Copy>(x: T) {
fn start(_: isize, _: *const *const u8) -> isize { fn start(_: isize, _: *const *const u8) -> isize {
let _b: Pair<u8> = Pair::new(0, 0); let _b: Pair<u8> = Pair::new(0, 0);
let _s: Pair<SevenBytes> = Pair::new(SevenBytes::new(), SevenBytes::new()); let _s: Pair<SevenBytes> = Pair::new(SevenBytes::new(), SevenBytes::new());
let _z: ZeroSized = ZeroSized; let ref _z: ZeroSized = ZeroSized;
f1::<SevenBytes>(SevenBytes::new()); f1::<SevenBytes>(SevenBytes::new());
0 0
} }