[PATCH] Make DeadArgElimination more conservative with va_arg functions

Rafael EspĂ­ndola rafael.espindola at gmail.com
Sat Jun 8 17:08:01 PDT 2013


LGTM.

This would be a safe transformation if all targets were using va_arg
instruction, right? The problem is that in many architectures it is
clang that expands va_arg, and llvm cannot easily compensate for an
arg going missing. A comment saying that would be nice.

On 8 June 2013 17:15, Tim Northover <t.p.northover at gmail.com> wrote:
> Hi,
>
> The attached patch is an attempt to resolve PR16255 which was revealed
> on AArch64 but potentially affects any target with two properties:
> 1. Variadic functions are called as normal functions
> 2. Clang counts registers and the LLVM IR type of an argument is
> context-sensitive.
>
> In particular x86_64 is also affected (see attached test-case,
> miscompiled at O3).
>
> The patch changes DeadArgElimination to be more conservative with
> variadic functions and in particular not remove them. It still does
> the optimisations I believe are safe:
> 1. Get rid if variadicity entirely if va_start not called.
> 2. Eliminate unused return values
> 3. Change caller values to undef if the parameter is unused.
>
> Obviously, there are potential performance issues here but I believe
> variadic calls are rarely performance-critical so that shouldn't be
> much of an issue.
>
> Ok to commit?
>
> Tim.
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



More information about the llvm-commits mailing list