This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] New SRA and early interprocedural SRA


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]