x86: Check FUNCTION_DECL before calling cgraph_node::get

gcc/

	PR target/103594
	* config/i386/i386.c (ix86_call_use_plt_p): Check FUNCTION_DECL
	before calling cgraph_node::get.

gcc/testsuite/

	PR target/103594
	* gcc.dg/pr103594.c: New test.
This commit is contained in:
H.J. Lu 2021-12-07 05:09:34 -08:00
parent 6e8a31275f
commit 7ef68c37b3
2 changed files with 16 additions and 1 deletions

View File

@ -15987,7 +15987,8 @@ ix86_call_use_plt_p (rtx call_op)
{
if (SYMBOL_REF_LOCAL_P (call_op))
{
if (SYMBOL_REF_DECL (call_op))
if (SYMBOL_REF_DECL (call_op)
&& TREE_CODE (SYMBOL_REF_DECL (call_op)) == FUNCTION_DECL)
{
/* NB: All ifunc functions must be called via PLT. */
cgraph_node *node

View File

@ -0,0 +1,14 @@
/* { dg-do compile { target fpic } } */
/* { dg-options "-O1 -fpic" } */
int regex_subst(void)
{
const void *subst = "";
return (*(int (*)(int))subst) (0);
}
int foobar (void)
{
int x;
return (*(int (*)(void))&x) ();
}