-
Notifications
You must be signed in to change notification settings - Fork 13.4k
use indirect return for i128
and f128
on wasm32
#135534
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,49 @@ | ||
//! Verify that Rust implements the expected calling convention for `f128` | ||
|
||
//@ add-core-stubs | ||
//@ compile-flags: -O --target wasm32-wasip1 | ||
//@ needs-llvm-components: webassembly | ||
|
||
#![crate_type = "lib"] | ||
#![no_std] | ||
#![no_core] | ||
#![feature(no_core, lang_items, f128)] | ||
|
||
extern crate minicore; | ||
|
||
extern "C" { | ||
fn extern_call(arg0: f128); | ||
fn extern_ret() -> f128; | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn pass(_arg0: u32, arg1: f128) { | ||
// CHECK-LABEL: @pass( | ||
// an f128 is passed via registers | ||
// CHECK-SAME: fp128 noundef %arg1 | ||
// CHECK: call void @extern_call | ||
unsafe { extern_call(arg1) }; | ||
} | ||
|
||
// Check that we produce the correct return ABI | ||
#[no_mangle] | ||
pub extern "C" fn ret(_arg0: u32, arg1: f128) -> f128 { | ||
// CHECK-LABEL: @ret( | ||
// but an f128 is returned via the stack | ||
// CHECK-SAME: sret | ||
// CHECK: store fp128 %arg1 | ||
// CHECK-NEXT: ret void | ||
arg1 | ||
} | ||
|
||
// Check that we consume the correct return ABI | ||
#[no_mangle] | ||
pub extern "C" fn forward(dst: *mut f128) { | ||
// CHECK-LABEL: @forward | ||
// CHECK-SAME: ptr{{.*}} %dst) | ||
// without optimizatons, an intermediate alloca is used | ||
// CHECK: call void @extern_ret | ||
// CHECK: store fp128 | ||
// CHECK: ret void | ||
unsafe { *dst = extern_ret() }; | ||
} |
This file contains hidden or 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,49 @@ | ||
//! Verify that Rust implements the expected calling convention for `i128`/`u128`. | ||
|
||
//@ add-core-stubs | ||
//@ compile-flags: -O --target wasm32-wasip1 | ||
//@ needs-llvm-components: webassembly | ||
|
||
#![crate_type = "lib"] | ||
#![no_std] | ||
#![no_core] | ||
#![feature(no_core, lang_items)] | ||
|
||
extern crate minicore; | ||
|
||
extern "C" { | ||
fn extern_call(arg0: i128); | ||
fn extern_ret() -> i128; | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn pass(_arg0: u32, arg1: i128) { | ||
// CHECK-LABEL: @pass( | ||
// an i128 is passed via registers | ||
// CHECK-SAME: i128 noundef %arg1 | ||
// CHECK: call void @extern_call | ||
unsafe { extern_call(arg1) }; | ||
} | ||
|
||
// Check that we produce the correct return ABI | ||
#[no_mangle] | ||
pub extern "C" fn ret(_arg0: u32, arg1: i128) -> i128 { | ||
// CHECK-LABEL: @ret( | ||
// but an i128 is returned via the stack | ||
// CHECK-SAME: sret | ||
// CHECK: store i128 %arg1 | ||
// CHECK-NEXT: ret void | ||
arg1 | ||
} | ||
|
||
// Check that we consume the correct return ABI | ||
#[no_mangle] | ||
pub extern "C" fn forward(dst: *mut i128) { | ||
// CHECK-LABEL: @forward | ||
// CHECK-SAME: ptr{{.*}} %dst) | ||
// without optimizatons, an intermediate alloca is used | ||
// CHECK: call void @extern_ret | ||
// CHECK: store i128 | ||
// CHECK: ret void | ||
unsafe { *dst = extern_ret() }; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.