forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#106036 - JohnTitor:issue-86106, r=nikic
Add regression test for rust-lang#86106 Closes rust-lang#86106 r? `@nikic` Signed-off-by: Yuki Okushi <[email protected]>
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// min-llvm-version: 15.0 | ||
// compile-flags: -C opt-level=3 | ||
|
||
// The below two functions ensure that both `String::new()` and `"".to_string()` | ||
// produce the identical code. | ||
|
||
#![crate_type = "lib"] | ||
|
||
// CHECK-LABEL: @string_new = unnamed_addr alias void (ptr), ptr @empty_to_string | ||
#[no_mangle] | ||
pub fn string_new() -> String { | ||
String::new() | ||
} | ||
|
||
// 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-NEXT: getelementptr | ||
// 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> { | ||
// CHECK: store i{{32|64}} | ||
// CHECK-NOT: load i8 | ||
// CHECK-NEXT: getelementptr | ||
// 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> { | ||
// CHECK: store i{{32|64}} | ||
// CHECK-NOT: load i8 | ||
// CHECK-NEXT: getelementptr | ||
// CHECK-NEXT: store ptr | ||
// CHECK-NEXT: getelementptr | ||
// CHECK-NEXT: store i{{32|64}} | ||
// CHECK-NEXT: ret void | ||
vec![].clone() | ||
} |