Hi! Before Honza introduced recursive_call_p, this tree-tailcall.c snipped has been guarded with if (func == current_function_decl), so what we used for DECL_ARGUMENTS didn't really matter. But as it can now be some alias to it, we really want to check that the current function's arguments match the arguments of the call, rather than just that the call's arguments match its function type.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-03-07 Jakub Jelinek <ja...@redhat.com> PR tree-optimization/84739 * tree-tailcall.c (find_tail_calls): Check call arguments against DECL_ARGUMENTS (current_function_decl) rather than DECL_ARGUMENTS (func) when checking for tail recursion. * gcc.dg/pr84739.c: New test. --- gcc/tree-tailcall.c.jj 2018-01-12 11:35:51.470222838 +0100 +++ gcc/tree-tailcall.c 2018-03-06 23:05:39.779048759 +0100 @@ -481,7 +481,7 @@ find_tail_calls (basic_block bb, struct { tree arg; - for (param = DECL_ARGUMENTS (func), idx = 0; + for (param = DECL_ARGUMENTS (current_function_decl), idx = 0; param && idx < gimple_call_num_args (call); param = DECL_CHAIN (param), idx ++) { --- gcc/testsuite/gcc.dg/pr84739.c.jj 2018-03-07 09:43:13.961110879 +0100 +++ gcc/testsuite/gcc.dg/pr84739.c 2018-03-07 09:43:19.856109830 +0100 @@ -0,0 +1,26 @@ +/* PR tree-optimization/84739 */ +/* { dg-do compile } */ +/* { dg-require-weak "" } */ +/* { dg-options "-O2" } */ + +static void baz (void) __attribute__((weakref("bar"))); /* { dg-warning "alias between functions of incompatible types" } */ + +int +foo (int x, int y) +{ + if (x) + y = 0; + if (y) + goto lab; + y = 0; +lab: + return y; +} + +void +bar (int x, int y) /* { dg-message "aliased declaration here" } */ +{ + y = foo (x, y); + if (y != 0) + baz (); +} Jakub