[PATCH] D27050: [X86] Add explicit regparm flag for X86-32 calling convention.

James Y Knight via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 28 12:33:01 PST 2016


jyknight added a comment.

There's two cases:

1. The calling convention for functions named in the IR. This can be set separately for each function by the frontend. Today, it's done by putting "inreg" attributes on appropriate parameters.
2. The calling convention used for library calls generated by LLVM. Today, this is not handled.

The former can be specified by __attribute__((regparm(N))), and the -mregparm command-line flag specifies both 2, and the default for 1.

This patch adds support for 2, without changing the way 1 works. But, ISTM, both of these should be really handled similarly -- I don't much like that this patch is adding new calling convention code for 2, but leaving the handling for 1 in clang's decision about whether to use "inreg".

I think, instead, that 3 new calling conventions, "x86_regparm_{1,2,3}" should be defined -- variants of the C calling convention, with a different number of args passed in registers.

Then --

1. Clang can emit the right cc for functions it defines/declares, rather than choosing where to place inreg.
2. Which one of the calling convention to use for libcalls can be set by a subtarget feature (selected by clang based on -mregparm=N command-line option, examined by X86TargetLowering to determine what to pass to setLibcallCallingConv).


https://reviews.llvm.org/D27050





More information about the llvm-commits mailing list