On Tue, Apr 30, 2019 at 09:03:07AM -0600, Jeff Law wrote:
> On 2/16/19 12:12 AM, Jakub Jelinek wrote:
> > Both the C and C++ standard guarantee that the argc argument to main is
> > non-negative, the following patch sets (or adjusts) the corresponding
> > SSA_NAME_RANGE_INFO.  While main is just one, with IPA VRP it can also
> > propagate etc.  I had to change one testcase because it started optimizing
> > it better (the test has been folded away), so no sinking was done.
> > 
> > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> > 
> > 2019-02-16  Jakub Jelinek  <ja...@redhat.com>
> > 
> >     PR tree-optimization/89350
> >     * gimple-ssa-evrp.c: Include tree-dfa.h and langhooks.h.
> >     (maybe_set_main_argc_range): New function.
> >     (execute_early_vrp): Call it.
> > 
> >     * gcc.dg/tree-ssa/vrp122.c: New test.
> >     * gcc.dg/tree-ssa/ssa-sink-3.c (main): Rename to ...
> >     (bar): ... this.
> My recollection is this was somewhat controversial WRT standards
> interpretation.  Additionally, it's just not clear how often this will
> help in the real world and Martin adjusted compute_objsize and the
> restrict pass to avoid the false positive.
> 
> Do we want to continue with this patch independently or not?  My
> inclination would be no.

I wanted to follow-up on this and restrict it to for now to C++ where it is
non-controversial.  Would be of course nice if the C WG discusses it too and
clarifies if needed, I agree the wording isn't 100% clear and the
requirement shouldn't be on whatever use does with that parameter inside of
main, but should be a contract on when main is called and if user decides to
call main multiple times in C, that contract should not be violated even
during the subsequent calls.

        Jakub

Reply via email to