Uh oh!
There was an error while loading. Please reload this page.
llvm: Add support for vectorcall (X86_VectorCall) convention - #30567
Conversation
rust-highfive
commented
Dec 26, 2015
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nrc (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
nagisa
commented
Dec 27, 2015
This is probably most important for MSVC interfacing. |
nrc
commented
Dec 28, 2015
brson
commented
Dec 29, 2015
Are there specific APIs that need this? I do not like adding features just because they exist in LLVM. Let's not add calling conventions lightly. cc @rust-lang/lang |
nagisa
commented
Dec 29, 2015
There doesn’t seem to be many uses of this calling conventions in public APIs, but there’s some (e.g. skia) that use this CC for optimisation purposes. |
steffengy
commented
Dec 29, 2015
I only know of PHP 7 (which is with what I'm fiddling around currently). The general problem is that rust first doesn't support all of LLVMs I do not quite understand why @brson doesn't want (more) parity with LLVM here, |
retep998
commented
Dec 29, 2015
I think that Rust should support any calling convention that can be reasonably used from C code. Things like vectorcall can be used by C code quite easily (at least on Windows with msvc), and are likely to be part of the public interface of libraries. As such, Rust should be proactive in supporting these calling conventions when it knows they exist, rather than waiting for people to get fed up with maintaining custom builds of Rust. There are weird custom calling conventions for things like Haskell and stuff which can't really be used from C code and are unlikely to be in the public interface of a library. I recommend not supporting these, as there's very little reason to support them. |
nrc
commented
Dec 29, 2015
The reason (aiui) for not exposing everything llvm exposes is that we don't want to be tied to the llvm backend any more than we already are. We might want to support a C or gcc or custom backend in the future and every extra implementation detail we expose which ties us to llvm makes that harder. It seems reasonable to expose calling conventions which are supported by all major C compilers if there is a demand. I don't know if that is the case here. |
steffengy
commented
Dec 30, 2015
I indeed agree that exposing everything llvm exposes is a bad idea However I can't quite agree with
|
nrc
commented
Dec 30, 2015
cc @rust-lang/tools @steffengy these are good points. I'm not sure where we stand on platform-specific stuff. This probably needs some discussion some where (tools/lang/core teams). |
Gankra
commented
Dec 30, 2015
Reading the MSDN page linked and this one makes it fairly clear to me that this isn't an LLVM-ism at all, and should be safe/desirable to provide. |
brson
commented
Jan 6, 2016
Rust is its own language, not a high-level interface to LLVM. We've had many cases in the past where patches exposed LLVM functionality just because it was neat and we could. LLVM is a big backend. It does lots of stuff. The more we expose the harder it is to maintain, spec, and port to non-LLVM backends. |
steffengy
commented
Jan 6, 2016
@brson
https://software.intel.com/sites/default/files/Vectorcall_regcall_Demystified.pdf And since, as I already mentioned,
I really do not see any reason not to add support in this case. |
Gankra
commented
Jan 6, 2016
Ok so y'all are kinda talking past each other on the issue of specific vs general. Hashing it out on IRC, the ultimate issue here is: Who's going to use this? We don't like adding features that literally no one is going to use "because we can", because that leads to rot. @steffengy you seem to imply that you're interested in using this for some problem, but you haven't explicitly stated that. Are you? @retep998 are there any systems you maintain that will benefit from this? Are there public interfaces that require this (@nagisa couldn't find any)? The fact that "this exists and isn't tied to LLVM specifically" is an ok start, but if there isn't any strong motivating usecases today, it might make sense to hold off on this. |
retep998
commented
Jan 6, 2016
|
steffengy
commented
Jan 6, 2016
Yes I currently am (else this PR wouldn't exist)
Additionally I also found https://github.com/google/skia that seems to use it
That does apply generally, but I do not really think that applies here, |
ranma42
commented
Jan 6, 2016
Regarding maintenance, I was surprised to see no test case in this PR, but according to |
alexcrichton
commented
Jan 11, 2016
I personally very much agree with @brson's sentiments about not exposing everything LLVM does "just because", however I also agree with @gankro's assessment that this may not apply to this PR (e.g. it seems that vectorcall is both a prior name and has usage in other compilers). In terms of of a public API exposed by the compiler itself, there's a few facets:
@ranma42 no we don't auto-generate tests for things like this, but I would personally like to see at least one usage of this in a test regardless. Overall I would like to explore putting this ABI behind a feature gate, and then I would be quite comfortable landing it. |
retep998
commented
Jan 11, 2016
@alexcrichton The |
brson
commented
Jan 12, 2016
Perhaps you can say more about what you want to do with this calling convention. It still seems to me that there are not public APIs that require Rust to implement vectorcall for compatibility. So the only reason I see to implement it is that it offers a compelling performance improvement in some case. Even if that is true, it does not necessarily suggest to me that 'vectorcall' is the way for Rust to achieve the same thing. A performance win really needs to be big for us to add an entirely new calling convention. |
steffengy
commented
Jan 12, 2016
There probably some private API methods I'm using, but most actually are public, Source-Reference (limited to 2 results per file) Whether there's a huge performance win, I cannot say, but since the Intel performance |
alexcrichton
commented
Jan 12, 2016
@brson how do you feel about adding this behind a feature gate? @steffengy could you also add a positive test which uses the ABI? |
nikomatsakis
commented
Jan 13, 2016
@steffengy reading the PR, I had one question: from what I can tell, this ABI is specific to Windows? Do you know what LLVM will do on other platforms? I would think that we probably want to just error out on non-Windows targets. |
steffengy
commented
Jan 13, 2016
@nikomatsakis LLVM seems to work fine using vectorcall on other platforms, else the tests wouldnt pass. You're right though that vectorcall is used only by msvc at the moment. |
nikomatsakis
commented
Jan 15, 2016
What concerned me is more that LLVM may be doing some random thing that is neither well specified nor particularly portable. |
steffengy
commented
Jan 15, 2016
@nikomatsakis It's basically the same with Win64 at the moment (which rust supports), |
nikomatsakis
commented
Jan 15, 2016
To be clear, this is mostly a theoretical concern and I'm not overly worried. But just to spell it out. What I was worried about is that people call into some C library that is declared with this calling convention. Then we switch from LLVM to some other backend. And we find out that it's a pain to reproduce the precise behavior that LLVM had in this new backend, because it is linux specific and doesn't support this windows-specific calling convention. Basically, part of the argument for supporting a calling convention is that it is widespread on Win64, and hence whatever backend we choose will support it, which I think makes sense. But it's not true on linux, and hence by permitting it we are committing ourselves more to LLVM than we otherwise would. No? |
steffengy
commented
Jan 15, 2016
If somebody would use a linux library which would indeed use this calling convention, This problem exists for every windows-specific calling convention though So you are not really bound to LLVM, but to a backend which supports windows-specific calling conventions, if someone would for whatever reason would want to use this convention on a non windows target (atleast today thats highly unlikely) I also think it's more like a theoretical concern, which should not have any larger impact in the future. |
brson
commented
Jan 16, 2016
Thanks for the examples @steffengy. I reluctantly concede that it looks inevitable that we'll have to implement this. Go for it. |
alexcrichton
commented
Jan 16, 2016
bors
commented
Jan 16, 2016
⌛ Testing commit 4396a2d with merge 400bacf... |
bors
commented
Jan 16, 2016
💔 Test failed - auto-linux-64-nopt-t |
nagisa
commented
Jan 16, 2016
@bors retry |
Add support to use functions exported using vectorcall. This essentially only allows to pass a new LLVM calling convention from rust to LLVM. ```rust extern "vectorcall" fn abc(param: c_void); ``` references ---- http://llvm.org/docs/doxygen/html/CallingConv_8h_source.htmlhttps://msdn.microsoft.com/en-us/library/dn375768.aspx
bors
commented
Jan 16, 2016
bors
commented
Jan 17, 2016
💔 Test failed - auto-linux-64-nopt-t |
nagisa
commented
Jan 17, 2016
@bors retry |
retep998
commented
Jan 17, 2016
Wow, the linux version of rust is quite flaky with those spurious failures. |
bors
commented
Jan 17, 2016
⚡ Previous build results for auto-linux-32-nopt-t, auto-linux-32-opt, auto-linux-64-debug-opt, auto-linux-64-opt, auto-linux-cross-opt, auto-linux-musl-64-opt, auto-mac-32-opt, auto-mac-64-nopt-t, auto-mac-64-opt, auto-win-msvc-32-opt are reusable. Rebuilding only auto-linux-64-nopt-t, auto-linux-64-x-android-t, auto-win-gnu-32-nopt-t, auto-win-gnu-32-opt, auto-win-gnu-64-nopt-t, auto-win-gnu-64-opt, auto-win-msvc-64-opt... |
bors
commented
Jan 17, 2016
nikomatsakis
commented
Jan 17, 2016
Yes. I think we should consider generating an error (or at least a warning) for all such ABIs when they are used outside the target platform. I agree this is not specific to vectorcall (nor to Windows; I'm sure there are linux-specific conventions out there) and didn't mean to imply otherwise. But, as you say, I'm not too worried about this being a big problem in practice. I'll just let it go. :) |
…, r=ehuss Add tracking issue and unstable book page for `"vectorcall"` ABI Originally added in 2015 by rust-lang#30567, the Windows `"vectorcall"` ABI didn't have a tracking issue until now. Tracking issue: rust-lang#124485
…, r=ehuss Add tracking issue and unstable book page for `"vectorcall"` ABI Originally added in 2015 by rust-lang#30567, the Windows `"vectorcall"` ABI didn't have a tracking issue until now. Tracking issue: rust-lang#124485
…, r=ehuss Add tracking issue and unstable book page for `"vectorcall"` ABI Originally added in 2015 by rust-lang#30567, the Windows `"vectorcall"` ABI didn't have a tracking issue until now. Tracking issue: rust-lang#124485
…, r=ehuss Add tracking issue and unstable book page for `"vectorcall"` ABI Originally added in 2015 by rust-lang#30567, the Windows `"vectorcall"` ABI didn't have a tracking issue until now. Tracking issue: rust-lang#124485
…, r=ehuss Add tracking issue and unstable book page for `"vectorcall"` ABI Originally added in 2015 by rust-lang#30567, the Windows `"vectorcall"` ABI didn't have a tracking issue until now. Tracking issue: rust-lang#124485
Rollup merge of rust-lang#124486 - beetrees:vectorcall-tracking-issue, r=ehuss Add tracking issue and unstable book page for `"vectorcall"` ABI Originally added in 2015 by rust-lang#30567, the Windows `"vectorcall"` ABI didn't have a tracking issue until now. Tracking issue: rust-lang#124485
Add support to use functions exported using vectorcall.
This essentially only allows to pass a new LLVM calling convention
from rust to LLVM.
references
http://llvm.org/docs/doxygen/html/CallingConv_8h_source.html
https://msdn.microsoft.com/en-us/library/dn375768.aspx