[PATCH] D40249: Copy Function's calling convention by default when creating a new Call

serge via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 21 03:42:55 PST 2017


serge-sans-paille added a comment.

In https://reviews.llvm.org/D40249#930728, @rnk wrote:

> This wasn't what I had in mind. When a frontend (or any other IR generator) creates a call, it should have a source of type information telling it the function prototype and the calling convention (in clang, the AST). It should also apply any other wacky calling convention flags like -mregparm and other things.


I totally agree. This means extending the current ``Create`` with a ``CallingConv::ID`` parameter to be able to express that in the builder. Note that my implementation goes in the same spirit (if no information, use the function's CallingConvention)

> In the special case where the frontend is emitting a call to a function defined in the current TU, we should have a check that the conventions match. I was imagining that you'd make IRBuilder implement that assert, and then add an alternative CreateCallWithConvention entry point or something like that to allow the frontend to override the check.

I'm not sure that's the best approach. With the approach described above, either the user does not specify the callingconv and it's always consistent (if the function is statically known, that is), or it forces it and we have to trust him/her. Asserting while the LangRef allows mismatching CallingConv seems strange to me. Helping the user to avoid forgeting to set the calling conv looks safer.


Repository:
  rL LLVM

https://reviews.llvm.org/D40249





More information about the llvm-commits mailing list