diff options
| author | bors <bors@rust-lang.org> | 2021-03-09 09:43:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-03-09 09:43:55 +0000 |
| commit | 3a5d45f68cadc8fff4fbb557780f92b403b19c19 (patch) | |
| tree | 2d80555f16636c76ee9e5d452078c13f19cc1f4a /src/test/codegen | |
| parent | 4b9f5cc4c10a161047475cb9bbe02c4fda57fb07 (diff) | |
| parent | 74de9db0ce515a26171c441cd808e6d872010f86 (diff) | |
| download | rust-3a5d45f68cadc8fff4fbb557780f92b403b19c19.tar.gz rust-3a5d45f68cadc8fff4fbb557780f92b403b19c19.zip | |
Auto merge of #82929 - m-ou-se:rollup-7fwrewh, r=m-ou-se
Rollup of 8 pull requests Successful merges: - #81127 (Improve sift_down performance in BinaryHeap) - #81879 (Added #[repr(transparent)] to core::cmp::Reverse) - #82048 (or-patterns: disallow in `let` bindings) - #82731 (Bump libc dependency of std to 0.2.88.) - #82799 (Add regression test for #75525) - #82841 (Change x64 size checks to not apply to x32.) - #82883 (Update Cargo) - #82887 (Update CONTRIBUTING.md) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/test/codegen')
| -rw-r--r-- | src/test/codegen/issue-75525-bounds-checks.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/codegen/issue-75525-bounds-checks.rs b/src/test/codegen/issue-75525-bounds-checks.rs new file mode 100644 index 00000000000..a03c63c1d09 --- /dev/null +++ b/src/test/codegen/issue-75525-bounds-checks.rs @@ -0,0 +1,27 @@ +// Regression test for #75525, verifies that no bounds checks are generated. + +// min-llvm-version: 12.0.0 +// compile-flags: -O + +#![crate_type = "lib"] + +// CHECK-LABEL: @f0 +// CHECK-NOT: panic +#[no_mangle] +pub fn f0(idx: usize, buf: &[u8; 10]) -> u8 { + if idx < 8 { buf[idx + 1] } else { 0 } +} + +// CHECK-LABEL: @f1 +// CHECK-NOT: panic +#[no_mangle] +pub fn f1(idx: usize, buf: &[u8; 10]) -> u8 { + if idx > 5 && idx < 8 { buf[idx - 1] } else { 0 } +} + +// CHECK-LABEL: @f2 +// CHECK-NOT: panic +#[no_mangle] +pub fn f2(idx: usize, buf: &[u8; 10]) -> u8 { + if idx > 5 && idx < 8 { buf[idx] } else { 0 } +} |
