Skip to content

Commit 430feb2

Browse files
committed
Auto merge of #78253 - Aaron1011:bump-llvm-deadarg, r=cuviper
Bump LLVM for DeadArgElim fix Fixes #76387 Pulls in rust-lang/llvm-project#82
2 parents f392479 + d3369e6 commit 430feb2

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

src/test/ui/auxiliary/issue-76387.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// compile-flags: -C opt-level=3
2+
3+
pub struct FatPtr {
4+
ptr: *mut u8,
5+
len: usize,
6+
}
7+
8+
impl FatPtr {
9+
pub fn new(len: usize) -> FatPtr {
10+
let ptr = Box::into_raw(vec![42u8; len].into_boxed_slice()) as *mut u8;
11+
12+
FatPtr { ptr, len }
13+
}
14+
}
15+
16+
impl std::ops::Deref for FatPtr {
17+
type Target = [u8];
18+
19+
#[inline]
20+
fn deref(&self) -> &[u8] {
21+
unsafe { std::slice::from_raw_parts(self.ptr, self.len) }
22+
}
23+
}
24+
25+
impl std::ops::Drop for FatPtr {
26+
fn drop(&mut self) {
27+
println!("Drop");
28+
}
29+
}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// no-system-llvm
2+
// compile-flags: -C opt-level=3
3+
// aux-build: issue-76387.rs
4+
// run-pass
5+
6+
// Regression test for issue #76387
7+
// Tests that LLVM doesn't miscompile this
8+
9+
extern crate issue_76387;
10+
11+
use issue_76387::FatPtr;
12+
13+
fn print(data: &[u8]) {
14+
println!("{:#?}", data);
15+
}
16+
17+
fn main() {
18+
let ptr = FatPtr::new(20);
19+
let data = unsafe { std::slice::from_raw_parts(ptr.as_ptr(), ptr.len()) };
20+
21+
print(data);
22+
}

0 commit comments

Comments
 (0)