Gaël Jobin via llvm-dev
2016-Jan-27 13:11 UTC
[llvm-dev] Why the platform dependent "va_list" variable is lowered by the frontend?
Hi all, I was playing with varargs and was wondering why the va_list variable in C is lowered by the frontend to a *i8 (x86) or a struct (x86_64)? I mean, if it depends on the architecture, it is more logical to have an IR intrinsic for va_list and let the backend lowering it to the right type. Regards, Gaël
Joerg Sonnenberger via llvm-dev
2016-Jan-27 14:04 UTC
[llvm-dev] Why the platform dependent "va_list" variable is lowered by the frontend?
On Wed, Jan 27, 2016 at 02:11:17PM +0100, Gaël Jobin via llvm-dev wrote:> I was playing with varargs and was wondering why the va_list variable > in C is lowered by the frontend to a *i8 (x86) or a struct (x86_64)? I > mean, if it depends on the architecture, it is more logical to have an > IR intrinsic for va_list and let the backend lowering it to the right > type.On many architectures, the IR support for variadic function calls is quite limited due to the complexity of the ABIs involved. As the frontend is then responsible for the doing the right thing esp. for va_arg, it most of intimate knowledge already. Joerg
James Y Knight via llvm-dev
2016-Jan-27 14:10 UTC
[llvm-dev] Why the platform dependent "va_list" variable is lowered by the frontend?
Yes, it does seem more logical. Unfortunately, this is not possible, at least with the current state of LLVM. Note in particular that *function calls* are also handled specially by the clang frontend for many architectures. On the LLVM side, there's not enough information to properly represent the function call convention for many architectures, as the calling conventions depend on C type information, and after converting the C types into LLVM types, some of the necessary information has been lost. I think it would be great to move more of the calling convention logic down to LLVM -- and I have some half-baked ideas on how it could be done without pushing the entire C type system down. But, it's certainly not trivial. On Wed, Jan 27, 2016 at 8:11 AM, Gaël Jobin via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi all, > > I was playing with varargs and was wondering why the va_list variable > in C is lowered by the frontend to a *i8 (x86) or a struct (x86_64)? I > mean, if it depends on the architecture, it is more logical to have an > IR intrinsic for va_list and let the backend lowering it to the right > type. > > Regards, > Gaël > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160127/89477028/attachment.html>