Fix part of PR86389

Message ID alpine.LSU.2.20.1807031554320.16707@zhemvz.fhfr.qr
State New
Headers show
Series
  • Fix part of PR86389
Related show

Commit Message

Richard Biener July 3, 2018, 1:55 p.m.
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.

Comments

Sandra Loosemore July 13, 2018, 4:35 p.m. | #1
On 07/03/2018 07:55 AM, Richard Biener wrote:
> 

> 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.


FYI, it looks like this new testcase requires

/* { dg-require-effective-target trampolines } */

as it is failing on a target without nested function support. 
Alternatively, maybe the testcase could be rewritten not to use a nested 
function?  I'm not sure if nested-ness is required to test the bug this 
issue was for.

-Sandra
Richard Biener July 16, 2018, 7:29 a.m. | #2
On Fri, 13 Jul 2018, Sandra Loosemore wrote:

> On 07/03/2018 07:55 AM, Richard Biener wrote:

> > 

> > 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.

> 

> FYI, it looks like this new testcase requires

> 

> /* { dg-require-effective-target trampolines } */

> 

> as it is failing on a target without nested function support. Alternatively,

> maybe the testcase could be rewritten not to use a nested function?  I'm not

> sure if nested-ness is required to test the bug this issue was for.


Fixed.

Richard.

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

	PR ipa/86389
	* gcc.dg/torture/pr86389.c: Require trampolines.

Index: gcc/testsuite/gcc.dg/torture/pr86389.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr86389.c	(revision 262676)
+++ gcc/testsuite/gcc.dg/torture/pr86389.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do run } */
+/* { dg-require-effective-target trampolines } */
 /* { dg-additional-options "-fipa-pta" } */
 
 void callme (void (*callback) (void));

Patch

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;