-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for __builtin_va_arg_pack and __builtin_va_arg_pack_len #7591
Comments
This is also being track as rdar://problem/11102669 |
We (Android) would be very happy to see this happen. Our libc currently has a number of the __*_chk() versions of functions #ifdef'd out for clang because this isn't supported. For example: https://github.com/android/platform_bionic/blob/master/libc/include/fcntl.h#L109 |
These builtins seem to work around va_list/va_start/va_end/va_arg. Are they really required, or are they just a lazy way of not writing your own local functions as a matter of vararg types? AFAICS, __builtin_va_arg_pack is almost useless, since generally stdlibs provide a va_list variant (no?), and __builtin_va_arg_pack_len usage is limited to one use: know how many items are references without having to add more code to check it, which seems a bit heavy for a run-time warning. I'm not against them, just sceptical of their value for such a big change in both LLVM and Clang. |
__builtin_va_arg_pack is used inside some stdlibs, e.g. in Bionic we have this construct: #if defined(clang) (where the #if defined(clang) variant is rather bogus, causes e.g. Chromium build to fail when it tries to There doesn't seem to be a good solution for this type of stuff without __builtin_va_arg_pack. glibc actually has a similar construct for fortified snprintf -- except it conditionalizes the #define on !__cplusplus to work around stuff trying to pull snprintf into a namespace or the likes. But that results in unfortified snprintf being used... |
I know bionic and glibc use that, but there is a perfectly valid option to use va_list directly (which glibc also uses). extern int vsnprintf (char *__restrict __s, size_t __maxlen, The only need for the fortified version is __builtin_va_arg_pack_len, which should actually be fixed by having specific non-vararg functions, for example this is kind of silly in a variadic function:
But I guess changing the standard is needed to make them non-variadic. My point is that, whatever savings you have on user code by implementing these builtins, you'll have in the compiler, which may look like saving (users don't need the bloating) but can also be a maintenance hell (by having to account for such builtins on future changes, optimizations, ABI compliance, etc). |
Eli, Do you mean add a metadata on every variadic call on the call itself? Or adding a simple metadata on the variadic function that will invoke the behaviour on the inliner to: IF inline-vararg metadata on function: If LLVM already supports always_inline or gnu_inline, the out-of-line function should be removed before validation, or the builtins/metadata will fail. |
This would be nice to have, to enable using clang with this stand-alone FORTIFY_SOURCE implementation: http://git.2f30.org/fortify-headers/about/ |
Put some patches up for this here: https://reviews.llvm.org/D57635 & https://reviews.llvm.org/D57634 |
Is there any movement on this? All the upstream LLVM feedback I can find on va_arg_pack() and va_arg_pack_len() seem pretty negative. Is there any value in working on this? |
[lldb] Disable TestSwiftStepInAsync.py
Extended Description
Per summary, it would be nice to add support for __builtin_va_arg_pack and __builtin_va_arg_pack_len at some point. Implementation steps:
The text was updated successfully, but these errors were encountered: