This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] New SRA and early interprocedural SRA
- From: Martin Jambor <mjambor at suse dot cz>
- To: Jay Foad <jay dot foad at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Jan Hubicka <hubicka at ucw dot cz>
- Date: Wed, 4 Mar 2009 00:58:43 +0100
- Subject: Re: [RFC] New SRA and early interprocedural SRA
- References: <ee2e06e90903030108r66631b8ewada08dc2c377574f@mail.gmail.com>
Hi,
On Tue, Mar 03, 2009 at 09:08:11AM +0000, Jay Foad wrote:
> > If we moved dereferencing the NULL parameter to the caller we would
> > have introduced a segfault in an application which did not suffer from
> > it before. Therefore we have to examine whether on each path from cal
> > to exit in the caller there is a dereferencing statement. We do this
> > by going up the dominator tree from the exit block and looking whether
> > there are any dereferences there.
>
> Does that work even for functions that might never return?
>
> int f (int *p) {
> if (condition which is always true in practice)
> while (true) {}
> else
> return *p;
> }
>
> Every path leading to a return dereferences p, but in practice f will
> never dereference p.
>
Thanks for the test case. I disregarded the infinite loops for
reasons that are no longer valid and so a slight variation of it (the
condition does not have to be always true to get a miscompilation) did
segfault when it shouldn't have.
I was about to add fake edges to te exit block for every statement
that can throw externally and so I thought I would add one for every
back edge too. However, currently it is impossible to get the
dominator of the exit block (if I remmeber correctly because it has a
negative index) and so whenever there is a such edge or statement in
the function, I resort to scanning just the firts basic block (just
like I did before when the exit block has multiple precedessors).
There's only one thing I want to change before posting the current
version so I belive I will do it early tomorrow.
Thanks for your interest in this,
Martin