This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix part of PR86389


Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

>From 52aad98947e5cfcb5624ff24f0c557d0029c34fe Mon Sep 17 00:00:00 2001
From: Richard Guenther <rguenther@suse.de>
Date: Tue, 3 Jul 2018 14:04:01 +0200
Subject: [PATCH] fix-pr86389

2018-07-03  Richard Biener  <rguenther@suse.de>

	PR ipa/86389
	* tree-ssa-structalias.c (find_func_clobbers): Properly
	handle indirect calls.

	* gcc.dg/torture/pr86389.c: New testcase.

diff --git a/gcc/testsuite/gcc.dg/torture/pr86389.c b/gcc/testsuite/gcc.dg/torture/pr86389.c
new file mode 100644
index 00000000000..cc29635c6d0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr86389.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-additional-options "-fipa-pta" } */
+
+void callme (void (*callback) (void));
+
+int
+main (void)
+{
+  int ok = 0;
+  void callback (void) { ok = 1; }
+
+  callme (&callback);
+
+  if (!ok)
+    __builtin_abort ();
+  return 0;
+}
+
+__attribute__((noinline, noclone))
+void
+callme (void (*callback) (void))
+{
+  (*callback) ();
+}
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index ac5d4bc93fe..fd24f84fb14 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -5353,6 +5353,7 @@ find_func_clobbers (struct function *fn, gimple *origt)
       /* For callees without function info (that's external functions),
 	 ESCAPED is clobbered and used.  */
       if (cfi->decl
+	  && TREE_CODE (cfi->decl) == FUNCTION_DECL
 	  && !cfi->is_fn_info)
 	{
 	  varinfo_t vi;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]