Re: [google]: initialize language field for clone function struct

2011-05-05 Thread Richard Guenther
On Wed, May 4, 2011 at 7:14 PM, Eric Botcazou ebotca...@adacore.com wrote: Actually it turns out that it doesn't matter.  If we arrive here with something that needs a SAVE_EXPR we have to be able to generate code for it somewhere, where there would be obviously the possibility to also

Re: [google]: initialize language field for clone function struct

2011-05-05 Thread Eric Botcazou
Sure, but that's a limitation of out SAVE_EXPR handling (given that it would be ok to expand the SAVE_EXPR multiple times - once per instantiation context). You need to expand the initializer exactly once and you need to make sure that this occurrence is invoked before all the others at run

Re: [google]: initialize language field for clone function struct

2011-05-05 Thread Eric Botcazou
But where do you expand it without the SAVE_EXPR? The same restrictions apply there. So I suppose you expand it to a function in which case there is the context where the SAVE_EXPR can be expanded exactly once. You don't have SAVE_EXPRs so you're precisely controlling what you're doing.

Re: [google]: initialize language field for clone function struct

2011-05-05 Thread Eric Botcazou
Hm, ok. I was more looking at removing the calls from fold-const.c where it seems to protect things like folding x = +Inf to x == x, stuff unlikely to appear in type sizes. I can imagine the Ada FE wanting to do things with type sizes and variable_size's wrapping looks like merely an

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Eric Botcazou
Well - the errors in variable_size aren't used by C any more (since 4.5), but I don't know whether any other languages use them. Apparently not, let's remove them. And pending sizes are used to a limited extent for C (to handle side effects in sizes of array parameters, as described in the

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Richard Guenther
On Tue, May 3, 2011 at 6:15 PM, Xinliang David Li davi...@google.com wrote: On Tue, May 3, 2011 at 3:55 AM, Jan Hubicka hubi...@ucw.cz wrote: Is this one ok? Hi, we did quite some work on removing a langhooks for LTO, where they become quite impossible So I would like to know what testcase

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Eric Botcazou
Umm, I think most of them (if not all) are just bogus. If a FE doesn't want to fold some stuff when at global scope it should not call fold. That isn't so easy because fold is invoked on sizes of types by stor-layout.c and these sizes can be variable (at least in Ada). So I think that the

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Joseph S. Myers
On Wed, 4 May 2011, Eric Botcazou wrote: That isn't so easy because fold is invoked on sizes of types by stor-layout.c That's what we should phase out. The eventual aim should be for (a) folding on GIMPLE (gimple-fold etc. - working with SSA not combined trees) as an optimization and (b)

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Eric Botcazou
That's what we should phase out. The eventual aim should be for (a) folding on GIMPLE (gimple-fold etc. - working with SSA not combined trees) as an optimization and (b) folding done by front ends only when required for language semantics (e.g. constant expressions). If you want to optimize

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Richard Guenther
On Wed, May 4, 2011 at 12:00 PM, Eric Botcazou ebotca...@adacore.com wrote: Umm, I think most of them (if not all) are just bogus.  If a FE doesn't want to fold some stuff when at global scope it should not call fold. That isn't so easy because fold is invoked on sizes of types by

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Richard Kenner
That's what we should phase out. The eventual aim should be for (a) folding on GIMPLE (gimple-fold etc. - working with SSA not combined trees) as an optimization and (b) folding done by front ends only when required for language semantics (e.g. constant expressions). Why? Isn't it

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Michael Matz
Hi, On Wed, 4 May 2011, Richard Guenther wrote: It prevents save_expr from being called at global level, since you cannot create SAVE_EXPRs outside functions.  Likewise in variable_size. I see several places in fold-const.c that are not properly guarded then. But anyway, if it is

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Richard Guenther
On Wed, May 4, 2011 at 1:56 PM, Michael Matz m...@suse.de wrote: Hi, On Wed, 4 May 2011, Richard Guenther wrote: It prevents save_expr from being called at global level, since you cannot create SAVE_EXPRs outside functions.  Likewise in variable_size. I see several places in

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Diego Novillo
On Wed, May 4, 2011 at 07:44, Richard Kenner ken...@vlsi1.ultra.nyu.edu wrote: That's what we should phase out.  The eventual aim should be for (a) folding on GIMPLE (gimple-fold etc. - working with SSA not combined trees) as an optimization and (b) folding done by front ends only when required

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Richard Kenner
There are pros and cons about early optimization, actually. Generating extremely optimized IL very early can actually tie up subsequent passes. For instance, loop unrolling and vectorization. There are others in the literature. Sure, in the sorts of examples you mention where there's a level

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Diego Novillo
On Wed, May 4, 2011 at 08:30, Richard Kenner ken...@vlsi1.ultra.nyu.edu wrote: There are pros and cons about early optimization, actually. Generating extremely optimized IL very early can actually tie up subsequent passes.  For instance, loop unrolling and vectorization. There are others in

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Michael Matz
Hi, On Wed, 4 May 2011, Richard Kenner wrote: There are pros and cons about early optimization, actually. Generating extremely optimized IL very early can actually tie up subsequent passes. For instance, loop unrolling and vectorization. There are others in the literature. Sure, in

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Nathan Froyd
On Wed, May 04, 2011 at 08:30:40AM -0400, Richard Kenner wrote: There are pros and cons about early optimization, actually. Generating extremely optimized IL very early can actually tie up subsequent passes. For instance, loop unrolling and vectorization. There are others in the

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Diego Novillo
On Wed, May 4, 2011 at 09:19, Nathan Froyd froy...@codesourcery.com wrote: On Wed, May 04, 2011 at 08:30:40AM -0400, Richard Kenner wrote: There are pros and cons about early optimization, actually. Generating extremely optimized IL very early can actually tie up subsequent passes.  For

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Richard Kenner
I think we may be talking at different levels. It's my impression that Richard K. was referring to local transformations like a - a - 0 once we are in the middle end. I agree that doing that transformation close to the FE is undesirable, but once we are in the middle end that should be

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Eric Botcazou
And I'm not sure you can't do SAVE_EXPRs outside of functions - you could simply emit global temporaries. How do you initialize global temporaries with non-trivial initializers? -- Eric Botcazou

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Richard Guenther
On Wed, May 4, 2011 at 5:10 PM, Eric Botcazou ebotca...@adacore.com wrote: And I'm not sure you can't do SAVE_EXPRs outside of functions - you could simply emit global temporaries. How do you initialize global temporaries with non-trivial initializers? Actually it turns out that it doesn't

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Eric Botcazou
Actually it turns out that it doesn't matter. If we arrive here with something that needs a SAVE_EXPR we have to be able to generate code for it somewhere, where there would be obviously the possibility to also generate code for a SAVE_EXPR. The transformations done in fold are optimizations

