[PATCH] D89400: [SimplifyLibCalls] Keep calling convention when simplifying to libcall

John Brawn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 15 06:55:26 PDT 2020


john.brawn added a comment.

Clang treats C library calls the same as any other function calls when it comes to the calling convention, so they get a non-C calling convention in the same circumstances that other functions do.

Looking at the ARM target in specific, a function gets a non-C calling convention when CodeGenModule::getTargetCodeGenInfo sets a calling convention (based on target triple and CodeGenOpts.FloatABI) that's different to what ARMABIInfo::getLLVMDefaultCC (which is based solely on the target triple) returns. So if you're using -mtriple=arm-none-eabi -mfloat-abi=hard then functions get the arm_aapcs_vfpcc calling convention, and if you're using -mtriple=arm-none-eabihf -mfloat-abi=soft then functions get the arm_aapcscc calling convention.

Looking at the backend it's ARMTargetLowering::getEffectiveCallingConv that determines the effective calling convention for functions with the C calling convention, which it does based on getTargetMachine().Options.FloatABIType which by default is derived from the target triple.

So if we wanted clang to use the C calling convention always for C library calls we would need to either:

- Add special handling to make sure C library calls only get the C calling convention and add some mechanism to signal to the backend what the actual calling convention is.
- Remove the behaviour that the calling-convention is non-C when there's a mismatch between the triple and the float-abi and do something different to make sure we end up with the right calling convention in the end (maybe have -mfloat-abi implicitly modify the triple like -march and -mcpu do).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89400/new/

https://reviews.llvm.org/D89400



More information about the llvm-commits mailing list