Page MenuHomePhabricator

[Driver] Incorporate -mfloat-abi in the computed triple on ARM

Authored by john.brawn on Oct 16 2020, 11:14 AM.



LLVM assumes that when it creates a call to a C library function it can use the C calling convention. On ARM the effective calling convention is determined from the target triple, however using -mfloat-abi=hard on ARM means that calls to (and definitions of) C library functions use the arm_aapcs_vfpcc calling convention which can result in a mismatch.

Fix this by incorporating -mfloat-abi into the target triple, similar to how -mbig-endian and -march/-mcpu are. This only works for EABI targets and not Android or iOS, but there the float abi is fixed so instead give an error.

Fixes PR45524.

Diff Detail

Unit TestsFailed

220 mswindows >
Script: -- : 'RUN: at line 7'; sed -e "s,SRC_COMPDIR,/Inputs,g" C:\ws\w32-1\llvm-project\premerge-checks\llvm\test\tools\llvm-objdump\X86/Inputs/source-interleave.ll > C:\ws\w32-1\llvm-project\premerge-checks\build\test\tools\llvm-objdump\X86\Output\source-interleave-prefix-windows.test.tmp.ll
240 mswindows >
Script: -- : 'RUN: at line 5'; sed -e "s,SRC_COMPDIR,./Inputs,g" C:\ws\w32-1\llvm-project\premerge-checks\llvm\test\tools\llvm-objdump\X86/Inputs/source-interleave.ll > C:\ws\w32-1\llvm-project\premerge-checks\build\test\tools\llvm-objdump\X86\Output\source-interleave-prefix.test.tmp-relative-path.ll

Event Timeline

john.brawn created this revision.Oct 16 2020, 11:14 AM
efriedma added inline comments.Oct 16 2020, 2:07 PM

Do we want to error in the "default" case? Not that anyone is likely to use -mfloat-abi on those targets, but I'd prefer not to silently miscompile.

john.brawn edited the summary of this revision. (Show Details)

Adjusted to give an error when the specified float abi is incompatible with the default. Was a bit trickier than I expected as it required extracting out the logic to determine the default into a separate function (we could instead emit the error in arm::getARMFloatABI but then it would be emitted several times as the function is called from several places).

This revision is now accepted and ready to land.Oct 20 2020, 1:56 PM