Skip to content

Commit

Permalink
fix extern "aapcs" fn
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jorge Aparicio committed Nov 16, 2016
1 parent 9d4b6fa commit 456ceba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/librustc_llvm/ffi.rs
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/abi.rs
Expand Up @@ -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[..];
Expand Down

0 comments on commit 456ceba

Please sign in to comment.