Skip to content

Commit e7d9396

Browse files
authored
Rollup merge of rust-lang#72547 - alex:patch-1, r=oli-obk
Added a codegen test for a recent optimization for overflow-checks=on Closes rust-lang#58692
2 parents e200252 + cd5f228 commit e7d9396

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/test/codegen/integer-overflow.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// no-system-llvm
2+
// compile-flags: -O -C overflow-checks=on
3+
4+
#![crate_type = "lib"]
5+
6+
7+
pub struct S1<'a> {
8+
data: &'a [u8],
9+
position: usize,
10+
}
11+
12+
// CHECK-LABEL: @slice_no_index_order
13+
#[no_mangle]
14+
pub fn slice_no_index_order<'a>(s: &'a mut S1, n: usize) -> &'a [u8] {
15+
// CHECK-NOT: slice_index_order_fail
16+
let d = &s.data[s.position..s.position+n];
17+
s.position += n;
18+
return d;
19+
}
20+
21+
// CHECK-LABEL: @test_check
22+
#[no_mangle]
23+
pub fn test_check<'a>(s: &'a mut S1, x: usize, y: usize) -> &'a [u8] {
24+
// CHECK: slice_index_order_fail
25+
&s.data[x..y]
26+
}

0 commit comments

Comments
 (0)