rust/tests/codegen/issues/issue-86106.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
1.7 KiB
Rust
Raw Normal View History

2023-04-05 14:15:32 -05:00
//@ only-64bit llvm appears to use stores instead of memset on 32bit
//@ compile-flags: -C opt-level=3 -Z merge-functions=disabled
2022-09-02 13:15:53 -05:00
//@ needs-deterministic-layouts
// The below two functions ensure that both `String::new()` and `"".to_string()`
// produce the identical code.
#![crate_type = "lib"]
// CHECK-LABEL: define {{(dso_local )?}}void @string_new
#[no_mangle]
pub fn string_new() -> String {
2023-01-12 15:54:27 -06:00
// CHECK-NOT: load i8
// CHECK: store i{{32|64}}
// CHECK-NEXT: getelementptr
2023-01-12 15:54:27 -06:00
// CHECK-NEXT: store ptr
// CHECK-NEXT: getelementptr
// CHECK-NEXT: store i{{32|64}}
// CHECK-NEXT: ret void
String::new()
}
// CHECK-LABEL: define {{(dso_local )?}}void @empty_to_string
#[no_mangle]
pub fn empty_to_string() -> String {
2023-01-12 15:54:27 -06:00
// CHECK-NOT: load i8
// CHECK: store i{{32|64}}
// CHECK-NEXT: getelementptr
// CHECK-NEXT: store ptr
2023-04-05 14:15:32 -05:00
// CHECK-NEXT: getelementptr
2023-01-12 15:54:27 -06:00
// CHECK-NEXT: store i{{32|64}}
// CHECK-NEXT: ret void
"".to_string()
}
// The below two functions ensure that both `vec![]` and `vec![].clone()`
// produce the identical code.
// CHECK-LABEL: @empty_vec
#[no_mangle]
pub fn empty_vec() -> Vec<u8> {
2023-01-12 15:54:27 -06:00
// CHECK: store i{{32|64}}
// CHECK-NOT: load i8
// CHECK-NEXT: getelementptr
2023-01-12 15:54:27 -06:00
// CHECK-NEXT: store ptr
// CHECK-NEXT: getelementptr
// CHECK-NEXT: store i{{32|64}}
// CHECK-NEXT: ret void
vec![]
}
// CHECK-LABEL: @empty_vec_clone
#[no_mangle]
pub fn empty_vec_clone() -> Vec<u8> {
2023-01-12 15:54:27 -06:00
// CHECK: store i{{32|64}}
// CHECK-NOT: load i8
// CHECK-NEXT: getelementptr
// CHECK-NEXT: store ptr
// CHECK-NEXT: getelementptr
2023-01-12 15:54:27 -06:00
// CHECK-NEXT: store i{{32|64}}
// CHECK-NEXT: ret void
vec![].clone()
}