[llvm-dev] Changing the libc calling convention

Ed Jones via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 6 02:27:30 PDT 2015

I have been searching for a way to change the default calling convention
used for library calls in Clang/LLVM. Although I can see a way to change
the calling convention for compiler-rt functions, there does not appear
to be a mechanism to achieve this for libc library calls.

I have tried a couple of solution:

I tried to change the calling convention in the declarations in the
library. For some library functions, these declarations appear to
conflict with the implicit declaration known to Clang, and I couldn't
find an obvious means for a target to override this. Another problem
with this approach was that the user could provide their own
declarations without a calling convention.

I also tried changing the calling convention in LLVM, by adding a hook
to TargetLibraryInfo to let the target override it. This worked for
trivial cases, but not for function pointers and a couple of other edge

I can probably make either solution work for my use case, but I am
curious if there is an obvious solution I am missing.

Best regards,
Edward Jones

More information about the llvm-dev mailing list