]> git.ipfire.org Git - thirdparty/gcc.git/commit
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>
Wed, 11 May 2022 05:58:18 +0000 (07:58 +0200)
commit97785bcbc66b11f41030a459f7b170f1e2ed5e50
tree8b493c1a9c46de70dbf974e40e5be93882aaf5c1
parente7e1ad94007d79b5bae948a03b6c6b57243708bc
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.

(cherry picked from commit d66a703c8ba86f3ca04cc10c3071696e6d014de6)
gcc/testsuite/g++.dg/ext/va-arg-pack-3.C [new file with mode: 0644]
gcc/tree-inline.c