Auto merge of #36752 - jonas-schievink:vartmparg, r=eddyb
Move MIR towards a single kind of local This PR modifies MIR to handle function arguments (`Arg`), user-defined variable bindings (`Var`), compiler-generated temporaries (`Tmp`), as well as the return value pointer equally. All of them are replaced with a single `Local` type, a few functions for iterating over different kinds of locals, and a way to get the kind of local we're dealing with (mainly used in the constant qualification/propagation passes). ~~I haven't managed to fix one remaining issue: A `StorageDead` not getting emitted for a variable (see the `TODO` in the test). If that's fixed, this is basically good to go.~~ Found the issue (an off-by-one error), fix incoming. r? @eddyb for changes to constant qualification and propagation I'm not quite sure about
This commit is contained in:
commit
ff67da63ea
35 changed files with 648 additions and 684 deletions
|
|
@ -30,11 +30,11 @@ pub fn test() {
|
|||
// CHECK: [[S_b:%[0-9]+]] = bitcast %"2.std::option::Option<i32>"** %b to i8*
|
||||
// CHECK: call void @llvm.lifetime.start(i{{[0-9 ]+}}, i8* [[S_b]])
|
||||
|
||||
// CHECK: [[S_tmp2:%[0-9]+]] = bitcast %"2.std::option::Option<i32>"* %tmp2 to i8*
|
||||
// CHECK: call void @llvm.lifetime.start(i{{[0-9 ]+}}, i8* [[S_tmp2]])
|
||||
// CHECK: [[S__5:%[0-9]+]] = bitcast %"2.std::option::Option<i32>"* %_5 to i8*
|
||||
// CHECK: call void @llvm.lifetime.start(i{{[0-9 ]+}}, i8* [[S__5]])
|
||||
|
||||
// CHECK: [[E_tmp2:%[0-9]+]] = bitcast %"2.std::option::Option<i32>"* %tmp2 to i8*
|
||||
// CHECK: call void @llvm.lifetime.end(i{{[0-9 ]+}}, i8* [[E_tmp2]])
|
||||
// CHECK: [[E__5:%[0-9]+]] = bitcast %"2.std::option::Option<i32>"* %_5 to i8*
|
||||
// CHECK: call void @llvm.lifetime.end(i{{[0-9 ]+}}, i8* [[E__5]])
|
||||
|
||||
// CHECK: [[E_b:%[0-9]+]] = bitcast %"2.std::option::Option<i32>"** %b to i8*
|
||||
// CHECK: call void @llvm.lifetime.end(i{{[0-9 ]+}}, i8* [[E_b]])
|
||||
|
|
|
|||
|
|
@ -23,19 +23,19 @@ fn main() {}
|
|||
// END RUST SOURCE
|
||||
// START rustc.node13.Deaggregator.before.mir
|
||||
// bb0: {
|
||||
// var0 = arg0; // scope 0 at main.rs:8:8: 8:9
|
||||
// tmp0 = var0; // scope 1 at main.rs:9:14: 9:15
|
||||
// return = Baz { x: tmp0, y: const F32(0), z: const false }; // scope ...
|
||||
// goto -> bb1; // scope 1 at main.rs:8:1: 10:2
|
||||
// _2 = _1;
|
||||
// _3 = _2;
|
||||
// _0 = Baz { x: _3, y: const F32(0), z: const false };
|
||||
// goto -> bb1;
|
||||
// }
|
||||
// END rustc.node13.Deaggregator.before.mir
|
||||
// START rustc.node13.Deaggregator.after.mir
|
||||
// bb0: {
|
||||
// var0 = arg0; // scope 0 at main.rs:8:8: 8:9
|
||||
// tmp0 = var0; // scope 1 at main.rs:9:14: 9:15
|
||||
// (return.0: usize) = tmp0; // scope 1 at main.rs:9:5: 9:34
|
||||
// (return.1: f32) = const F32(0); // scope 1 at main.rs:9:5: 9:34
|
||||
// (return.2: bool) = const false; // scope 1 at main.rs:9:5: 9:34
|
||||
// goto -> bb1; // scope 1 at main.rs:8:1: 10:2
|
||||
// _2 = _1;
|
||||
// _3 = _2;
|
||||
// (_0.0: usize) = _3;
|
||||
// (_0.1: f32) = const F32(0);
|
||||
// (_0.2: bool) = const false;
|
||||
// goto -> bb1;
|
||||
// }
|
||||
// END rustc.node13.Deaggregator.after.mir
|
||||
// END rustc.node13.Deaggregator.after.mir
|
||||
|
|
|
|||
|
|
@ -28,18 +28,18 @@ fn main() {
|
|||
// END RUST SOURCE
|
||||
// START rustc.node10.Deaggregator.before.mir
|
||||
// bb0: {
|
||||
// var0 = arg0; // scope 0 at main.rs:7:8: 7:9
|
||||
// tmp0 = var0; // scope 1 at main.rs:8:19: 8:20
|
||||
// return = Baz::Foo { x: tmp0 }; // scope 1 at main.rs:8:5: 8:21
|
||||
// goto -> bb1; // scope 1 at main.rs:7:1: 9:2
|
||||
// _2 = _1;
|
||||
// _3 = _2;
|
||||
// _0 = Baz::Foo { x: _3 };
|
||||
// goto -> bb1;
|
||||
// }
|
||||
// END rustc.node10.Deaggregator.before.mir
|
||||
// START rustc.node10.Deaggregator.after.mir
|
||||
// bb0: {
|
||||
// var0 = arg0; // scope 0 at main.rs:7:8: 7:9
|
||||
// tmp0 = var0; // scope 1 at main.rs:8:19: 8:20
|
||||
// ((return as Foo).0: usize) = tmp0; // scope 1 at main.rs:8:5: 8:21
|
||||
// discriminant(return) = 1; // scope 1 at main.rs:8:5: 8:21
|
||||
// goto -> bb1; // scope 1 at main.rs:7:1: 9:2
|
||||
// _2 = _1;
|
||||
// _3 = _2;
|
||||
// ((_0 as Foo).0: usize) = _3;
|
||||
// discriminant(_0) = 1;
|
||||
// goto -> bb1;
|
||||
// }
|
||||
// END rustc.node10.Deaggregator.after.mir
|
||||
// END rustc.node10.Deaggregator.after.mir
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ fn main() {
|
|||
// END RUST SOURCE
|
||||
// START rustc.node4.SimplifyBranches.initial-before.mir
|
||||
// bb0: {
|
||||
// if(const false) -> [true: bb1, false: bb2]; // scope 0 at simplify_if.rs:12:5: 14:6
|
||||
// if(const false) -> [true: bb1, false: bb2];
|
||||
// }
|
||||
// END rustc.node4.SimplifyBranches.initial-before.mir
|
||||
// START rustc.node4.SimplifyBranches.initial-after.mir
|
||||
// bb0: {
|
||||
// goto -> bb2; // scope 0 at simplify_if.rs:12:5: 14:6
|
||||
// goto -> bb2;
|
||||
// }
|
||||
// END rustc.node4.SimplifyBranches.initial-after.mir
|
||||
// END rustc.node4.SimplifyBranches.initial-after.mir
|
||||
|
|
|
|||
|
|
@ -21,27 +21,27 @@ fn main() {
|
|||
// END RUST SOURCE
|
||||
// START rustc.node4.TypeckMir.before.mir
|
||||
// bb0: {
|
||||
// StorageLive(var0); // scope 0 at storage_ranges.rs:14:9: 14:10
|
||||
// var0 = const 0i32; // scope 0 at storage_ranges.rs:14:13: 14:14
|
||||
// StorageLive(var1); // scope 1 at storage_ranges.rs:16:13: 16:14
|
||||
// StorageLive(tmp1); // scope 1 at storage_ranges.rs:16:18: 16:25
|
||||
// StorageLive(tmp2); // scope 1 at storage_ranges.rs:16:23: 16:24
|
||||
// tmp2 = var0; // scope 1 at storage_ranges.rs:16:23: 16:24
|
||||
// tmp1 = std::option::Option<i32>::Some(tmp2,); // scope 1 at storage_ranges.rs:16:18: 16:25
|
||||
// var1 = &tmp1; // scope 1 at storage_ranges.rs:16:17: 16:25
|
||||
// StorageDead(tmp2); // scope 1 at storage_ranges.rs:16:23: 16:24
|
||||
// tmp0 = (); // scope 2 at storage_ranges.rs:15:5: 17:6
|
||||
// StorageDead(tmp1); // scope 1 at storage_ranges.rs:16:18: 16:25
|
||||
// StorageDead(var1); // scope 1 at storage_ranges.rs:16:13: 16:14
|
||||
// StorageLive(var2); // scope 1 at storage_ranges.rs:18:9: 18:10
|
||||
// var2 = const 1i32; // scope 1 at storage_ranges.rs:18:13: 18:14
|
||||
// return = (); // scope 3 at storage_ranges.rs:13:11: 19:2
|
||||
// StorageDead(var2); // scope 1 at storage_ranges.rs:18:9: 18:10
|
||||
// StorageDead(var0); // scope 0 at storage_ranges.rs:14:9: 14:10
|
||||
// goto -> bb1; // scope 0 at storage_ranges.rs:13:1: 19:2
|
||||
// StorageLive(_1);
|
||||
// _1 = const 0i32;
|
||||
// StorageLive(_3);
|
||||
// StorageLive(_4);
|
||||
// StorageLive(_5);
|
||||
// _5 = _1;
|
||||
// _4 = std::option::Option<i32>::Some(_5,);
|
||||
// _3 = &_4;
|
||||
// StorageDead(_5);
|
||||
// _2 = ();
|
||||
// StorageDead(_4);
|
||||
// StorageDead(_3);
|
||||
// StorageLive(_6);
|
||||
// _6 = const 1i32;
|
||||
// _0 = ();
|
||||
// StorageDead(_6);
|
||||
// StorageDead(_1);
|
||||
// goto -> bb1;
|
||||
// }
|
||||
//
|
||||
// bb1: {
|
||||
// return; // scope 0 at storage_ranges.rs:13:1: 19:2
|
||||
// return;
|
||||
// }
|
||||
// END rustc.node4.TypeckMir.before.mir
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue