diff mbox

Fix BLOCK_SUPERCONTEXT for cilk produced functions

Message ID 20140704090536.GA25736@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka July 4, 2014, 9:05 a.m. UTC
Hi,
BLOCK_SUPERCONTEXT for normal blocks leads all the way to FUNCTOIN_DECL.  This is not the case of some
automatically generated functions, like one for cilk.  I think it is bug. This patch fixes cilk, I will
look for other cases if that looks OK.

Bootstrapped/regtested x86_64-linux

Honza

	* cilk.c (create_cilk_helper_decl): Create toplevel block correctly.

Comments

Jeff Law July 7, 2014, 5:47 p.m. UTC | #1
On 07/04/14 03:05, Jan Hubicka wrote:
> Hi,
> BLOCK_SUPERCONTEXT for normal blocks leads all the way to FUNCTOIN_DECL.  This is not the case of some
> automatically generated functions, like one for cilk.  I think it is bug. This patch fixes cilk, I will
> look for other cases if that looks OK.
>
> Bootstrapped/regtested x86_64-linux
>
> Honza
>
> 	* cilk.c (create_cilk_helper_decl): Create toplevel block correctly.
But doesn't this put the CILK created FUNCTION_DECL within the scope FNDECL?

Though I guess that may be reasonable since these decls are created in 
response to the spawn keyword.  To some degree they are nested within 
the scope of the current function.

OK.

jeff
Jan Hubicka July 7, 2014, 8:14 p.m. UTC | #2
> On 07/04/14 03:05, Jan Hubicka wrote:
> >Hi,
> >BLOCK_SUPERCONTEXT for normal blocks leads all the way to FUNCTOIN_DECL.  This is not the case of some
> >automatically generated functions, like one for cilk.  I think it is bug. This patch fixes cilk, I will
> >look for other cases if that looks OK.
> >
> >Bootstrapped/regtested x86_64-linux
> >
> >Honza
> >
> >	* cilk.c (create_cilk_helper_decl): Create toplevel block correctly.
> But doesn't this put the CILK created FUNCTION_DECL within the scope FNDECL?

I am not sure I understand your question...
FNDECL is a newly created decl that will get its body filled in later. I
believe the BLOCK_SUPERCONTEXT of its main block should be always FNDECL
instead of NULL as for was majority of functions we produce...
if that function contains code outlined from the main function, I think
these are linked by ABSTRACT_ORIGIN.

Honza
> 
> Though I guess that may be reasonable since these decls are created
> in response to the spawn keyword.  To some degree they are nested
> within the scope of the current function.
> 
> OK.
> 
> jeff
Jeff Law July 17, 2014, 8:45 a.m. UTC | #3
On 07/07/14 14:14, Jan Hubicka wrote:
>> On 07/04/14 03:05, Jan Hubicka wrote:
>>> Hi,
>>> BLOCK_SUPERCONTEXT for normal blocks leads all the way to FUNCTOIN_DECL.  This is not the case of some
>>> automatically generated functions, like one for cilk.  I think it is bug. This patch fixes cilk, I will
>>> look for other cases if that looks OK.
>>>
>>> Bootstrapped/regtested x86_64-linux
>>>
>>> Honza
>>>
>>> 	* cilk.c (create_cilk_helper_decl): Create toplevel block correctly.
>> But doesn't this put the CILK created FUNCTION_DECL within the scope FNDECL?
>
> I am not sure I understand your question...
> FNDECL is a newly created decl that will get its body filled in later. I
> believe the BLOCK_SUPERCONTEXT of its main block should be always FNDECL
> instead of NULL as for was majority of functions we produce...
> if that function contains code outlined from the main function, I think
> these are linked by ABSTRACT_ORIGIN.
Nevermind.  I was confused about the state fndecl & the context chains.

OK for the trunk and 4.9 if you think it's important to address there as 
well

jeff
diff mbox

Patch

Index: cilk.c
===================================================================
--- cilk.c	(revision 212278)
+++ cilk.c	(working copy)
@@ -314,6 +314,7 @@  create_cilk_helper_decl (struct wrapper_
   tree block = make_node (BLOCK);
   DECL_INITIAL (fndecl) = block;
   TREE_USED (block) = 1;
+  BLOCK_SUPERCONTEXT (block) = fndecl;
   gcc_assert (!DECL_SAVED_TREE (fndecl));
 
   /* Inlining would defeat the purpose of this wrapper.