diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2020-11-15 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2020-11-15 00:00:00 +0000 |
| commit | f27d56d1ff2fdbb86cb1fc86fb06bf32f009ada0 (patch) | |
| tree | 30cd6a34abaae0085f34220f89a31ef977439368 /src | |
| parent | 75042566d1c90d912f22e4db43b6d3af98447986 (diff) | |
| download | rust-f27d56d1ff2fdbb86cb1fc86fb06bf32f009ada0.tar.gz rust-f27d56d1ff2fdbb86cb1fc86fb06bf32f009ada0.zip | |
Limit storage duration of inlined always live locals
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/mir-opt/inline/inline_diverging.h.Inline.diff | 1 | ||||
| -rw-r--r-- | src/test/mir-opt/inline/inline_generator.main.Inline.diff | 4 | ||||
| -rw-r--r-- | src/test/mir-opt/inline/inline_shims.drop.Inline.diff | 4 | ||||
| -rw-r--r-- | src/test/ui/mir/auxiliary/issue_76375_aux.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/mir/issue-76375.rs | 16 |
5 files changed, 31 insertions, 4 deletions
diff --git a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff index b728ad4b428..07994eb3c16 100644 --- a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff +++ b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff @@ -40,6 +40,7 @@ - // mir::Constant // + span: $DIR/inline-diverging.rs:22:16: 22:21 // + literal: Const { ty: fn() -> ! {sleep}, val: Value(Scalar(<ZST>)) } ++ StorageLive(_6); // scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 + StorageLive(_3); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + StorageLive(_4); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + _4 = &_2; // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 diff --git a/src/test/mir-opt/inline/inline_generator.main.Inline.diff b/src/test/mir-opt/inline/inline_generator.main.Inline.diff index aa32daa82dd..99497a6fc79 100644 --- a/src/test/mir-opt/inline/inline_generator.main.Inline.diff +++ b/src/test/mir-opt/inline/inline_generator.main.Inline.diff @@ -65,12 +65,16 @@ - // + literal: Const { ty: for<'r> fn(std::pin::Pin<&'r mut impl std::ops::Generator<bool>>, bool) -> std::ops::GeneratorState<<impl std::ops::Generator<bool> as std::ops::Generator<bool>>::Yield, <impl std::ops::Generator<bool> as std::ops::Generator<bool>>::Return> {<impl std::ops::Generator<bool> as std::ops::Generator<bool>>::resume}, val: Value(Scalar(<ZST>)) } + StorageLive(_7); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 + _7 = const false; // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageLive(_8); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageLive(_9); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 + _9 = discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]))); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + switchInt(move _9) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 } - bb3: { + bb1: { ++ StorageDead(_9); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageDead(_8); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 + StorageDead(_7); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 StorageDead(_2); // scope 0 at $DIR/inline-generator.rs:9:45: 9:46 StorageDead(_4); // scope 0 at $DIR/inline-generator.rs:9:46: 9:47 diff --git a/src/test/mir-opt/inline/inline_shims.drop.Inline.diff b/src/test/mir-opt/inline/inline_shims.drop.Inline.diff index 503d8bc6b7a..092ff42c3b6 100644 --- a/src/test/mir-opt/inline/inline_shims.drop.Inline.diff +++ b/src/test/mir-opt/inline/inline_shims.drop.Inline.diff @@ -36,11 +36,15 @@ - // mir::Constant - // + span: $DIR/inline-shims.rs:12:14: 12:37 - // + literal: Const { ty: unsafe fn(*mut std::option::Option<B>) {std::intrinsics::drop_in_place::<std::option::Option<B>>}, val: Value(Scalar(<ZST>)) } ++ StorageLive(_6); // scope 2 at $DIR/inline-shims.rs:12:14: 12:40 ++ StorageLive(_7); // scope 2 at $DIR/inline-shims.rs:12:14: 12:40 + _6 = discriminant((*_5)); // scope 3 at $DIR/inline-shims.rs:12:14: 12:40 + switchInt(move _6) -> [0_isize: bb2, otherwise: bb3]; // scope 3 at $DIR/inline-shims.rs:12:14: 12:40 } bb2: { ++ StorageDead(_7); // scope 2 at $DIR/inline-shims.rs:12:14: 12:40 ++ StorageDead(_6); // scope 2 at $DIR/inline-shims.rs:12:14: 12:40 StorageDead(_5); // scope 2 at $DIR/inline-shims.rs:12:39: 12:40 return; // scope 0 at $DIR/inline-shims.rs:13:2: 13:2 + } diff --git a/src/test/ui/mir/auxiliary/issue_76375_aux.rs b/src/test/ui/mir/auxiliary/issue_76375_aux.rs index f8b318d58ba..72f32ecf7ea 100644 --- a/src/test/ui/mir/auxiliary/issue_76375_aux.rs +++ b/src/test/ui/mir/auxiliary/issue_76375_aux.rs @@ -1,8 +1,8 @@ // edition:2018 -// compile-flags: -Z mir-opt-level=2 -Z unsound-mir-opts +// compile-flags: -Z mir-opt-level=2 #[inline(always)] -pub fn f(s: bool) -> String { +pub fn copy_prop(s: bool) -> String { let a = "Hello world!".to_string(); let b = a; let c = b; @@ -12,3 +12,9 @@ pub fn f(s: bool) -> String { String::new() } } + +#[inline(always)] +pub fn dest_prop(x: &[u8]) -> &[u8] { + let y = &x[..x.len()]; + y +} diff --git a/src/test/ui/mir/issue-76375.rs b/src/test/ui/mir/issue-76375.rs index ef459f6a28e..a7772cb1fe6 100644 --- a/src/test/ui/mir/issue-76375.rs +++ b/src/test/ui/mir/issue-76375.rs @@ -1,6 +1,8 @@ +// Regression test for issue #76375. +// // edition:2018 // build-pass -// compile-flags: -Z mir-opt-level=2 -L. +// compile-flags: -Z mir-opt-level=2 // aux-build:issue_76375_aux.rs #![crate_type = "lib"] @@ -8,8 +10,18 @@ extern crate issue_76375_aux; pub async fn g() { - issue_76375_aux::f(true); + issue_76375_aux::copy_prop(true); h().await; } +pub async fn u() { + let b = [0u8; 32]; + let mut i = 0; + while i != 10 { + issue_76375_aux::dest_prop(&b); + h().await; + i += 1; + } +} + pub async fn h() {} |
