public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5822] x86: Check FUNCTION_DECL before calling cgraph_node::get
@ 2021-12-07 13:25 H.J. Lu
0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2021-12-07 13:25 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:7ef68c37b3a46e69ed4a5ff6b2b368e2c9a8023f
commit r12-5822-g7ef68c37b3a46e69ed4a5ff6b2b368e2c9a8023f
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Tue Dec 7 05:09:34 2021 -0800
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.
Diff:
---
gcc/config/i386/i386.c | 3 ++-
gcc/testsuite/gcc.dg/pr103594.c | 14 ++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 52547b0f057..f1e41fd55f9 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -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
diff --git a/gcc/testsuite/gcc.dg/pr103594.c b/gcc/testsuite/gcc.dg/pr103594.c
new file mode 100644
index 00000000000..0eae239eea0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr103594.c
@@ -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) ();
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-07 13:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 13:25 [gcc r12-5822] x86: Check FUNCTION_DECL before calling cgraph_node::get H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).