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] Fix gimple_purge_all_dead_eh_edges (PR tree-optimization/36766)


On Tue, Sep 2, 2008 at 8:52 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> We ICE on the attached testcase, because tree-ssa-dom.c optimizes
> in 3 different bbs some statements from possibly throwing to ones that can't
> throw and calls gimple_purge_all_dead_eh_edges on them, but the
> gimple_purge_dead_eh_edges call on the second basic block purges also the
> third basic block in the bitmap as unreachable after removing dead eh edge.
>
> I think there is nothing wrong with what DOM or PRE are doing, it can't
> predict if some bb will be purged, so the following patch makes
> gimple_purge_all_dead_eh_edges silently skip basic blocks that have been
> already purged earlier in the loop.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2008-09-02  Jakub Jelinek  <jakub@redhat.com>
>
>        PR tree-optimization/36766
>        * tree-cfg.c (gimple_purge_all_dead_eh_edges): Do nothing
>        for already removed basic blocks.
>
>        * g++.dg/tree-ssa/pr36766.C: New test.
>
> --- gcc/tree-cfg.c.jj   2008-08-31 13:19:03.000000000 +0200
> +++ gcc/tree-cfg.c      2008-09-02 16:06:34.000000000 +0200
> @@ -6560,7 +6560,13 @@ gimple_purge_all_dead_eh_edges (const_bi
>
>   EXECUTE_IF_SET_IN_BITMAP (blocks, 0, i, bi)
>     {
> -      changed |= gimple_purge_dead_eh_edges (BASIC_BLOCK (i));
> +      basic_block bb = BASIC_BLOCK (i);
> +
> +      /* Earlier gimple_purge_dead_eh_edges could have removed
> +        this basic block already.  */
> +      gcc_assert (bb || changed);
> +      if (bb != NULL)
> +       changed |= gimple_purge_dead_eh_edges (bb);
>     }
>
>   return changed;
> --- gcc/testsuite/g++.dg/tree-ssa/pr36766.C.jj  2008-09-02 16:11:13.000000000 +0200
> +++ gcc/testsuite/g++.dg/tree-ssa/pr36766.C     2008-09-02 16:10:47.000000000 +0200
> @@ -0,0 +1,31 @@
> +// PR tree-optimization/36766
> +// { dg-do compile }
> +// { dg-options "-O -fnon-call-exceptions" }
> +
> +struct A
> +{
> +  ~A ()
> +  {
> +    int *a = this->b;
> +  }
> +  int *b;
> +};
> +
> +struct B : A
> +{
> +  B ()
> +  {
> +    int *a = this->b;
> +  }
> +   ~B ()
> +  {
> +    int *a = this->b;
> +  }
> +};
> +
> +void
> +foo ()
> +{
> +  B *c = new B;
> +  delete c;
> +}
>
>        Jakub
>


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