-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure floats are returned losslessly by the Rust ABI on 32-bit x86 #123351
Conversation
rustbot has assigned @compiler-errors. Use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes lgtm, but I'm not an ABI expert
so let's get another look at it r? compiler |
Not an ABI expert either r? compiler |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me, too. I'm also not an expert on this matter ^^'.
@RalfJung, could you help us out?
c413b2f
to
c42c4b5
Compare
I've added a commit to update |
My name appears in these issues as I gained just enough knowledge to identify that we have a problem, but I don't feel confident to approve any changes to our ABI, sorry. With my limited knowledge however, this change does make a lot of sense. And it's a lot simpler than what I thought was necessary to do this. Very nice! So... who is an ABI expert? @bjorn3, @nikic and @eddyb are the first people coming to my mind. (Maybe we should have some sort of dedicated ABI expert ping group. It would be really good to have some people in charge of ABI-related questions.) |
c42c4b5
to
852ffd3
Compare
I guess it can be left for a followup, but if SSE2 is available, I think |
@programmerjake See #115919 - currently blocked on #116584. I agree it would be a good future improvement once the target feature issues have been sorted out. |
I don't have time to review this for the next two weeks at least unfortunately. |
No worries. I'll try someone else. r? @nikic |
…workingjubilee Ensure floats are returned losslessly by the Rust ABI on 32-bit x86 Solves rust-lang#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.
💔 Test failed - checks-actions |
Error appears to be spurious. |
@bors r=nikic,workingjubilee |
💡 This pull request was already approved, no need to approve it again.
|
☀️ Test successful - checks-actions |
Finished benchmarking commit (c6727fc): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 703.434s -> 705.609s (0.31%) |
Update Rust toolchain from nightly-2024-07-12 to nightly-2024-07-13 without any other source changes. This is an automatically generated pull request. If any of the CI checks fail, manual intervention is required. In such a case, review the changes at https://github.com/rust-lang/rust from rust-lang@5315cbe up to rust-lang@c6727fc. The log for this commit range is: rust-lang@c6727fc9b5 Auto merge of rust-lang#123351 - beetrees:x86-ret-snan-rust, r=nikic,workingjubilee rust-lang@62c068feea Auto merge of rust-lang#127636 - nnethercote:fix-Parser-look_ahead, r=oli-obk rust-lang@5d76a13bbe Auto merge of rust-lang#127653 - matthiaskrgr:rollup-72bqgvp, r=matthiaskrgr rust-lang@f11c2c8e95 Rollup merge of rust-lang#127648 - Kobzol:ci-lower-timeout, r=pietroalbini rust-lang@526da2366a Rollup merge of rust-lang#127627 - lcnr:rustc_search_graph, r=compiler-errors rust-lang@f5fa6fb602 Rollup merge of rust-lang#127613 - nikic:riscv-update, r=cuviper rust-lang@b4f002d2e5 Rollup merge of rust-lang#127552 - onur-ozkan:unnecessary-git-usage, r=Kobzol rust-lang@8ceb4e49ff Rollup merge of rust-lang#127433 - dtolnay:conststrlen, r=workingjubilee rust-lang@f9b3e8b387 Rollup merge of rust-lang#126827 - the8472:pidfd-spawn, r=workingjubilee rust-lang@18152d72a4 Rollup merge of rust-lang#126639 - sayantn:amx, r=Amanieu rust-lang@65ea92d4a1 Rollup merge of rust-lang#124980 - zachs18:rc-allocator, r=Amanieu rust-lang@05eac57ef6 Auto merge of rust-lang#127479 - Urgau:rustc-stable-hash, r=michaelwoerister rust-lang@15f770b143 enable fuzzing of `SearchGraph` rust-lang@cae9d480bf Adjust tests for x86 "Rust" ABI changes rust-lang@3f4b9dd463 Lower timeout of CI jobs to 4 hours rust-lang@7f1518bddd Add instability attribute on private const_strlen function rust-lang@b286722878 Auto merge of rust-lang#127635 - matthiaskrgr:rollup-foopajr, r=matthiaskrgr rust-lang@100f3fd133 Add a new special case to `Parser::look_ahead`. rust-lang@ebe1305b1e Remove the bogus special case from `Parser::look_ahead`. rust-lang@dad95578b0 Add unit tests for `Parser::look_ahead`. rust-lang@ec05c4ea3f Add the feature gate and target-features rust-lang@c2b7842555 Rollup merge of rust-lang#127625 - SkiFire13:revert-comment-deletion, r=workingjubilee rust-lang@ca576eae4e Rollup merge of rust-lang#127622 - compiler-errors:builtin-internal, r=lqd rust-lang@fe564c10ab Rollup merge of rust-lang#127607 - Zalathar:normalize-hint, r=wesleywiser rust-lang@83d1a1b252 Rollup merge of rust-lang#127596 - tesuji:help-unwrap-or, r=compiler-errors rust-lang@1e7ad4c3ed Rollup merge of rust-lang#127422 - greaka:master, r=workingjubilee rust-lang@58fe37f2c3 Rollup merge of rust-lang#127164 - Nadrieril:clean-lowering-loop, r=matthewjasper rust-lang@4a31a6c32a Auto merge of rust-lang#127382 - estebank:const-let, r=compiler-errors rust-lang@5e311f933d Auto merge of rust-lang#127614 - matthiaskrgr:rollup-8geziwi, r=matthiaskrgr rust-lang@a776e5f922 Add doc for deconstruct_option_or_result rust-lang@872d7b82e1 Add suggestion for `Option<&Vec<T>> -> Option<&[T]` rust-lang@d9170dc666 Add regression test for issue 127545 rust-lang@4df75140dd Fix aarch64 test rust-lang@cbe75486f7 Account for `let foo = expr`; to suggest `const foo: Ty = expr;` rust-lang@b56dc8ee90 Use verbose style when suggesting changing `const` with `let` rust-lang@d9021791eb Revert accidental comment deletion rust-lang@b77d3ef7c4 Mark builtin syntax as internal rust-lang@fa3ce50f0b Rollup merge of rust-lang#127605 - nikic:remove-extern-wasm, r=oli-obk rust-lang@d433f176ef Rollup merge of rust-lang#127601 - trevyn:issue-127600, r=compiler-errors rust-lang@47ab86653e Rollup merge of rust-lang#127599 - tgross35:lazy_cell_consume-rename, r=workingjubilee rust-lang@a10b4d1463 Rollup merge of rust-lang#127598 - weiznich:diagnostic_do_not_recommend_also_skips_help, r=compiler-errors rust-lang@73c500b3a7 Rollup merge of rust-lang#127591 - compiler-errors:label-after-primary, r=lcnr rust-lang@380c78741e Rollup merge of rust-lang#127588 - uweigand:s390x-f16-doctests, r=tgross35 rust-lang@6fd955549a Rollup merge of rust-lang#127572 - tbu-:pr_debug_event_nonpacked, r=jhpratt rust-lang@8de487fdbd Rollup merge of rust-lang#124599 - estebank:issue-41708, r=wesleywiser rust-lang@55256c5a18 Update dist-riscv64-linux to binutils 2.40 rust-lang@977439d9b8 Use uplifted `rustc-stable-hash` crate in `rustc_data_structures` rust-lang@f56b2074c6 solve -> solve/mod rust-lang@08a2992d6b compiletest: Better error message for bad `normalize-*` headers rust-lang@8a50bcbdce Remove extern "wasm" ABI rust-lang@a01f49e7f3 check is_ident before parse_ident rust-lang@ab56fe2053 Rename `lazy_cell_consume` to `lazy_cell_into_inner` rust-lang@27d5db166e Allows `#[diagnostic::do_not_recommend]` to supress trait impls in suggestions as well rust-lang@12ae282987 Fix diagnostic and add a test for it rust-lang@df72e478b0 Make sure that labels are defined after the primary span in diagnostics rust-lang@0065763950 core: Limit remaining f16 doctests to x86_64 linux rust-lang@45ad522e87 Don't mark `DEBUG_EVENT` struct as `repr(packed)` rust-lang@0134bd2e67 remove unnecessary `git` usages rust-lang@42772e98e0 Address review comments rust-lang@3e030b38ef Return the `otherwise_block` instead of passing it as argument rust-lang@fc40247c6b Factor out the "process remaining candidates" cases rust-lang@8a222ffd6b Don't try to save an extra block rust-lang@c5062f7318 Move or-pattern expansion inside the main part of the algorithm rust-lang@bff4d213fa Factor out the special handling of or-patterns rust-lang@5bf50e66f9 Move a function rust-lang@53d3e6217b Stabilize const_cstr_from_ptr (CStr::from_ptr, CStr::count_bytes) rust-lang@585ca16e0b as_simd: fix comment to be in line with 507583a (rust-lang#121201) rust-lang@0f643c449a Ensure tests don't fail on i586 in CI rust-lang@ec0c755704 Check that we get somewhat sane PIDs when spawning with pidfds rust-lang@3e4e31b7bf more fine-grained feature-detection for pidfd spawning rust-lang@0ce361938e document safety properties of the internal Process::new constructor rust-lang@6687a3f7da use pidfd_spawn for faster process creation when pidfds are requested rust-lang@5c46acac04 document the cvt methods rust-lang@0e1c832dbd Update `platform-support.md` to reflect improvements in returning floats on 32-bit x86 rust-lang@952becc0bd Ensure floats are returned losslessly by the Rust ABI on 32-bit x86 rust-lang@a1ad6346d6 Add fn allocator method to rc/sync::Weak. Relax Rc<T>/Arc<T>::allocator to allow unsized T. rust-lang@2df4f7dd8c Suggest borrowing on fn argument that is `impl AsRef` Co-authored-by: celinval <35149715+celinval@users.noreply.github.com>
…ilee enable const-float-classify test, and test_next_up/down on 32bit x86 The test_next_up/down tests have been disabled on all 32bit x86 targets, which goes too far -- they should definitely work on our (tier 1) i686 target, it is only without SSE that we might run into trouble due to rust-lang#114479. However, I cannot reproduce that trouble any more -- maybe that got fixed by rust-lang#123351? The const-float-classify test relied on const traits "because we can", and got disabled when const traits got removed. That's an unfortunate reduction in test coverage of our float functionality, so let's restore the test in a way that does not rely on const traits. The const-float tests are actually testing runtime behavior as well, and I don't think that runtime behavior is covered anywhere else. Probably they shouldn't be called "const-float", but we don't have a `tests/ui/float` folder... should I create one and move them there? Are there any other ui tests that should be moved there? I also removed some FIXME referring to not use x87 for Rust-to-Rust-calls -- that has happened in rust-lang#123351 so this got fixed indeed. Does that mean we can simplify all that float code again? I am not sure how to test it. Is running the test suite with an i586 target enough? Cc `@tgross35` `@workingjubilee`
…ilee enable const-float-classify test, and test_next_up/down on 32bit x86 The test_next_up/down tests have been disabled on all 32bit x86 targets, which goes too far -- they should definitely work on our (tier 1) i686 target, it is only without SSE that we might run into trouble due to rust-lang#114479. However, I cannot reproduce that trouble any more -- maybe that got fixed by rust-lang#123351? The const-float-classify test relied on const traits "because we can", and got disabled when const traits got removed. That's an unfortunate reduction in test coverage of our float functionality, so let's restore the test in a way that does not rely on const traits. The const-float tests are actually testing runtime behavior as well, and I don't think that runtime behavior is covered anywhere else. Probably they shouldn't be called "const-float", but we don't have a `tests/ui/float` folder... should I create one and move them there? Are there any other ui tests that should be moved there? I also removed some FIXME referring to not use x87 for Rust-to-Rust-calls -- that has happened in rust-lang#123351 so this got fixed indeed. Does that mean we can simplify all that float code again? I am not sure how to test it. Is running the test suite with an i586 target enough? Cc `@tgross35` `@workingjubilee`
…ilee enable const-float-classify test, and test_next_up/down on 32bit x86 The test_next_up/down tests have been disabled on all 32bit x86 targets, which goes too far -- they should definitely work on our (tier 1) i686 target, it is only without SSE that we might run into trouble due to rust-lang#114479. However, I cannot reproduce that trouble any more -- maybe that got fixed by rust-lang#123351? The const-float-classify test relied on const traits "because we can", and got disabled when const traits got removed. That's an unfortunate reduction in test coverage of our float functionality, so let's restore the test in a way that does not rely on const traits. The const-float tests are actually testing runtime behavior as well, and I don't think that runtime behavior is covered anywhere else. Probably they shouldn't be called "const-float", but we don't have a `tests/ui/float` folder... should I create one and move them there? Are there any other ui tests that should be moved there? I also removed some FIXME referring to not use x87 for Rust-to-Rust-calls -- that has happened in rust-lang#123351 so this got fixed indeed. Does that mean we can simplify all that float code again? I am not sure how to test it. Is running the test suite with an i586 target enough? Cc ``@tgross35`` ``@workingjubilee``
…ilee enable const-float-classify test, and test_next_up/down on 32bit x86 The test_next_up/down tests have been disabled on all 32bit x86 targets, which goes too far -- they should definitely work on our (tier 1) i686 target, it is only without SSE that we might run into trouble due to rust-lang#114479. However, I cannot reproduce that trouble any more -- maybe that got fixed by rust-lang#123351? The const-float-classify test relied on const traits "because we can", and got disabled when const traits got removed. That's an unfortunate reduction in test coverage of our float functionality, so let's restore the test in a way that does not rely on const traits. The const-float tests are actually testing runtime behavior as well, and I don't think that runtime behavior is covered anywhere else. Probably they shouldn't be called "const-float", but we don't have a `tests/ui/float` folder... should I create one and move them there? Are there any other ui tests that should be moved there? I also removed some FIXME referring to not use x87 for Rust-to-Rust-calls -- that has happened in rust-lang#123351 so this got fixed indeed. Does that mean we can simplify all that float code again? I am not sure how to test it. Is running the test suite with an i586 target enough? Cc ```@tgross35``` ```@workingjubilee```
Rollup merge of rust-lang#129835 - RalfJung:float-tests, r=workingjubilee enable const-float-classify test, and test_next_up/down on 32bit x86 The test_next_up/down tests have been disabled on all 32bit x86 targets, which goes too far -- they should definitely work on our (tier 1) i686 target, it is only without SSE that we might run into trouble due to rust-lang#114479. However, I cannot reproduce that trouble any more -- maybe that got fixed by rust-lang#123351? The const-float-classify test relied on const traits "because we can", and got disabled when const traits got removed. That's an unfortunate reduction in test coverage of our float functionality, so let's restore the test in a way that does not rely on const traits. The const-float tests are actually testing runtime behavior as well, and I don't think that runtime behavior is covered anywhere else. Probably they shouldn't be called "const-float", but we don't have a `tests/ui/float` folder... should I create one and move them there? Are there any other ui tests that should be moved there? I also removed some FIXME referring to not use x87 for Rust-to-Rust-calls -- that has happened in rust-lang#123351 so this got fixed indeed. Does that mean we can simplify all that float code again? I am not sure how to test it. Is running the test suite with an i586 target enough? Cc ```@tgross35``` ```@workingjubilee```
enable const-float-classify test, and test_next_up/down on 32bit x86 The test_next_up/down tests have been disabled on all 32bit x86 targets, which goes too far -- they should definitely work on our (tier 1) i686 target, it is only without SSE that we might run into trouble due to rust-lang/rust#114479. However, I cannot reproduce that trouble any more -- maybe that got fixed by rust-lang/rust#123351? The const-float-classify test relied on const traits "because we can", and got disabled when const traits got removed. That's an unfortunate reduction in test coverage of our float functionality, so let's restore the test in a way that does not rely on const traits. The const-float tests are actually testing runtime behavior as well, and I don't think that runtime behavior is covered anywhere else. Probably they shouldn't be called "const-float", but we don't have a `tests/ui/float` folder... should I create one and move them there? Are there any other ui tests that should be moved there? I also removed some FIXME referring to not use x87 for Rust-to-Rust-calls -- that has happened in #123351 so this got fixed indeed. Does that mean we can simplify all that float code again? I am not sure how to test it. Is running the test suite with an i586 target enough? Cc ```@tgross35``` ```@workingjubilee```
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 singlef32
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.