-
Notifications
You must be signed in to change notification settings - Fork 13k
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
ABI for float builtins depends on target features #112885
Comments
I would argue this is a per-call-site decision, see also #70563. IIUC, the most problematic situation here is code that is generally built for i386 without any SSE support, but then has some fast-paths for when SSE2 is available. That code will presumably be linked with a compiler_rt built without SSE support, but float operations inside the functions that have SSE2 enabled will expect the callee to use the SSE register. If |
@RalfJung For calls to builtins, there is usually no |
Isn't that happening on some different IR? I'm not familiar with the lower ends of LLVM -- I heard there's Machine IR there. If this is never in any IR it should be easier -- the legalization "just" has to pass through the information which ABI to use, to make it clear that this should not be adjusted to whatever the target features of the current function are. (I'm sure it's not actually easy, the devil is always in the details.) |
The legalization call will be inserted in SelectionDAG or gMIR |
For reference both gcc and clang just reject |
Both GCC and Clang support |
When LLVM needs to call a builtin (such as
__truncdfhf2
or__addtf3
), it will use whatever ABI is the default for the target features of the function that is currently being compiled. This means that on targets where the ABI of float types is target-feature dependant (e.g. the ABI ofhalf
changes of 32-bit x86 depending on whethersse2
is enabled, and the ABI offp128
changes on PowerPC depending on whethervsx
is enabled), LLVM will call the same builtin function using two different incompatible ABIs.The simplest solution to this seems to be extending the
target-abi
module flag to allow frontends to specify which float ABI gets used for function calls independent of the target features of a function. Other solutions include allowing the frontend to override the names of builtin functions on a per-function-being-compiled level.Related Rust issues: rust-lang/rust#131819, rust-lang/rust#125109
The text was updated successfully, but these errors were encountered: