Avoid ivopts when loop contains vfork

Richard Guenther richard.guenther@gmail.com
Thu Feb 10 16:27:00 GMT 2011


On Thu, Feb 10, 2011 at 3:31 PM, Bernd Schmidt <bernds@codesourcery.com> wrote:
> When a loop contains vfork, certain loop optimizations can be incorrect.
> This was seen with an unreleased port in the LTP testcase waitpid03,
> with the relevant part of the code looking like this:
>
>               while (++ikids < MAXUPRC) {
>                        if ((pid[ikids] = FORK_OR_VFORK()) > 0) {
>
> This was transformed into an autoinc, i.e. something like
>
>               while (ikids < MAXUPRC - 1) {
>                        if ((pid[ikids++] = FORK_OR_VFORK()) > 0) {
>
> ikids did not get a hard register, which means that the copy on the
> stack was incremented twice, once for each return from vfork.

Err, but isn't the stack copied by fork?  It isn't obvious to me that
IVOPTs can't handle returning twice functions transparently (it has
to consider us going into both arms of the if anyways).

Richard.

> In our tree, I fixed it with the following patch.  Note that, despite
> the name, setjmp_call_p really tests ECF_RETURNS_TWICE, which is true
> for vfork as well.
>
> Bootstrapped and regression tested on i686-linux.  Ok?
>
>
> Bernd
>
>



More information about the Gcc-patches mailing list