[cfe-dev] Bugfixer's question about how C calling convention corresponds to platform CC

David Tweed david.tweed at arm.com
Tue Oct 9 03:34:41 PDT 2012


Hi,

> My understanding is that somewhere in the code there should be an equating of the C calling convention with a platform specific convention, and from then on function definitions will automatically be output with the "no marker" form "define @foo". I _think_ what's happening it that this equating isn't occurring, so that when functions are created with the natural platform calling convention LLVM doesn't realise this convention is the same as the C convention, i.e., I don't think it's something that should need doing for each function but is a missing initialisation step.
> 
> However, we still need to figure out where this happens. Any insight from anyone appreciated.

|  Do you really think CC_AAPCS or CC_AAPCS_VFP sould be equal to C
|calling convention? If so, how about making ClangCallConvToLLVMCallConv
|return llvm::CallingConv::C for CC_AAPCS and CC_AAPCS_VFP like this?

My understanding is that clang should be generating function calls with the appropriate default convention, and that default ought to be be being set somewhere in Toolchain.cpp or other driver files. I don't think your patch is right: there's a difference between using the default calling convention which happens to be X and explicitly asking, via function attributes, for a specific calling convention X; in the latter case it has to be preserved. (I think it would be legal, although probably insane, to have explicit calls using apcs, aapcs and aapcs_vfp in the same binary as well as whatever default is being used.) I'm still investigating.

Cheers,
Dave







More information about the cfe-dev mailing list