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: [PATCH, IPA ICF] Fix PR63664, PR63574 (segfault in ipa-icf pass)


On Tue, Oct 28, 2014 at 5:14 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> Hi,
>
> This patch fixes PR63664 and PR63574.  Problem is in NULL types for labels not handled by ICF properly.  I assume it is OK for labels to have NULL type and added check into ICF rather then fixed label generation.
>
> Bootstrapped and checked on linux-x86_64.  OK for trunk?

Instead it shouldn't be called for labels instead.

Richard.

> Thanks,
> Ilya
> --
> gcc/
>
> 2014-10-28  Ilya Enkovich  <ilya.enkovich@intel.com>
>
>         PR ipa/63664
>         PR bootstrap/63574
>         * ipa-icf-gimple.c (func_checker::compatible_types_p): Allow NULL args.
>
> gcc/testsuite/
>
> 2014-10-28  Ilya Enkovich  <ilya.enkovich@intel.com>
>
>         PR ipa/63664
>         * gcc.dg/ipa/pr63664.C: New.
>
>
> diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
> index 1369b74..afc0eeb 100644
> --- a/gcc/ipa-icf-gimple.c
> +++ b/gcc/ipa-icf-gimple.c
> @@ -169,6 +169,11 @@ bool func_checker::compatible_types_p (tree t1, tree t2,
>                                        bool compare_polymorphic,
>                                        bool first_argument)
>  {
> +  if (!t1 && !t2)
> +    return true;
> +  else if (!t1 || !t2)
> +    return false;
> +
>    if (TREE_CODE (t1) != TREE_CODE (t2))
>      return return_false_with_msg ("different tree types");
>
> diff --git a/gcc/testsuite/gcc.dg/ipa/pr63664.C b/gcc/testsuite/gcc.dg/ipa/pr63664.C
> new file mode 100644
> index 0000000..31d96d4
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/ipa/pr63664.C
> @@ -0,0 +1,43 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +class test {
> + public:
> +  test (int val, int *p)
> +    {
> +      int_val = *p;
> +      bool_val = (val != int_val);
> +    }
> +
> +  ~test ()
> +    {
> +      if (!bool_val)
> +       return;
> +    }
> +
> +  int get_int_val () const { return int_val; }
> +
> + private:
> +  bool bool_val;
> +  int int_val;
> +};
> +
> +static int __attribute__ ((noinline))
> +f1 (int i, int *p)
> +{
> +  test obj (i, p);
> +  return obj.get_int_val ();
> +}
> +
> +static int __attribute__ ((noinline))
> +f2 (int i, int *p)
> +{
> +  test obj (i, p);
> +  return obj.get_int_val ();
> +}
> +
> +int
> +f (int i, int *p)
> +{
> +  return f1 (i, p) + f2 (i, p);
> +}


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