On Wed, Jan 03, 2018 at 01:27:01PM +0100, Martin Liška wrote:
>                       /* Reading the final '\0' character.  */
>                       tree zero = build_int_cst (TREE_TYPE (lhs), 0);
>                       gimple_set_vuse (stmt, NULL_TREE);
>                       gimple_assign_set_rhs_from_tree (gsi, zero);
> +                     *cleanup_eh = maybe_clean_or_replace_eh_stmt (stmt,
> +                                                                   stmt);

The second stmt should be gsi_stmt (*gsi) just in case
gimple_assign_set_rhs_from_tree can't modify in-place, and probably you need
                        *cleanup_eh
                          = maybe_clean_or_replace_eh_stmt (stmt,
                                                            gsi_stmt (*gsi));
then to get formatting right.

>                       update_stmt (gsi_stmt (*gsi));
> +
> +                     if (dump_file && (dump_flags & TDF_DETAILS) != 0)
> +                       {
> +                         fprintf (dump_file, "into: ");
> +                         print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);

Again, should be gsi_stmt (*gsi);.  Or do:
stmt = gsi_stmt (*gsi);
above update_stmt.  As stmt is used several times later, I think that is my
preference (though, in maybe_clean_or_replace_eh_stmt call you IMHO still want
gsi_stmt repeated).

> +                       }
>                     }
>                   else if (w1 > w2)
>                     {
> @@ -3399,11 +3416,16 @@ strlen_dom_walker::before_dom_children (basic_block 
> bb)
>       }
>      }
>  
> +  bool cleanup_eh = false;
> +
>    /* Attempt to optimize individual statements.  */
>    for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); )
> -    if (strlen_check_and_optimize_stmt (&gsi))
> +    if (strlen_check_and_optimize_stmt (&gsi, &cleanup_eh))
>        gsi_next (&gsi);
>  
> +  if (cleanup_eh)
> +    gimple_purge_dead_eh_edges (bb);

If gimple_purge_dead_eh_edges returns true, you want to arrange for the
pass to return TODO_cleanup_cfg (probably needs to use some global static
variable to propagate that).

        Jakub

Reply via email to