https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116080

--- Comment #18 from Christophe Lyon <clyon at gcc dot gnu.org> ---
Sorry, no, this is not the cause of the problem (actually musttail7.c also
fails in gcc.log).

I looked into this, and it's a bit tricky....

in arm_function_ok_for_sibcall() (from arm.cc), we have:
  /* If we are interworking and the function is not declared static
     then we can't tail-call it unless we know that it exists in this
     compilation unit (since it might be a Thumb routine).  */
  if (TARGET_INTERWORK && decl && TREE_PUBLIC (decl)
      && !TREE_ASM_WRITTEN (decl))
    return false;

In this specific case, we have TARGET_INTERWORK==true because we default to
armv4t. In the other configurations we test, TARGET_INTERWORK==false because we
use newer architecture versions.

So.... the testcase emits an error because TREE_ASM_WRITTEN (decl) == false for
f2() since it is recursive.

Is musttail7.c specifically about testing recursive calls?

As a workaround, I suggest to remove {} from foo's definition, such that it is
TREE_PUBLIC, but TREE_ASM_WRITTEN is false.


AFAICS, this is already what we have in
check_effective_target_external_musttail and
check_effective_target_struct_musttail.

Reply via email to