https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65302

--- Comment #5 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
BB 5 is:
<bb 5>:
getStringBounds (_4, _11, &D.4106, _9, _8, _7);
goto <bb 7>;

and fixup cfg calls:

8702              if (maybe_clean_eh_stmt (stmt)
8703                  && gimple_purge_dead_eh_edges (bb))

the statement is correctly identified as nonthrowing but edges are removed,
because it is not in EH region.

It is created by:
#0  0x0000000000921eb5 in gimple_copy (stmt=0x7ffff68e0e58) at
../../gcc/gimple.c:1687
#1  0x0000000000f96735 in gimple_ic (icall_stmt=0x7ffff68e0e58,
direct_call=0x7ffff68e6498, prob=8000, count=0, all=0) at
../../gcc/value-prof.c:1439
#2  0x00000000007976f2 in cgraph_edge::redirect_call_stmt_to_callee
(this=0x7ffff6adf7b8) at ../../gcc/cgraph.c:1336
#3  0x000000000155a53a in inline_transform (node=0x7ffff6ae57a8) at
../../gcc/ipa-inline-transform.c:529

later the EH is copied but only if stmt can throw:

  /* Build an EH edge for the direct call if necessary.  */                     
  lp_nr = lookup_stmt_eh_lp (icall_stmt);                                       
  if (lp_nr > 0 && stmt_could_throw_p (dcall_stmt))                             
    {                                                                           
      add_stmt_to_eh_lp (dcall_stmt, lp_nr);                                    
    }                                                                           

I suppose we want to purge EH edges in case we did not copy the EH region.

Index: value-prof.c
===================================================================
--- value-prof.c        (revision 221223)
+++ value-prof.c        (working copy)
@@ -1576,6 +1576,8 @@ gimple_ic (gcall *icall_stmt, struct cgr
                     PHI_ARG_DEF_FROM_EDGE (phi, e_eh));
          }
        }
+  if (!stmt_could_throw_p (dcall_stmt))
+    gimple_purge_dead_eh_edges (dcall_bb);
   return dcall_stmt;
 }

Reply via email to