tree-inline: Fix up __builtin_va_arg_pack handling [PR100898]
authorJakub Jelinek <jakub@redhat.com>
Mon, 7 Jun 2021 07:25:37 +0000 (09:25 +0200)
committerJakub Jelinek <jakub@redhat.com>
Mon, 7 Jun 2021 07:25:37 +0000 (09:25 +0200)
commitd66a703c8ba86f3ca04cc10c3071696e6d014de6
treeb7aa12a7dde48a53c2a6b9dac21df6ca2531cadb
parentbe5efe9c12cb852c788f74f8555e6ab8d755479b
tree-inline: Fix up __builtin_va_arg_pack handling [PR100898]

The following testcase ICEs, because gimple_call_arg_ptr (..., 0)
asserts that there is at least one argument, while we were using
it even if we didn't copy anything just to get a pointer from/to which
the zero arguments should be copied.

Fixed by guarding the memcpy calls.  Also, the code was calling
gimple_call_num_args too many times - 5 times instead of 2, so the patch
adds two temporaries for those.

2021-06-07  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/100898
* tree-inline.c (copy_bb): Only use gimple_call_arg_ptr if memcpy
should copy any arguments.  Don't call gimple_call_num_args
on id->call_stmt or call_stmt more than once.

* g++.dg/ext/va-arg-pack-3.C: New test.
gcc/testsuite/g++.dg/ext/va-arg-pack-3.C [new file with mode: 0644]
gcc/tree-inline.c