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.
Auto merge of rust-lang#122325 - erikdesjardins:array, r=<try>
Stop using LLVM struct types for array/pointer offset GEPs ...and just use a byte array with the same size as the element type instead. This avoids depending on LLVM's struct layout to determine the size of the array/pointer element. Spiritually split out from rust-lang#121577. r? `@nikic`
- Loading branch information
Showing
9 changed files
with
58 additions
and
19 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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//@ compile-flags: -O | ||
|
||
#![crate_type = "lib"] | ||
#![feature(core_intrinsics)] | ||
|
||
use std::intrinsics::arith_offset; | ||
|
||
// CHECK-LABEL: ptr @arith_offset_zst | ||
// CHECK-SAME: (ptr noundef{{.*}} %p, [[SIZE:i[0-9]+]] noundef %d) | ||
#[no_mangle] | ||
pub unsafe fn arith_offset_zst(p: *const (), d: isize) -> *const () { | ||
// CHECK-NOT: getelementptr | ||
// CHECK: ret ptr %p | ||
arith_offset(p, d) | ||
} | ||
|
||
// CHECK-LABEL: ptr @arith_offset_u32 | ||
// CHECK-SAME: (ptr noundef{{.*}} %p, [[SIZE]] noundef %d) | ||
#[no_mangle] | ||
pub unsafe fn arith_offset_u32(p: *const u32, d: isize) -> *const u32 { | ||
// CHECK: %[[R:.*]] = getelementptr [4 x i8], ptr %p, [[SIZE]] %d | ||
// CHECK-NEXT: ret ptr %[[R]] | ||
arith_offset(p, d) | ||
} | ||
|
||
// CHECK-LABEL: ptr @arith_offset_u64 | ||
// CHECK-SAME: (ptr noundef{{.*}} %p, [[SIZE]] noundef %d) | ||
#[no_mangle] | ||
pub unsafe fn arith_offset_u64(p: *const u64, d: isize) -> *const u64 { | ||
// CHECK: %[[R:.*]] = getelementptr [8 x i8], ptr %p, [[SIZE]] %d | ||
// CHECK-NEXT: ret ptr %[[R]] | ||
arith_offset(p, d) | ||
} |
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