Re: [google]: initialize language field for clone function struct

2011-05-04 Thread Tom Tromey
Joseph I don't know if Fortran, Java or Go use variable-size types at Joseph all. Java doesn't have variable-size types. AFAIK, gcj does not generate them internally for anything, either. Tom

Re: [google]: initialize language field for clone function struct

2011-05-03 Thread Xinliang David Li
On Tue, May 3, 2011 at 3:55 AM, Jan Hubicka hubi...@ucw.cz wrote: Is this one ok? Hi, we did quite some work on removing a langhooks for LTO, where they become quite impossible So I would like to know what testcase causes the problem and why. In fold-const.c, there are many of calls to

Re: [google]: initialize language field for clone function struct

2011-05-03 Thread Jan Hubicka
In fold-const.c, there are many of calls to lang_hooks.decls.global_bindings_p, and the implementation of this in name-lookup.h will look at the the cfun-language #define cp_function_chain (cfun-language) #define current_binding_level \ (*(cfun cp_function_chain

Re: [google]: initialize language field for clone function struct

2011-05-03 Thread Eric Botcazou
I am however completely missing the point of this langhook and doc is not exactly informative either: /* Returns nonzero if we are in the global binding level. Ada returns -1 for an undocumented reason used in stor-layout.c. */ What is the purpose of this hook? I've seen things

Re: [google]: initialize language field for clone function struct

2011-05-03 Thread Joseph S. Myers
On Tue, 3 May 2011, Eric Botcazou wrote: I am however completely missing the point of this langhook and doc is not exactly informative either: /* Returns nonzero if we are in the global binding level. Ada returns -1 for an undocumented reason used in stor-layout.c. */ What

Re: [google]: initialize language field for clone function struct

2011-05-03 Thread Nathan Froyd
On Tue, May 03, 2011 at 07:06:58PM +, Joseph S. Myers wrote: In my view we should require front ends to take responsibility for variable-size types, and get rid of this language-independent function (copying such parts as are needed into the front ends that need them). C for example

Re: [google]: initialize language field for clone function struct

2011-05-03 Thread Joseph S. Myers
On Tue, 3 May 2011, Nathan Froyd wrote: On Tue, May 03, 2011 at 07:06:58PM +, Joseph S. Myers wrote: In my view we should require front ends to take responsibility for variable-size types, and get rid of this language-independent function (copying such parts as are needed into the

Re: [google]: initialize language field for clone function struct

2011-05-03 Thread Eric Botcazou
In my view we should require front ends to take responsibility for variable-size types, and get rid of this language-independent function (copying such parts as are needed into the front ends that need them). I don't really see the point here. GCC supports variable-sized types in the

Re: [google]: initialize language field for clone function struct

2011-05-03 Thread Nathan Froyd
On Tue, May 03, 2011 at 07:27:24PM +, Joseph S. Myers wrote: On Tue, 3 May 2011, Nathan Froyd wrote: The raft of changes/improvements enabled by this change would be most welcome. *_SIZE becoming double_ints or HOST_WIDE_INT instead of trees is the first thing that comes to mind;

Re: [google]: initialize language field for clone function struct

2011-05-03 Thread Joseph S. Myers
On Tue, 3 May 2011, Eric Botcazou wrote: In my view we should require front ends to take responsibility for variable-size types, and get rid of this language-independent function (copying such parts as are needed into the front ends that need them). I don't really see the point here.

Re: [google]: initialize language field for clone function struct

2011-05-03 Thread Eric Botcazou
C returns -1 from global_bindings_p, as does Ada. That the languages that probably care most about variable-size types find aspects of the generic function need overriding like that should be a good indication that it isn't really that generic - as I said above, semantics for variable sizes

Re: [google]: initialize language field for clone function struct

2011-05-03 Thread Joseph S. Myers
On Tue, 3 May 2011, Eric Botcazou wrote: C returns -1 from global_bindings_p, as does Ada. That the languages that probably care most about variable-size types find aspects of the generic function need overriding like that should be a good indication that it isn't really that generic -

Re: [google]: initialize language field for clone function struct

2011-05-02 Thread Xinliang David Li
Is this one ok? David On Fri, Apr 29, 2011 at 4:38 PM, Xinliang David Li davi...@google.com wrote: During function cloning, the language field of the src func is not copied. This can lead to null dereference when gcc calls into langhook functions.  Unfortunately, I lost track of the test

[google]: initialize language field for clone function struct

2011-04-29 Thread Xinliang David Li
During function cloning, the language field of the src func is not copied. This can lead to null dereference when gcc calls into langhook functions. Unfortunately, I lost track of the test case. Ok for trunk ? Thanks, David 2011-04-29 Xinliang David Li davi...@google.com *