https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99339
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Clearly LLVM doesn't do the varargs optimizations we do. Anyway, perhaps for these special cases we could just figure out which of the exact arguments is accessed (if for all .VA_ARG calls we see the exact sequence of those calls from __builtin_va_start and they are few) in a target hook called from the stdarg pass and let the target hook replace them with some internal fn call or register var read etc. And optimize away __builtin_va_start if nothing else would use it after that optimization. The question is how common in the wild it is and if it is worth the work. I guess e.g. the open function (when not implemented in assembly or hacked up so that it just has 3 arguments on the definition instead of 2 + ...) is an example where it could benefit from that. The lowering is done so that the GIMPLE optimizers can actually optimize all the struct field loads/stores etc., doing it only in RTL optimizations results in worse code.