public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR 56022] Correct order of calls to invoke_set_current_function_hook and aggregate_value_p
@ 2013-01-21 16:49 Martin Jambor
  2013-01-21 16:58 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Jambor @ 2013-01-21 16:49 UTC (permalink / raw)
  To: GCC Patches

Hi,

segfault reported as PR 56022 happens because cfun->returns_struct is
erroneously set.  This happens because aggregate_value_p (called from
allocate_struct_function) relies on that
invoke_set_current_function_hook has already been called.

The patch below moves the call up bit, although not all the way to its
original position because invoke_set_current_function_hook indirectly
calls init_dummy_function_start which in turns calls
push_struct_function which needs cfun->decl to be set up so that
popping cfun can then restore current function decl.  Checking that
fndecl is not NULL twice is a bit ugly but I thought I'd keep the
assignment to cfun->decl and DECL_STRUCT_FUNCTION (fndecl) together
for the sake of consistency.

Bootstrapped and tested on x86_64-linux without any issues.  OK for
trunk?

Thanks,

Martin


2013-01-21  Martin Jambor  <mjambor@suse.cz>

	PR middle-end/56022
	* function.c (allocate_struct_function): Call
	invoke_set_current_function_hook earlier.

testsuite/
	* gcc.target/i386/pr56022.c: New test.

Index: src/gcc/function.c
===================================================================
--- src.orig/gcc/function.c
+++ src/gcc/function.c
@@ -4479,7 +4479,6 @@ get_last_funcdef_no (void)
 void
 allocate_struct_function (tree fndecl, bool abstract_p)
 {
-  tree result;
   tree fntype = fndecl ? TREE_TYPE (fndecl) : NULL_TREE;
 
   cfun = ggc_alloc_cleared_function ();
@@ -4498,8 +4497,13 @@ allocate_struct_function (tree fndecl, b
       DECL_STRUCT_FUNCTION (fndecl) = cfun;
       cfun->decl = fndecl;
       current_function_funcdef_no = get_next_funcdef_no ();
+    }
+
+  invoke_set_current_function_hook (fndecl);
 
-      result = DECL_RESULT (fndecl);
+  if (fndecl != NULL_TREE)
+    {
+      tree result = DECL_RESULT (fndecl);
       if (!abstract_p && aggregate_value_p (result, fndecl))
 	{
 #ifdef PCC_STATIC_STRUCT_RETURN
@@ -4518,8 +4522,6 @@ allocate_struct_function (tree fndecl, b
          but is this worth the hassle?  */
       cfun->can_throw_non_call_exceptions = flag_non_call_exceptions;
     }
-
-  invoke_set_current_function_hook (fndecl);
 }
 
 /* This is like allocate_struct_function, but pushes a new cfun for FNDECL
Index: src/gcc/testsuite/gcc.target/i386/pr56022.c
===================================================================
--- /dev/null
+++ src/gcc/testsuite/gcc.target/i386/pr56022.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx" } */
+
+typedef float __m256 __attribute__ ((__vector_size__ (32), __may_alias__));
+__attribute__((target("no-avx"))) static int currentImplementationSupported()
+{}
+__m256 foo0(__m256 a) {}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, PR 56022] Correct order of calls to invoke_set_current_function_hook and aggregate_value_p
  2013-01-21 16:49 [PATCH, PR 56022] Correct order of calls to invoke_set_current_function_hook and aggregate_value_p Martin Jambor
@ 2013-01-21 16:58 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2013-01-21 16:58 UTC (permalink / raw)
  To: GCC Patches

On Mon, Jan 21, 2013 at 05:49:46PM +0100, Martin Jambor wrote:
> 2013-01-21  Martin Jambor  <mjambor@suse.cz>
> 
> 	PR middle-end/56022
> 	* function.c (allocate_struct_function): Call
> 	invoke_set_current_function_hook earlier.
> 
> testsuite/
> 	* gcc.target/i386/pr56022.c: New test.

Ok, thanks.

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-21 16:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-21 16:49 [PATCH, PR 56022] Correct order of calls to invoke_set_current_function_hook and aggregate_value_p Martin Jambor
2013-01-21 16:58 ` Jakub Jelinek

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