From 456ceba13784f2f88f7f21239e308a0f195967a1 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 16 Nov 2016 17:33:23 -0500 Subject: [PATCH] fix `extern "aapcs" fn` 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 | 1 + src/librustc_trans/abi.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_llvm/ffi.rs b/src/librustc_llvm/ffi.rs index 8f21bf32c9e..2173adf2e6e 100644 --- a/src/librustc_llvm/ffi.rs +++ b/src/librustc_llvm/ffi.rs @@ -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, diff --git a/src/librustc_trans/abi.rs b/src/librustc_trans/abi.rs index f2e15a8973c..cb06fac2c67 100644 --- a/src/librustc_trans/abi.rs +++ b/src/librustc_trans/abi.rs @@ -274,10 +274,10 @@ impl FnType { 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[..];