forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Nikita Popov <github@npopov.com>
- Loading branch information
Showing
11 changed files
with
37 additions
and
55 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
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
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 |
---|---|---|
@@ -1,27 +1,26 @@ | ||
//@ compile-flags: -O | ||
// XXX: The x86-64 assembly get optimized correclty. But llvm-ir output is not until llvm 18? | ||
//@ min-llvm-version: 18 | ||
|
||
#![crate_type = "lib"] | ||
|
||
pub enum K{ | ||
pub enum K { | ||
A(Box<[i32]>), | ||
B(Box<[u8]>), | ||
C(Box<[String]>), | ||
D(Box<[u16]>), | ||
} | ||
|
||
#[no_mangle] | ||
// CHECK-LABEL: @get_len | ||
// CHECK: getelementptr inbounds | ||
// CHECK-NEXT: {{.*}}: | ||
// CHECK-NEXT: getelementptr inbounds | ||
// CHECK-NEXT: load | ||
// CHECK-NEXT: ret i64 | ||
// CHECK-NOT: switch | ||
pub fn get_len(arg: &K)->usize{ | ||
#[no_mangle] | ||
pub fn get_len(arg: &K) -> usize { | ||
match arg { | ||
K::A(ref lst)=>lst.len(), | ||
K::B(ref lst)=>lst.len(), | ||
K::C(ref lst)=>lst.len(), | ||
K::D(ref lst)=>lst.len(), | ||
K::A(ref lst) => lst.len(), | ||
K::B(ref lst) => lst.len(), | ||
K::C(ref lst) => lst.len(), | ||
K::D(ref lst) => lst.len(), | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,17 +1,12 @@ | ||
//@ compile-flags: -O | ||
//@ min-llvm-version: 17 | ||
#![crate_type = "lib"] | ||
|
||
// CHECK-LABEL: @write_u8_variant_a | ||
// CHECK: getelementptr | ||
// CHECK-NEXT: {{.*}}: | ||
// CHECK-NEXT: getelementptr | ||
// CHECK-NEXT: icmp ugt | ||
#[no_mangle] | ||
pub fn write_u8_variant_a( | ||
bytes: &mut [u8], | ||
buf: u8, | ||
offset: usize, | ||
) -> Option<&mut [u8]> { | ||
pub fn write_u8_variant_a(bytes: &mut [u8], buf: u8, offset: usize) -> Option<&mut [u8]> { | ||
let buf = buf.to_le_bytes(); | ||
bytes | ||
.get_mut(offset..).and_then(|bytes| bytes.get_mut(..buf.len())) | ||
bytes.get_mut(offset..).and_then(|bytes| bytes.get_mut(..buf.len())) | ||
} |
5 changes: 2 additions & 3 deletions
5
tests/codegen/issues/issue-113757-bounds-check-after-cmp-max.rs
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
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
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
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
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
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