How to force compiler to save registers before using it during code gen?

I need to call some C functions compiled by clang from JITed code, and the issue is that code compiled by clang would only push callee-saved registers on stack before using them, so I have to push caller-saved registers on stack during JIT every time before calling those functions. So, are there any options in Clang to force the compiler to push registers before using them during generating code for those specific functions? I know gcc supports -fcall-saved-reg, Are there any similar options in clang?

AFAIK, this is a calling convention related issue.
An intuitive suggestion is to change the caller and callee saved register in your arch.

Right, this is related to the calling convention. What would be the correct option in Clang for this, something like -fcall-saved-regs in gcc? I couldn’t find this in any of Clang’s documentation. The most related one seems -fcall-saved-x10, which is only available on aarch64.

Hi Mr hao.
I presume you just want llvm to do all the reg on stack saving for you.
What i was suggesting is that you can change the defs in backend codegen, llvm
will help you save all the callee saved regs, if you add all regs to callee saved register defs,
I believe the backend will automaticlly put all of them on stack for you.