summaryrefslogtreecommitdiffstats
path: root/tests/codegen/issues
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
commit837b550238aa671a591ccf282dddeab29cadb206 (patch)
tree914b6b8862bace72bd3245ca184d374b08d8a672 /tests/codegen/issues
parentAdding debian version 1.70.0+dfsg2-1. (diff)
downloadrustc-837b550238aa671a591ccf282dddeab29cadb206.tar.xz
rustc-837b550238aa671a591ccf282dddeab29cadb206.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/codegen/issues')
-rw-r--r--tests/codegen/issues/issue-103840.rs1
-rw-r--r--tests/codegen/issues/issue-105386-ub-in-debuginfo.rs3
-rw-r--r--tests/codegen/issues/issue-111603.rs28
-rw-r--r--tests/codegen/issues/issue-73396-bounds-check-after-position.rs30
-rw-r--r--tests/codegen/issues/issue-86106.rs29
5 files changed, 64 insertions, 27 deletions
diff --git a/tests/codegen/issues/issue-103840.rs b/tests/codegen/issues/issue-103840.rs
index f19d7031b..da64692d2 100644
--- a/tests/codegen/issues/issue-103840.rs
+++ b/tests/codegen/issues/issue-103840.rs
@@ -1,4 +1,5 @@
// compile-flags: -O
+// min-llvm-version: 16.0
#![crate_type = "lib"]
pub fn foo(t: &mut Vec<usize>) {
diff --git a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs
index d54ac9e33..2ee4d7cca 100644
--- a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs
+++ b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs
@@ -19,4 +19,5 @@ pub fn outer_function(x: S, y: S) -> usize {
// CHECK-NOT: [[ptr_tmp:%.*]] = getelementptr inbounds %"[closure@{{.*.rs}}:9:23: 9:25]", ptr [[spill]]
// CHECK-NOT: [[load:%.*]] = load ptr, ptr
// CHECK: call void @llvm.lifetime.start{{.*}}({{.*}}, ptr [[spill]])
-// CHECK: call void @llvm.memcpy{{.*}}(ptr {{align .*}} [[spill]], ptr {{align .*}} %x
+// CHECK: [[inner:%.*]] = getelementptr inbounds %"{{.*}}", ptr [[spill]]
+// CHECK: call void @llvm.memcpy{{.*}}(ptr {{align .*}} [[inner]], ptr {{align .*}} %x
diff --git a/tests/codegen/issues/issue-111603.rs b/tests/codegen/issues/issue-111603.rs
new file mode 100644
index 000000000..90b3c314d
--- /dev/null
+++ b/tests/codegen/issues/issue-111603.rs
@@ -0,0 +1,28 @@
+// compile-flags: -O
+
+#![crate_type = "lib"]
+#![feature(get_mut_unchecked, new_uninit)]
+
+use std::sync::Arc;
+
+// CHECK-LABEL: @new_uninit
+#[no_mangle]
+pub fn new_uninit(x: u64) -> Arc<[u64; 1000]> {
+ // CHECK: call alloc::sync::arcinner_layout_for_value_layout
+ // CHECK-NOT: call alloc::sync::arcinner_layout_for_value_layout
+ let mut arc = Arc::new_uninit();
+ unsafe { Arc::get_mut_unchecked(&mut arc) }.write([x; 1000]);
+ unsafe { arc.assume_init() }
+}
+
+// CHECK-LABEL: @new_uninit_slice
+#[no_mangle]
+pub fn new_uninit_slice(x: u64) -> Arc<[u64]> {
+ // CHECK: call alloc::sync::arcinner_layout_for_value_layout
+ // CHECK-NOT: call alloc::sync::arcinner_layout_for_value_layout
+ let mut arc = Arc::new_uninit_slice(1000);
+ for elem in unsafe { Arc::get_mut_unchecked(&mut arc) } {
+ elem.write(x);
+ }
+ unsafe { arc.assume_init() }
+}
diff --git a/tests/codegen/issues/issue-73396-bounds-check-after-position.rs b/tests/codegen/issues/issue-73396-bounds-check-after-position.rs
index 8d07a67a1..2d7797887 100644
--- a/tests/codegen/issues/issue-73396-bounds-check-after-position.rs
+++ b/tests/codegen/issues/issue-73396-bounds-check-after-position.rs
@@ -9,7 +9,10 @@
#[no_mangle]
pub fn position_slice_to_no_bounds_check(s: &[u8]) -> &[u8] {
// CHECK-NOT: panic
- // CHECK-NOT: slice_index_len_fail
+ // CHECK-NOT: slice_start_index_len_fail
+ // CHECK-NOT: slice_end_index_len_fail
+ // CHECK-NOT: panic_bounds_check
+ // CHECK-NOT: unreachable
if let Some(idx) = s.iter().position(|b| *b == b'\\') {
&s[..idx]
} else {
@@ -21,7 +24,10 @@ pub fn position_slice_to_no_bounds_check(s: &[u8]) -> &[u8] {
#[no_mangle]
pub fn position_slice_from_no_bounds_check(s: &[u8]) -> &[u8] {
// CHECK-NOT: panic
- // CHECK-NOT: slice_index_len_fail
+ // CHECK-NOT: slice_start_index_len_fail
+ // CHECK-NOT: slice_end_index_len_fail
+ // CHECK-NOT: panic_bounds_check
+ // CHECK-NOT: unreachable
if let Some(idx) = s.iter().position(|b| *b == b'\\') {
&s[idx..]
} else {
@@ -33,7 +39,10 @@ pub fn position_slice_from_no_bounds_check(s: &[u8]) -> &[u8] {
#[no_mangle]
pub fn position_index_no_bounds_check(s: &[u8]) -> u8 {
// CHECK-NOT: panic
- // CHECK-NOT: slice_index_len_fail
+ // CHECK-NOT: slice_start_index_len_fail
+ // CHECK-NOT: slice_end_index_len_fail
+ // CHECK-NOT: panic_bounds_check
+ // CHECK-NOT: unreachable
if let Some(idx) = s.iter().position(|b| *b == b'\\') {
s[idx]
} else {
@@ -44,7 +53,10 @@ pub fn position_index_no_bounds_check(s: &[u8]) -> u8 {
#[no_mangle]
pub fn rposition_slice_to_no_bounds_check(s: &[u8]) -> &[u8] {
// CHECK-NOT: panic
- // CHECK-NOT: slice_index_len_fail
+ // CHECK-NOT: slice_start_index_len_fail
+ // CHECK-NOT: slice_end_index_len_fail
+ // CHECK-NOT: panic_bounds_check
+ // CHECK-NOT: unreachable
if let Some(idx) = s.iter().rposition(|b| *b == b'\\') {
&s[..idx]
} else {
@@ -56,7 +68,10 @@ pub fn rposition_slice_to_no_bounds_check(s: &[u8]) -> &[u8] {
#[no_mangle]
pub fn rposition_slice_from_no_bounds_check(s: &[u8]) -> &[u8] {
// CHECK-NOT: panic
- // CHECK-NOT: slice_index_len_fail
+ // CHECK-NOT: slice_start_index_len_fail
+ // CHECK-NOT: slice_end_index_len_fail
+ // CHECK-NOT: panic_bounds_check
+ // CHECK-NOT: unreachable
if let Some(idx) = s.iter().rposition(|b| *b == b'\\') {
&s[idx..]
} else {
@@ -68,7 +83,10 @@ pub fn rposition_slice_from_no_bounds_check(s: &[u8]) -> &[u8] {
#[no_mangle]
pub fn rposition_index_no_bounds_check(s: &[u8]) -> u8 {
// CHECK-NOT: panic
- // CHECK-NOT: slice_index_len_fail
+ // CHECK-NOT: slice_start_index_len_fail
+ // CHECK-NOT: slice_end_index_len_fail
+ // CHECK-NOT: panic_bounds_check
+ // CHECK-NOT: unreachable
if let Some(idx) = s.iter().rposition(|b| *b == b'\\') {
s[idx]
} else {
diff --git a/tests/codegen/issues/issue-86106.rs b/tests/codegen/issues/issue-86106.rs
index 9ccbcb24f..c0be7fab2 100644
--- a/tests/codegen/issues/issue-86106.rs
+++ b/tests/codegen/issues/issue-86106.rs
@@ -1,4 +1,5 @@
// min-llvm-version: 15.0
+// only-64bit llvm appears to use stores instead of memset on 32bit
// compile-flags: -C opt-level=3 -Z merge-functions=disabled
// The below two functions ensure that both `String::new()` and `"".to_string()`
@@ -9,12 +10,9 @@
// CHECK-LABEL: define void @string_new
#[no_mangle]
pub fn string_new() -> String {
- // CHECK-NOT: load i8
- // CHECK: store i{{32|64}}
+ // CHECK: store ptr inttoptr
// CHECK-NEXT: getelementptr
- // CHECK-NEXT: store ptr
- // CHECK-NEXT: getelementptr
- // CHECK-NEXT: store i{{32|64}}
+ // CHECK-NEXT: call void @llvm.memset
// CHECK-NEXT: ret void
String::new()
}
@@ -22,12 +20,9 @@ pub fn string_new() -> String {
// CHECK-LABEL: define void @empty_to_string
#[no_mangle]
pub fn empty_to_string() -> String {
- // CHECK-NOT: load i8
- // CHECK: store i{{32|64}}
- // CHECK-NEXT: getelementptr
- // CHECK-NEXT: store ptr
+ // CHECK: store ptr inttoptr
// CHECK-NEXT: getelementptr
- // CHECK-NEXT: store i{{32|64}}
+ // CHECK-NEXT: call void @llvm.memset
// CHECK-NEXT: ret void
"".to_string()
}
@@ -38,12 +33,9 @@ pub fn empty_to_string() -> String {
// CHECK-LABEL: @empty_vec
#[no_mangle]
pub fn empty_vec() -> Vec<u8> {
- // CHECK: store i{{32|64}}
- // CHECK-NOT: load i8
+ // CHECK: store ptr inttoptr
// CHECK-NEXT: getelementptr
- // CHECK-NEXT: store ptr
- // CHECK-NEXT: getelementptr
- // CHECK-NEXT: store i{{32|64}}
+ // CHECK-NEXT: call void @llvm.memset
// CHECK-NEXT: ret void
vec![]
}
@@ -51,12 +43,9 @@ pub fn empty_vec() -> Vec<u8> {
// CHECK-LABEL: @empty_vec_clone
#[no_mangle]
pub fn empty_vec_clone() -> Vec<u8> {
- // CHECK: store i{{32|64}}
- // CHECK-NOT: load i8
- // CHECK-NEXT: getelementptr
- // CHECK-NEXT: store ptr
+ // CHECK: store ptr inttoptr
// CHECK-NEXT: getelementptr
- // CHECK-NEXT: store i{{32|64}}
+ // CHECK-NEXT: call void @llvm.memset
// CHECK-NEXT: ret void
vec![].clone()
}