https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119395
Bug ID: 119395
Summary: target hook function_ok_for_sibcall should take a
gcall* instead of CALL_EXPR as the last argument
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: internal-improvement
Severity: enhancement
Priority: P3
Component: middle-end
Assignee: pinskia at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
I am not sure I will get around to implementing this but I am filing this as I
noticed it when I am cleaning up some of the tail call code.
But basically currently the definition of function_ok_for_sibcall is:
```
"True if it is OK to do sibling call optimization for the specified\n\
call expression @var{exp}. @var{decl} will be the called function,\n\
or @code{NULL} if this is an indirect call.\n\
\n\
It is not uncommon for limitations of calling conventions to prevent\n\
tail calls to functions outside the current unit of translation, or\n\
during PIC compilation. The hook is used to enforce these restrictions,\n\
as the @code{sibcall} md pattern cannot fail, or fall over to a\n\
``normal'' call. The criteria for successful sibling call optimization\n\
may vary greatly between different architectures.",
bool, (tree decl, tree exp),
```
As we move expansion of call directly from gimple instead of creating a
CALL_EXPR, this target hook needs to change.
I am not 100% sure the calling of the target hook can be moved from expand to
the gimple pass though. Because some targets check stuff that is only seemly
available during expand.