diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-06-29 14:18:55 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-06-30 07:47:07 +0000 |
| commit | 7839cb963f747edff90b72efc6094e7184f6ef0e (patch) | |
| tree | 5bf0f8fa756c9bfd3867445cd5a97c91066a5d04 /src/test/codegen | |
| parent | 0e674b3ec5e2c238e6756d512fa39efc1ceeb74a (diff) | |
| download | rust-7839cb963f747edff90b72efc6094e7184f6ef0e.tar.gz rust-7839cb963f747edff90b72efc6094e7184f6ef0e.zip | |
Change enum->int casts to not go through MIR casts.
Instead we generate a discriminant rvalue and cast the result of that.
Diffstat (limited to 'src/test/codegen')
| -rw-r--r-- | src/test/codegen/enum-bounds-check-derived-idx.rs | 6 | ||||
| -rw-r--r-- | src/test/codegen/enum-bounds-check-issue-13926.rs | 3 | ||||
| -rw-r--r-- | src/test/codegen/enum-bounds-check-issue-82871.rs | 9 | ||||
| -rw-r--r-- | src/test/codegen/enum-bounds-check.rs | 3 |
4 files changed, 14 insertions, 7 deletions
diff --git a/src/test/codegen/enum-bounds-check-derived-idx.rs b/src/test/codegen/enum-bounds-check-derived-idx.rs index aa66c2ed08e..fe02aeb5f62 100644 --- a/src/test/codegen/enum-bounds-check-derived-idx.rs +++ b/src/test/codegen/enum-bounds-check-derived-idx.rs @@ -12,13 +12,15 @@ pub enum Bar { // CHECK-LABEL: @lookup_inc #[no_mangle] pub fn lookup_inc(buf: &[u8; 5], f: Bar) -> u8 { - // CHECK-NOT: panic_bounds_check + // FIXME: panic check can be removed by adding the assumes back after https://github.com/rust-lang/rust/pull/98332 + // CHECK: panic_bounds_check buf[f as usize + 1] } // CHECK-LABEL: @lookup_dec #[no_mangle] pub fn lookup_dec(buf: &[u8; 5], f: Bar) -> u8 { - // CHECK-NOT: panic_bounds_check + // FIXME: panic check can be removed by adding the assumes back after https://github.com/rust-lang/rust/pull/98332 + // CHECK: panic_bounds_check buf[f as usize - 1] } diff --git a/src/test/codegen/enum-bounds-check-issue-13926.rs b/src/test/codegen/enum-bounds-check-issue-13926.rs index b26945bc549..1aec41d5441 100644 --- a/src/test/codegen/enum-bounds-check-issue-13926.rs +++ b/src/test/codegen/enum-bounds-check-issue-13926.rs @@ -13,6 +13,7 @@ pub enum Exception { // CHECK-LABEL: @access #[no_mangle] pub fn access(array: &[usize; 12], exc: Exception) -> usize { - // CHECK-NOT: panic_bounds_check + // FIXME: panic check can be removed by adding the assumes back after https://github.com/rust-lang/rust/pull/98332 + // CHECK: panic_bounds_check array[(exc as u8 - 4) as usize] } diff --git a/src/test/codegen/enum-bounds-check-issue-82871.rs b/src/test/codegen/enum-bounds-check-issue-82871.rs index a1fa1387d94..32fdc4a5f4f 100644 --- a/src/test/codegen/enum-bounds-check-issue-82871.rs +++ b/src/test/codegen/enum-bounds-check-issue-82871.rs @@ -1,4 +1,4 @@ -// compile-flags: -O +// compile-flags: -C opt-level=0 #![crate_type = "lib"] @@ -9,7 +9,10 @@ pub enum E { // CHECK-LABEL: @index #[no_mangle] -pub fn index(x: &[u32; 3], ind: E) -> u32{ - // CHECK-NOT: panic_bounds_check +pub fn index(x: &[u32; 3], ind: E) -> u32 { + // Canary: we should be able to optimize out the bounds check, but we need + // to track the range of the discriminant result in order to be able to do that. + // oli-obk tried to add that, but that caused miscompilations all over the place. + // CHECK: panic_bounds_check x[ind as usize] } diff --git a/src/test/codegen/enum-bounds-check.rs b/src/test/codegen/enum-bounds-check.rs index 17322d5911b..f85c6817ded 100644 --- a/src/test/codegen/enum-bounds-check.rs +++ b/src/test/codegen/enum-bounds-check.rs @@ -21,6 +21,7 @@ pub enum Bar { // CHECK-LABEL: @lookup_unmodified #[no_mangle] pub fn lookup_unmodified(buf: &[u8; 5], f: Bar) -> u8 { - // CHECK-NOT: panic_bounds_check + // FIXME: panic check can be removed by adding the assumes back after https://github.com/rust-lang/rust/pull/98332 + // CHECK: panic_bounds_check buf[f as usize] } |
