-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also use
mir::Offset
for pointer add
- Loading branch information
Showing
11 changed files
with
117 additions
and
77 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
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,34 @@ | ||
// compile-flags: -O -C no-prepopulate-passes | ||
// min-llvm-version: 15.0 (because we're using opaque pointers) | ||
|
||
#![crate_type = "lib"] | ||
#![feature(core_intrinsics)] | ||
|
||
use std::intrinsics::offset; | ||
|
||
// CHECK-LABEL: ptr @offset_zst | ||
// CHECK-SAME: (ptr noundef %p, [[SIZE:i[0-9]+]] noundef %d) | ||
#[no_mangle] | ||
pub unsafe fn offset_zst(p: *const (), d: usize) -> *const () { | ||
// CHECK-NOT: getelementptr | ||
// CHECK: ret ptr %p | ||
offset(p, d) | ||
} | ||
|
||
// CHECK-LABEL: ptr @offset_isize | ||
// CHECK-SAME: (ptr noundef %p, [[SIZE]] noundef %d) | ||
#[no_mangle] | ||
pub unsafe fn offset_isize(p: *const u32, d: isize) -> *const u32 { | ||
// CHECK: %[[R:.*]] = getelementptr inbounds i32, ptr %p, [[SIZE]] %d | ||
// CHECK-NEXT: ret ptr %[[R]] | ||
offset(p, d) | ||
} | ||
|
||
// CHECK-LABEL: ptr @offset_usize | ||
// CHECK-SAME: (ptr noundef %p, [[SIZE]] noundef %d) | ||
#[no_mangle] | ||
pub unsafe fn offset_usize(p: *const u64, d: usize) -> *const u64 { | ||
// CHECK: %[[R:.*]] = getelementptr inbounds i64, ptr %p, [[SIZE]] %d | ||
// CHECK-NEXT: ret ptr %[[R]] | ||
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
Oops, something went wrong.