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 stor-layout.c > and these sizes can be variable (at least in Ada). So I think that the calls > to the hook are still needed. But: > 1) The -1 thing should go and the hook return boolean. The prerequisite is > to tidy up variable_size, > 2) I think that the GIMPLE hook can return 0 unconditionally. > >> But I'm not sure that is actually what it tries to do ... and the existing >> checks are far from consistently spread out in fold-const.c ... > > 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 supposed to protect SAVE_EXPRs then I'd have expected save_expr to contain that check and possibly return NULL if it can't save. And I'm not sure you can't do SAVE_EXPRs outside of functions - you could simply emit global temporaries. Richard. > -- > Eric Botcazou >