Skip to content

Commit

Permalink
Rollup merge of rust-lang#82799 - bugadani:codegen-tests, r=nagisa
Browse files Browse the repository at this point in the history
Add regression test for rust-lang#75525
  • Loading branch information
m-ou-se authored Mar 9, 2021
2 parents bfa0873 + 10a4c67 commit 5574680
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/test/codegen/issue-75525-bounds-checks.rs
Original file line number Diff line number Diff line change
@@ -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 }
}

0 comments on commit 5574680

Please sign in to comment.