]> git.lizzy.rs Git - rust.git/commitdiff
fix `extern "aapcs" fn`
authorJorge Aparicio <japaricious@gmail.com>
Wed, 16 Nov 2016 22:33:23 +0000 (17:33 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Wed, 16 Nov 2016 23:38:32 +0000 (18:38 -0500)
to actually use the AAPCS calling convention

closes #37810

This is technically a [breaking-change] because it changes the ABI of
`extern "aapcs"` functions that (a) involve `f32`/`f64` arguments/return
values and (b) are compiled for arm-eabihf targets from
"aapcs-vfp" (wrong) to "aapcs" (correct).

Appendix:

What these ABIs mean?

- In the "aapcs-vfp" ABI or "hard float" calling convention: Floating
point values are passed/returned through FPU registers (s0, s1, d0, etc.)

- Whereas, in the "aapcs" ABI or "soft float" calling convention:
Floating point values are passed/returned through general purpose
registers (r0, r1, etc.)

Mixing these ABIs can cause problems if the caller assumes that the
routine is using one of these ABIs but it's actually using the other
one.

src/librustc_llvm/ffi.rs
src/librustc_trans/abi.rs

index 8f21bf32c9e4d2949f647d9e0af64127ac6d2296..2173adf2e6e2d129e1df47f42cde20e2a437d7a1 100644 (file)
@@ -41,6 +41,7 @@ pub enum CallConv {
     ColdCallConv = 9,
     X86StdcallCallConv = 64,
     X86FastcallCallConv = 65,
+    ArmAapcsCallConv = 67,
     X86_64_SysV = 78,
     X86_64_Win64 = 79,
     X86_VectorCall = 80,
index f2e15a8973c910ca83eda7b7d4c1fcd09195b2c2..cb06fac2c674e22ca4c21c0f6007c2bb00398e51 100644 (file)
@@ -274,10 +274,10 @@ pub fn unadjusted<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
             C => llvm::CCallConv,
             Win64 => llvm::X86_64_Win64,
             SysV64 => llvm::X86_64_SysV,
+            Aapcs => llvm::ArmAapcsCallConv,
 
             // These API constants ought to be more specific...
             Cdecl => llvm::CCallConv,
-            Aapcs => llvm::CCallConv,
         };
 
         let mut inputs = &sig.inputs[..];