[PATCH] Make DeadArgElimination more conservative with va_arg functions

Tim Northover t.p.northover at gmail.com
Sat Jun 8 14:15:33 PDT 2013


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: variadic.c
Type: text/x-csrc
Size: 422 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130608/81cd745b/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dead-arg-safe.diff
Type: application/octet-stream
Size: 3472 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130608/81cd745b/attachment.obj>


More information about the llvm-commits mailing list