On Fri, Sep 06, 2024 at 09:51:38AM +0200, Richard Biener wrote:
> On Fri, Sep 6, 2024 at 9:31 AM Jakub Jelinek <ja...@redhat.com> wrote:
> >
> > On Fri, Sep 06, 2024 at 12:21:20AM -0700, Andrew Pinski wrote:
> > > This is an alternative patch to fix PR tree-optimization/116601 by 
> > > factoring
> > > out the main part of pass_fold_builtins::execute into its own function so 
> > > that
> > > we don't need to repeat the code for doing the eh cleanup. It also fixes 
> > > the
> > > problem I saw with the atomics which might skip over a statement; though 
> > > I don't
> > > have a testcase for that.
> >
> > I'm worried about using this elsewhere, various fab foldings are meant to be
> > done only in that pass and not earlier.
> > E.g. the __builtin_constant_p folding, __builtin_assume_aligned, stack
> > restore, unreachable, va_{start,end,copy}.
> 
> Maybe we can document this fact better or name the function differently?

Some of it is documented already in the source.
                case BUILT_IN_CONSTANT_P:
                  /* Resolve __builtin_constant_p.  If it hasn't been
                     folded to integer_one_node by now, it's fairly
                     certain that the value simply isn't constant.  */
                  result = integer_zero_node;
or
                case BUILT_IN_VA_START:
                case BUILT_IN_VA_END:
                case BUILT_IN_VA_COPY:
                  /* These shouldn't be folded before pass_stdarg.  */
                  result = optimize_stdarg_builtin (stmt);
Obviously, if either is done much earlier, then the former can fold to 1
(e.g. if it is before IPA or shortly after IPA and not all usual propagation
after inlining etc. is done already), or pass_stdarg hasn't been done, etc.

        Jakub

Reply via email to