[PATCH, PR40323] Prevent infinite looping in ipa-prop.c

Richard Guenther richard.guenther@gmail.com
Wed Jun 3 10:13:00 GMT 2009


2009/6/2 Martin Jambor <mjambor@suse.cz>:
> Hi,
>
> the following patch prevents a bogus infinite loop in ipa-prop.c when
> building jump functions for member pointers.
>
> I have bootstrapped and tegression tested the patch on x86_64-linux.
>
> OK for trunk (in particular, is the tescase OK and at the right place)?

The testcase should not have -O3 in dg-options (-O3 is among the
torture options used).

Ok if you omit that.

Thanks,
Richard.

> Thanks,
>
> Martin
>
> 2009-06-02  Martin Jambor  <mjambor@suse.cz>
>
>        PR tree-optimization/40323
>        * ipa-prop.c (get_ssa_def_if_simple_copy): Break if not single
>        assignment.
>
>        * testsuite/g++.dg/torture/pr40323.C: New file.
>
> Index: gcc/testsuite/g++.dg/torture/pr40323.C
> ===================================================================
> --- gcc/testsuite/g++.dg/torture/pr40323.C      (revision 0)
> +++ gcc/testsuite/g++.dg/torture/pr40323.C      (revision 0)
> @@ -0,0 +1,68 @@
> +/* Testcase for PR 40323.  */
> +/* { dg-do compile } */
> +/* { dg-options "-O3 -fno-early-inlining"  } */
> +/* { dg-options "-O3 -fno-early-inlining -fpie" { target { ! nonpic } } } */
> +
> +extern void do_something (const char *, int);
> +
> +class Parent
> +{
> +private:
> +  const char *data;
> +
> +public:
> +  Parent (const char *d) : data(d)
> +  {}
> +
> +  int funcOne (int delim) const;
> +};
> +
> +class AnotherParent
> +{
> +private:
> +  double d;
> +public:
> +  AnotherParent (void) : d(0)
> +  {}
> +};
> +
> +
> +class Child : public AnotherParent, Parent
> +{
> +private:
> +  int zzz;
> +public:
> +  Child (const char *d) : Parent(d)
> +  {}
> +};
> +
> +
> +int Parent::funcOne (int delim) const
> +{
> +  int i;
> +  for (i = 0; i < delim; i++)
> +    do_something(data, i);
> +
> +  return 1;
> +}
> +
> +int docalling (int (Child::* f)(int delim) const)
> +{
> +  Child S ("muhehehe");
> +
> +  return (S.*f)(4);
> +}
> +
> +typedef int (Parent::* my_mp_type)(int delim);
> +
> +int main (int argc, char *argv[])
> +{
> +  int i;
> +  int (Parent::* f)(int ) const;
> +  int (Child::* g)(int ) const;
> +
> +  f = &Parent::funcOne;
> +  g = (int (Child::* )(int) const) f;
> +  i = docalling (g);
> +  return i;
> +}
> Index: gcc/ipa-prop.c
> ===================================================================
> --- gcc/ipa-prop.c      (revision 148082)
> +++ gcc/ipa-prop.c      (working copy)
> @@ -440,6 +440,8 @@ get_ssa_def_if_simple_copy (tree rhs)
>
>       if (gimple_assign_single_p (def_stmt))
>        rhs = gimple_assign_rhs1 (def_stmt);
> +      else
> +       break;
>     }
>   return rhs;
>  }
>



More information about the Gcc-patches mailing list