diff options
| author | bors <bors@rust-lang.org> | 2024-07-12 20:36:43 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-07-12 20:36:43 +0000 |
| commit | c6727fc9b5c64cefa7263486497ee95e529bd0f8 (patch) | |
| tree | 97a13f2f6b89c85feb20239b77a14958fea7083c /tests/codegen/issues/issue-32031.rs | |
| parent | 62c068feeafd1f4abbf87243d69cf8862e4dd277 (diff) | |
| parent | cae9d480bfe930a678fe2744082fc6ef1d957f63 (diff) | |
| download | rust-c6727fc9b5c64cefa7263486497ee95e529bd0f8.tar.gz rust-c6727fc9b5c64cefa7263486497ee95e529bd0f8.zip | |
Auto merge of #123351 - beetrees:x86-ret-snan-rust, r=nikic,workingjubilee
Ensure floats are returned losslessly by the Rust ABI on 32-bit x86 Solves #115567 for the (default) `"Rust"` ABI. When compiling for 32-bit x86, this PR changes the `"Rust"` ABI to return floats indirectly instead of in x87 registers (with the exception of single `f32`s, which this PR returns in general purpose registers as they are small enough to fit in one). No change is made to the `"C"` ABI as that ABI requires x87 register usage and therefore will need a different solution.
Diffstat (limited to 'tests/codegen/issues/issue-32031.rs')
| -rw-r--r-- | tests/codegen/issues/issue-32031.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/codegen/issues/issue-32031.rs b/tests/codegen/issues/issue-32031.rs index 9693c414a67..4d6895166f1 100644 --- a/tests/codegen/issues/issue-32031.rs +++ b/tests/codegen/issues/issue-32031.rs @@ -1,11 +1,16 @@ //@ compile-flags: -C no-prepopulate-passes -Copt-level=0 +// 32-bit x86 returns `f32` and `f64` differently to avoid the x87 stack. +//@ revisions: x86 other +//@[x86] only-x86 +//@[other] ignore-x86 #![crate_type = "lib"] #[no_mangle] pub struct F32(f32); -// CHECK: define{{.*}}float @add_newtype_f32(float %a, float %b) +// other: define{{.*}}float @add_newtype_f32(float %a, float %b) +// x86: define{{.*}}i32 @add_newtype_f32(float %a, float %b) #[inline(never)] #[no_mangle] pub fn add_newtype_f32(a: F32, b: F32) -> F32 { @@ -15,7 +20,8 @@ pub fn add_newtype_f32(a: F32, b: F32) -> F32 { #[no_mangle] pub struct F64(f64); -// CHECK: define{{.*}}double @add_newtype_f64(double %a, double %b) +// other: define{{.*}}double @add_newtype_f64(double %a, double %b) +// x86: define{{.*}}void @add_newtype_f64(ptr{{.*}}sret([8 x i8]){{.*}}%_0, double %a, double %b) #[inline(never)] #[no_mangle] pub fn add_newtype_f64(a: F64, b: F64) -> F64 { |
