public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] return edge in make_eh_edges
@ 2023-10-19  7:58 Alexandre Oliva
  2023-10-19  9:09 ` Richard Biener
  0 siblings, 1 reply; 8+ messages in thread
From: Alexandre Oliva @ 2023-10-19  7:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: hubicka


The need to initialize edge probabilities has made make_eh_edges
undesirably hard to use.  I suppose we don't want make_eh_edges to
initialize the probability of the newly-added edge itself, so that the
caller takes care of it, but identifying the added edge in need of
adjustments is inefficient and cumbersome.  Change make_eh_edges so
that it returns the added edge.

Regstrapped on x86_64-linux-gnu, and (along with various hardening
patches) on ppc64el-linux-gnu.  Also tested on multiple other targets,
on older versions of GCC.  The returned value is unused in code already
in the compiler.  This is a preparatory patch for uses to be introduced
along with stack scrubbing and control flow redundancy.  Ok to install?


for  gcc/ChangeLog

	* tree-eh.cc (make_eh_edges): Return the new edge.
	* tree-eh.h (make_eh_edges): Likewise.
---
 gcc/tree-eh.cc |    6 +++---
 gcc/tree-eh.h  |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc
index e8ceff36cc6e7..1cb8e08652909 100644
--- a/gcc/tree-eh.cc
+++ b/gcc/tree-eh.cc
@@ -2274,7 +2274,7 @@ make_eh_dispatch_edges (geh_dispatch *stmt)
 /* Create the single EH edge from STMT to its nearest landing pad,
    if there is such a landing pad within the current function.  */
 
-void
+edge
 make_eh_edges (gimple *stmt)
 {
   basic_block src, dst;
@@ -2283,14 +2283,14 @@ make_eh_edges (gimple *stmt)
 
   lp_nr = lookup_stmt_eh_lp (stmt);
   if (lp_nr <= 0)
-    return;
+    return NULL;
 
   lp = get_eh_landing_pad_from_number (lp_nr);
   gcc_assert (lp != NULL);
 
   src = gimple_bb (stmt);
   dst = label_to_block (cfun, lp->post_landing_pad);
-  make_edge (src, dst, EDGE_EH);
+  return make_edge (src, dst, EDGE_EH);
 }
 
 /* Do the work in redirecting EDGE_IN to NEW_BB within the EH region tree;
diff --git a/gcc/tree-eh.h b/gcc/tree-eh.h
index 771be50fe9a1d..1382568b7c919 100644
--- a/gcc/tree-eh.h
+++ b/gcc/tree-eh.h
@@ -30,7 +30,7 @@ extern bool remove_stmt_from_eh_lp (gimple *);
 extern int lookup_stmt_eh_lp_fn (struct function *, const gimple *);
 extern int lookup_stmt_eh_lp (const gimple *);
 extern bool make_eh_dispatch_edges (geh_dispatch *);
-extern void make_eh_edges (gimple *);
+extern edge make_eh_edges (gimple *);
 extern edge redirect_eh_edge (edge, basic_block);
 extern void redirect_eh_dispatch_edge (geh_dispatch *, edge, basic_block);
 extern bool operation_could_trap_helper_p (enum tree_code, bool, bool, bool,


-- 
Alexandre Oliva, happy hacker            https://FSFLA.org/blogs/lxo/
   Free Software Activist                   GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity
Excluding neuro-others for not behaving ""normal"" is *not* inclusive

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] return edge in make_eh_edges
  2023-10-19  7:58 [PATCH] return edge in make_eh_edges Alexandre Oliva
@ 2023-10-19  9:09 ` Richard Biener
  2023-10-20  3:34   ` Alexandre Oliva
  2023-10-20  6:09   ` [PATCH] rename make_eh_edges to make_eh_edge (was: return edge in make_eh_edges) Alexandre Oliva
  0 siblings, 2 replies; 8+ messages in thread
From: Richard Biener @ 2023-10-19  9:09 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: gcc-patches, hubicka

On Thu, Oct 19, 2023 at 9:59 AM Alexandre Oliva <oliva@adacore.com> wrote:
>
>
> The need to initialize edge probabilities has made make_eh_edges
> undesirably hard to use.  I suppose we don't want make_eh_edges to
> initialize the probability of the newly-added edge itself, so that the
> caller takes care of it, but identifying the added edge in need of
> adjustments is inefficient and cumbersome.  Change make_eh_edges so
> that it returns the added edge.
>
> Regstrapped on x86_64-linux-gnu, and (along with various hardening
> patches) on ppc64el-linux-gnu.  Also tested on multiple other targets,
> on older versions of GCC.  The returned value is unused in code already
> in the compiler.  This is a preparatory patch for uses to be introduced
> along with stack scrubbing and control flow redundancy.  Ok to install?

OK.  Maybe time to do s/make_eh_edges/make_eh_edge/ though.

Richard.

>
> for  gcc/ChangeLog
>
>         * tree-eh.cc (make_eh_edges): Return the new edge.
>         * tree-eh.h (make_eh_edges): Likewise.
> ---
>  gcc/tree-eh.cc |    6 +++---
>  gcc/tree-eh.h  |    2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc
> index e8ceff36cc6e7..1cb8e08652909 100644
> --- a/gcc/tree-eh.cc
> +++ b/gcc/tree-eh.cc
> @@ -2274,7 +2274,7 @@ make_eh_dispatch_edges (geh_dispatch *stmt)
>  /* Create the single EH edge from STMT to its nearest landing pad,
>     if there is such a landing pad within the current function.  */
>
> -void
> +edge
>  make_eh_edges (gimple *stmt)
>  {
>    basic_block src, dst;
> @@ -2283,14 +2283,14 @@ make_eh_edges (gimple *stmt)
>
>    lp_nr = lookup_stmt_eh_lp (stmt);
>    if (lp_nr <= 0)
> -    return;
> +    return NULL;
>
>    lp = get_eh_landing_pad_from_number (lp_nr);
>    gcc_assert (lp != NULL);
>
>    src = gimple_bb (stmt);
>    dst = label_to_block (cfun, lp->post_landing_pad);
> -  make_edge (src, dst, EDGE_EH);
> +  return make_edge (src, dst, EDGE_EH);
>  }
>
>  /* Do the work in redirecting EDGE_IN to NEW_BB within the EH region tree;
> diff --git a/gcc/tree-eh.h b/gcc/tree-eh.h
> index 771be50fe9a1d..1382568b7c919 100644
> --- a/gcc/tree-eh.h
> +++ b/gcc/tree-eh.h
> @@ -30,7 +30,7 @@ extern bool remove_stmt_from_eh_lp (gimple *);
>  extern int lookup_stmt_eh_lp_fn (struct function *, const gimple *);
>  extern int lookup_stmt_eh_lp (const gimple *);
>  extern bool make_eh_dispatch_edges (geh_dispatch *);
> -extern void make_eh_edges (gimple *);
> +extern edge make_eh_edges (gimple *);
>  extern edge redirect_eh_edge (edge, basic_block);
>  extern void redirect_eh_dispatch_edge (geh_dispatch *, edge, basic_block);
>  extern bool operation_could_trap_helper_p (enum tree_code, bool, bool, bool,
>
>
> --
> Alexandre Oliva, happy hacker            https://FSFLA.org/blogs/lxo/
>    Free Software Activist                   GNU Toolchain Engineer
> More tolerance and less prejudice are key for inclusion and diversity
> Excluding neuro-others for not behaving ""normal"" is *not* inclusive

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] return edge in make_eh_edges
  2023-10-19  9:09 ` Richard Biener
@ 2023-10-20  3:34   ` Alexandre Oliva
  2023-10-20  6:09   ` [PATCH] rename make_eh_edges to make_eh_edge (was: return edge in make_eh_edges) Alexandre Oliva
  1 sibling, 0 replies; 8+ messages in thread
From: Alexandre Oliva @ 2023-10-20  3:34 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches, hubicka

On Oct 19, 2023, Richard Biener <richard.guenther@gmail.com> wrote:

> OK.  Maybe time to do s/make_eh_edges/make_eh_edge/ though.

Thanks, will do, ideally on top of the already-tested refreshed patches
that I'm going to post shortly.

-- 
Alexandre Oliva, happy hacker            https://FSFLA.org/blogs/lxo/
   Free Software Activist                   GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity
Excluding neuro-others for not behaving ""normal"" is *not* inclusive

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] rename make_eh_edges to make_eh_edge (was: return edge in make_eh_edges)
  2023-10-19  9:09 ` Richard Biener
  2023-10-20  3:34   ` Alexandre Oliva
@ 2023-10-20  6:09   ` Alexandre Oliva
  2023-10-20  6:34     ` Richard Biener
  1 sibling, 1 reply; 8+ messages in thread
From: Alexandre Oliva @ 2023-10-20  6:09 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches, hubicka

On Oct 19, 2023, Richard Biener <richard.guenther@gmail.com> wrote:

> Maybe time to do s/make_eh_edges/make_eh_edge/ though.

How about this?  Regstrapped on x86_64-linux-gnu and ppc64le-linux-gnu,
on top of the patches for strub, hardbool, and hardcfr that I've just
posted.  Ok to install?

----

Since make_eh_edges creates at most one edge, rename it to
make_eh_edge.


for  gcc/ChangeLog

	* tree-eh.h (make_eh_edges): Rename to...
	(make_eh_edge): ... this.
	* tree-eh.cc: Likewise.  Adjust all callers.
---
 gcc/gimple-harden-conditionals.cc |    2 +-
 gcc/gimple-harden-control-flow.cc |    2 +-
 gcc/ipa-strub.cc                  |    2 +-
 gcc/tree-cfg.cc                   |    6 +++---
 gcc/tree-eh.cc                    |    4 ++--
 gcc/tree-eh.h                     |    2 +-
 gcc/tree-inline.cc                |    2 +-
 7 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/gcc/gimple-harden-conditionals.cc b/gcc/gimple-harden-conditionals.cc
index a299b984375cd..1999e827a04ca 100644
--- a/gcc/gimple-harden-conditionals.cc
+++ b/gcc/gimple-harden-conditionals.cc
@@ -580,7 +580,7 @@ pass_harden_compares::execute (function *fun)
 	  if (throwing_compare_p)
 	    {
 	      add_stmt_to_eh_lp (asgnck, lookup_stmt_eh_lp (asgn));
-	      make_eh_edges (asgnck);
+	      make_eh_edge (asgnck);
 
 	      edge ckeh;
 	      basic_block nbb = split_edge (non_eh_succ_edge
diff --git a/gcc/gimple-harden-control-flow.cc b/gcc/gimple-harden-control-flow.cc
index 5c28fd07f3329..7b69281bffc0b 100644
--- a/gcc/gimple-harden-control-flow.cc
+++ b/gcc/gimple-harden-control-flow.cc
@@ -1285,7 +1285,7 @@ pass_harden_control_flow_redundancy::execute (function *fun)
 
 	      add_stmt_to_eh_lp (stmt, lp_eh_cleanup);
 	      /* Finally, wire the EH cleanup block into the CFG.  */
-	      edge neeh = make_eh_edges (stmt);
+	      edge neeh = make_eh_edge (stmt);
 	      neeh->probability = profile_probability::never ();
 	      gcc_checking_assert (neeh->dest == bb_eh_cleanup);
 	      if (neeh->dest->count.initialized_p ())
diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc
index 612ece9f18552..e944fe1d1101d 100644
--- a/gcc/ipa-strub.cc
+++ b/gcc/ipa-strub.cc
@@ -2075,7 +2075,7 @@ gsi_insert_finally_seq_after_call (gimple_stmt_iterator gsi, gimple_seq seq)
   gsi_insert_before (&gsi, resx, GSI_SAME_STMT);
 
   /* Finally, wire the EH cleanup block into the CFG.  */
-  edge neeh = make_eh_edges (stmt);
+  edge neeh = make_eh_edge (stmt);
   neeh->probability = profile_probability::never ();
   gcc_checking_assert (neeh->dest == bb_eh_cleanup);
   gcc_checking_assert (!neeh->dest->count.initialized_p ());
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index f748ca8508940..d41b80d93b6e7 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -878,7 +878,7 @@ make_edges_bb (basic_block bb, struct omp_region **pcur_region, int *pomp_index)
       fallthru = false;
       break;
     case GIMPLE_RESX:
-      make_eh_edges (last);
+      make_eh_edge (last);
       fallthru = false;
       break;
     case GIMPLE_EH_DISPATCH:
@@ -894,7 +894,7 @@ make_edges_bb (basic_block bb, struct omp_region **pcur_region, int *pomp_index)
 
       /* If this statement has reachable exception handlers, then
 	 create abnormal edges to them.  */
-      make_eh_edges (last);
+      make_eh_edge (last);
 
       /* BUILTIN_RETURN is really a return statement.  */
       if (gimple_call_builtin_p (last, BUILT_IN_RETURN))
@@ -911,7 +911,7 @@ make_edges_bb (basic_block bb, struct omp_region **pcur_region, int *pomp_index)
       /* A GIMPLE_ASSIGN may throw internally and thus be considered
 	 control-altering.  */
       if (is_ctrl_altering_stmt (last))
-	make_eh_edges (last);
+	make_eh_edge (last);
       fallthru = true;
       break;
 
diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc
index 1cb8e08652909..6a30ed9d2b8a6 100644
--- a/gcc/tree-eh.cc
+++ b/gcc/tree-eh.cc
@@ -2275,7 +2275,7 @@ make_eh_dispatch_edges (geh_dispatch *stmt)
    if there is such a landing pad within the current function.  */
 
 edge
-make_eh_edges (gimple *stmt)
+make_eh_edge (gimple *stmt)
 {
   basic_block src, dst;
   eh_landing_pad lp;
@@ -4921,7 +4921,7 @@ make_pass_cleanup_eh (gcc::context *ctxt)
 #endif
 
 /* Verify that BB containing STMT as the last statement, has precisely the
-   edge that make_eh_edges would create.  */
+   edge that make_eh_edge would create.  */
 
 DEBUG_FUNCTION bool
 verify_eh_edges (gimple *stmt)
diff --git a/gcc/tree-eh.h b/gcc/tree-eh.h
index 1382568b7c919..045424fe6ece3 100644
--- a/gcc/tree-eh.h
+++ b/gcc/tree-eh.h
@@ -30,7 +30,7 @@ extern bool remove_stmt_from_eh_lp (gimple *);
 extern int lookup_stmt_eh_lp_fn (struct function *, const gimple *);
 extern int lookup_stmt_eh_lp (const gimple *);
 extern bool make_eh_dispatch_edges (geh_dispatch *);
-extern edge make_eh_edges (gimple *);
+extern edge make_eh_edge (gimple *);
 extern edge redirect_eh_edge (edge, basic_block);
 extern void redirect_eh_dispatch_edge (geh_dispatch *, edge, basic_block);
 extern bool operation_could_trap_helper_p (enum tree_code, bool, bool, bool,
diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index d63060c9429c4..867f3b22b589a 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -2615,7 +2615,7 @@ copy_edges_for_bb (basic_block bb, profile_count num, profile_count den,
 	}
       else if (can_throw)
 	{
-	  make_eh_edges (copy_stmt);
+	  make_eh_edge (copy_stmt);
 	  update_probs = true;
 	}
 


-- 
Alexandre Oliva, happy hacker            https://FSFLA.org/blogs/lxo/
   Free Software Activist                   GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity
Excluding neuro-others for not behaving ""normal"" is *not* inclusive

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] rename make_eh_edges to make_eh_edge (was: return edge in make_eh_edges)
  2023-10-20  6:09   ` [PATCH] rename make_eh_edges to make_eh_edge (was: return edge in make_eh_edges) Alexandre Oliva
@ 2023-10-20  6:34     ` Richard Biener
  2023-10-21  7:17       ` [PATCH] [PR111520] set hardcmp eh probs (was: rename make_eh_edges to make_eh_edge) Alexandre Oliva
  2023-10-26  6:23       ` [PATCH] rename make_eh_edges to make_eh_edge Alexandre Oliva
  0 siblings, 2 replies; 8+ messages in thread
From: Richard Biener @ 2023-10-20  6:34 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: gcc-patches, hubicka

On Fri, Oct 20, 2023 at 8:09 AM Alexandre Oliva <oliva@adacore.com> wrote:
>
> On Oct 19, 2023, Richard Biener <richard.guenther@gmail.com> wrote:
>
> > Maybe time to do s/make_eh_edges/make_eh_edge/ though.
>
> How about this?  Regstrapped on x86_64-linux-gnu and ppc64le-linux-gnu,
> on top of the patches for strub, hardbool, and hardcfr that I've just
> posted.  Ok to install?

OK.

Richard.

> ----
>
> Since make_eh_edges creates at most one edge, rename it to
> make_eh_edge.
>
>
> for  gcc/ChangeLog
>
>         * tree-eh.h (make_eh_edges): Rename to...
>         (make_eh_edge): ... this.
>         * tree-eh.cc: Likewise.  Adjust all callers.
> ---
>  gcc/gimple-harden-conditionals.cc |    2 +-
>  gcc/gimple-harden-control-flow.cc |    2 +-
>  gcc/ipa-strub.cc                  |    2 +-
>  gcc/tree-cfg.cc                   |    6 +++---
>  gcc/tree-eh.cc                    |    4 ++--
>  gcc/tree-eh.h                     |    2 +-
>  gcc/tree-inline.cc                |    2 +-
>  7 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/gcc/gimple-harden-conditionals.cc b/gcc/gimple-harden-conditionals.cc
> index a299b984375cd..1999e827a04ca 100644
> --- a/gcc/gimple-harden-conditionals.cc
> +++ b/gcc/gimple-harden-conditionals.cc
> @@ -580,7 +580,7 @@ pass_harden_compares::execute (function *fun)
>           if (throwing_compare_p)
>             {
>               add_stmt_to_eh_lp (asgnck, lookup_stmt_eh_lp (asgn));
> -             make_eh_edges (asgnck);
> +             make_eh_edge (asgnck);
>
>               edge ckeh;
>               basic_block nbb = split_edge (non_eh_succ_edge
> diff --git a/gcc/gimple-harden-control-flow.cc b/gcc/gimple-harden-control-flow.cc
> index 5c28fd07f3329..7b69281bffc0b 100644
> --- a/gcc/gimple-harden-control-flow.cc
> +++ b/gcc/gimple-harden-control-flow.cc
> @@ -1285,7 +1285,7 @@ pass_harden_control_flow_redundancy::execute (function *fun)
>
>               add_stmt_to_eh_lp (stmt, lp_eh_cleanup);
>               /* Finally, wire the EH cleanup block into the CFG.  */
> -             edge neeh = make_eh_edges (stmt);
> +             edge neeh = make_eh_edge (stmt);
>               neeh->probability = profile_probability::never ();
>               gcc_checking_assert (neeh->dest == bb_eh_cleanup);
>               if (neeh->dest->count.initialized_p ())
> diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc
> index 612ece9f18552..e944fe1d1101d 100644
> --- a/gcc/ipa-strub.cc
> +++ b/gcc/ipa-strub.cc
> @@ -2075,7 +2075,7 @@ gsi_insert_finally_seq_after_call (gimple_stmt_iterator gsi, gimple_seq seq)
>    gsi_insert_before (&gsi, resx, GSI_SAME_STMT);
>
>    /* Finally, wire the EH cleanup block into the CFG.  */
> -  edge neeh = make_eh_edges (stmt);
> +  edge neeh = make_eh_edge (stmt);
>    neeh->probability = profile_probability::never ();
>    gcc_checking_assert (neeh->dest == bb_eh_cleanup);
>    gcc_checking_assert (!neeh->dest->count.initialized_p ());
> diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
> index f748ca8508940..d41b80d93b6e7 100644
> --- a/gcc/tree-cfg.cc
> +++ b/gcc/tree-cfg.cc
> @@ -878,7 +878,7 @@ make_edges_bb (basic_block bb, struct omp_region **pcur_region, int *pomp_index)
>        fallthru = false;
>        break;
>      case GIMPLE_RESX:
> -      make_eh_edges (last);
> +      make_eh_edge (last);
>        fallthru = false;
>        break;
>      case GIMPLE_EH_DISPATCH:
> @@ -894,7 +894,7 @@ make_edges_bb (basic_block bb, struct omp_region **pcur_region, int *pomp_index)
>
>        /* If this statement has reachable exception handlers, then
>          create abnormal edges to them.  */
> -      make_eh_edges (last);
> +      make_eh_edge (last);
>
>        /* BUILTIN_RETURN is really a return statement.  */
>        if (gimple_call_builtin_p (last, BUILT_IN_RETURN))
> @@ -911,7 +911,7 @@ make_edges_bb (basic_block bb, struct omp_region **pcur_region, int *pomp_index)
>        /* A GIMPLE_ASSIGN may throw internally and thus be considered
>          control-altering.  */
>        if (is_ctrl_altering_stmt (last))
> -       make_eh_edges (last);
> +       make_eh_edge (last);
>        fallthru = true;
>        break;
>
> diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc
> index 1cb8e08652909..6a30ed9d2b8a6 100644
> --- a/gcc/tree-eh.cc
> +++ b/gcc/tree-eh.cc
> @@ -2275,7 +2275,7 @@ make_eh_dispatch_edges (geh_dispatch *stmt)
>     if there is such a landing pad within the current function.  */
>
>  edge
> -make_eh_edges (gimple *stmt)
> +make_eh_edge (gimple *stmt)
>  {
>    basic_block src, dst;
>    eh_landing_pad lp;
> @@ -4921,7 +4921,7 @@ make_pass_cleanup_eh (gcc::context *ctxt)
>  #endif
>
>  /* Verify that BB containing STMT as the last statement, has precisely the
> -   edge that make_eh_edges would create.  */
> +   edge that make_eh_edge would create.  */
>
>  DEBUG_FUNCTION bool
>  verify_eh_edges (gimple *stmt)
> diff --git a/gcc/tree-eh.h b/gcc/tree-eh.h
> index 1382568b7c919..045424fe6ece3 100644
> --- a/gcc/tree-eh.h
> +++ b/gcc/tree-eh.h
> @@ -30,7 +30,7 @@ extern bool remove_stmt_from_eh_lp (gimple *);
>  extern int lookup_stmt_eh_lp_fn (struct function *, const gimple *);
>  extern int lookup_stmt_eh_lp (const gimple *);
>  extern bool make_eh_dispatch_edges (geh_dispatch *);
> -extern edge make_eh_edges (gimple *);
> +extern edge make_eh_edge (gimple *);
>  extern edge redirect_eh_edge (edge, basic_block);
>  extern void redirect_eh_dispatch_edge (geh_dispatch *, edge, basic_block);
>  extern bool operation_could_trap_helper_p (enum tree_code, bool, bool, bool,
> diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
> index d63060c9429c4..867f3b22b589a 100644
> --- a/gcc/tree-inline.cc
> +++ b/gcc/tree-inline.cc
> @@ -2615,7 +2615,7 @@ copy_edges_for_bb (basic_block bb, profile_count num, profile_count den,
>         }
>        else if (can_throw)
>         {
> -         make_eh_edges (copy_stmt);
> +         make_eh_edge (copy_stmt);
>           update_probs = true;
>         }
>
>
>
> --
> Alexandre Oliva, happy hacker            https://FSFLA.org/blogs/lxo/
>    Free Software Activist                   GNU Toolchain Engineer
> More tolerance and less prejudice are key for inclusion and diversity
> Excluding neuro-others for not behaving ""normal"" is *not* inclusive

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] [PR111520] set hardcmp eh probs (was: rename make_eh_edges to make_eh_edge)
  2023-10-20  6:34     ` Richard Biener
@ 2023-10-21  7:17       ` Alexandre Oliva
  2023-10-23  7:59         ` Richard Biener
  2023-10-26  6:23       ` [PATCH] rename make_eh_edges to make_eh_edge Alexandre Oliva
  1 sibling, 1 reply; 8+ messages in thread
From: Alexandre Oliva @ 2023-10-21  7:17 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches, hubicka

On Oct 20, 2023, Richard Biener <richard.guenther@gmail.com> wrote:

>> * tree-eh.h (make_eh_edges): Rename to...
>> (make_eh_edge): ... this.
>> * tree-eh.cc: Likewise.  Adjust all callers.

Once the above goes in (it depends on the strub monster patch), the
following one should apply as well.  Regstrapped on x86_64-linux-gnu.
Ok to install?

Set execution count of EH blocks, and probability of EH edges.


for  gcc/ChangeLog

	PR tree-optimization/111520
	* gimple-harden-conditionals.cc
	(pass_harden_compares::execute): Set EH edge probability and
	EH block execution count.

for  gcc/testsuite/ChangeLog

	PR tree-optimization/111520
	* g++.dg/torture/harden-comp-pr111520.cc: New.
---
 gcc/gimple-harden-conditionals.cc                  |   12 +++++++++++-
 .../g++.dg/torture/harden-comp-pr111520.cc         |   17 +++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/torture/harden-comp-pr111520.cc

diff --git a/gcc/gimple-harden-conditionals.cc b/gcc/gimple-harden-conditionals.cc
index 1999e827a04ca..bded288985063 100644
--- a/gcc/gimple-harden-conditionals.cc
+++ b/gcc/gimple-harden-conditionals.cc
@@ -580,11 +580,21 @@ pass_harden_compares::execute (function *fun)
 	  if (throwing_compare_p)
 	    {
 	      add_stmt_to_eh_lp (asgnck, lookup_stmt_eh_lp (asgn));
-	      make_eh_edge (asgnck);
+	      edge eh = make_eh_edge (asgnck);
+	      /* This compare looks like it could raise an exception,
+		 but it's dominated by the original compare, that
+		 would raise an exception first, so the EH edge from
+		 this one is never really taken.  */
+	      eh->probability = profile_probability::never ();
+	      if (eh->dest->count.initialized_p ())
+		eh->dest->count += eh->count ();
+	      else
+		eh->dest->count = eh->count ();
 
 	      edge ckeh;
 	      basic_block nbb = split_edge (non_eh_succ_edge
 					    (gimple_bb (asgnck), &ckeh));
+	      gcc_checking_assert (eh == ckeh);
 	      gsi_split = gsi_start_bb (nbb);
 
 	      if (dump_file)
diff --git a/gcc/testsuite/g++.dg/torture/harden-comp-pr111520.cc b/gcc/testsuite/g++.dg/torture/harden-comp-pr111520.cc
new file mode 100644
index 0000000000000..b4381b4d84ec4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/harden-comp-pr111520.cc
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-fharden-compares -fsignaling-nans -fnon-call-exceptions" } */
+
+struct S
+{
+  S (bool);
+  ~S ();
+};
+
+float f;
+
+void
+foo ()
+{
+  S a = 0;
+  S b = f;
+}


-- 
Alexandre Oliva, happy hacker            https://FSFLA.org/blogs/lxo/
   Free Software Activist                   GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity
Excluding neuro-others for not behaving ""normal"" is *not* inclusive

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [PR111520] set hardcmp eh probs (was: rename make_eh_edges to make_eh_edge)
  2023-10-21  7:17       ` [PATCH] [PR111520] set hardcmp eh probs (was: rename make_eh_edges to make_eh_edge) Alexandre Oliva
@ 2023-10-23  7:59         ` Richard Biener
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Biener @ 2023-10-23  7:59 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: gcc-patches, hubicka

On Sat, Oct 21, 2023 at 9:17 AM Alexandre Oliva <oliva@adacore.com> wrote:
>
> On Oct 20, 2023, Richard Biener <richard.guenther@gmail.com> wrote:
>
> >> * tree-eh.h (make_eh_edges): Rename to...
> >> (make_eh_edge): ... this.
> >> * tree-eh.cc: Likewise.  Adjust all callers.
>
> Once the above goes in (it depends on the strub monster patch), the
> following one should apply as well.  Regstrapped on x86_64-linux-gnu.
> Ok to install?

OK.

> Set execution count of EH blocks, and probability of EH edges.
>
>
> for  gcc/ChangeLog
>
>         PR tree-optimization/111520
>         * gimple-harden-conditionals.cc
>         (pass_harden_compares::execute): Set EH edge probability and
>         EH block execution count.
>
> for  gcc/testsuite/ChangeLog
>
>         PR tree-optimization/111520
>         * g++.dg/torture/harden-comp-pr111520.cc: New.
> ---
>  gcc/gimple-harden-conditionals.cc                  |   12 +++++++++++-
>  .../g++.dg/torture/harden-comp-pr111520.cc         |   17 +++++++++++++++++
>  2 files changed, 28 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/g++.dg/torture/harden-comp-pr111520.cc
>
> diff --git a/gcc/gimple-harden-conditionals.cc b/gcc/gimple-harden-conditionals.cc
> index 1999e827a04ca..bded288985063 100644
> --- a/gcc/gimple-harden-conditionals.cc
> +++ b/gcc/gimple-harden-conditionals.cc
> @@ -580,11 +580,21 @@ pass_harden_compares::execute (function *fun)
>           if (throwing_compare_p)
>             {
>               add_stmt_to_eh_lp (asgnck, lookup_stmt_eh_lp (asgn));
> -             make_eh_edge (asgnck);
> +             edge eh = make_eh_edge (asgnck);
> +             /* This compare looks like it could raise an exception,
> +                but it's dominated by the original compare, that
> +                would raise an exception first, so the EH edge from
> +                this one is never really taken.  */
> +             eh->probability = profile_probability::never ();
> +             if (eh->dest->count.initialized_p ())
> +               eh->dest->count += eh->count ();
> +             else
> +               eh->dest->count = eh->count ();
>
>               edge ckeh;
>               basic_block nbb = split_edge (non_eh_succ_edge
>                                             (gimple_bb (asgnck), &ckeh));
> +             gcc_checking_assert (eh == ckeh);
>               gsi_split = gsi_start_bb (nbb);
>
>               if (dump_file)
> diff --git a/gcc/testsuite/g++.dg/torture/harden-comp-pr111520.cc b/gcc/testsuite/g++.dg/torture/harden-comp-pr111520.cc
> new file mode 100644
> index 0000000000000..b4381b4d84ec4
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/torture/harden-comp-pr111520.cc
> @@ -0,0 +1,17 @@
> +/* { dg-do compile } */
> +/* { dg-options "-fharden-compares -fsignaling-nans -fnon-call-exceptions" } */
> +
> +struct S
> +{
> +  S (bool);
> +  ~S ();
> +};
> +
> +float f;
> +
> +void
> +foo ()
> +{
> +  S a = 0;
> +  S b = f;
> +}
>
>
> --
> Alexandre Oliva, happy hacker            https://FSFLA.org/blogs/lxo/
>    Free Software Activist                   GNU Toolchain Engineer
> More tolerance and less prejudice are key for inclusion and diversity
> Excluding neuro-others for not behaving ""normal"" is *not* inclusive

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] rename make_eh_edges to make_eh_edge
  2023-10-20  6:34     ` Richard Biener
  2023-10-21  7:17       ` [PATCH] [PR111520] set hardcmp eh probs (was: rename make_eh_edges to make_eh_edge) Alexandre Oliva
@ 2023-10-26  6:23       ` Alexandre Oliva
  1 sibling, 0 replies; 8+ messages in thread
From: Alexandre Oliva @ 2023-10-26  6:23 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches, hubicka

On Oct 20, 2023, Richard Biener <richard.guenther@gmail.com> wrote:

> OK.

Thanks.

>> * tree-eh.h (make_eh_edges): Rename to...
>> (make_eh_edge): ... this.
>> * tree-eh.cc: Likewise.  Adjust all callers.

Ugh, "Adjust all callers" is no longer enough, all files need to be
mentioned explicitly.  So I'm pushing it with:

	* tree-eh.h (make_eh_edges): Rename to...
	(make_eh_edge): ... this.
	* tree-eh.cc: Likewise.  Adjust all callers...
	* gimple-harden-conditionals.cc: ... here, ...
	* gimple-harden-control-flow.cc: ... here, ...
	* tree-cfg.cc: ... here, ...
	* tree-inline.cc: ... and here.

The ipa-strub.cc is now part of the strub patch.

-- 
Alexandre Oliva, happy hacker            https://FSFLA.org/blogs/lxo/
   Free Software Activist                   GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity
Excluding neuro-others for not behaving ""normal"" is *not* inclusive

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-10-26  6:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-19  7:58 [PATCH] return edge in make_eh_edges Alexandre Oliva
2023-10-19  9:09 ` Richard Biener
2023-10-20  3:34   ` Alexandre Oliva
2023-10-20  6:09   ` [PATCH] rename make_eh_edges to make_eh_edge (was: return edge in make_eh_edges) Alexandre Oliva
2023-10-20  6:34     ` Richard Biener
2023-10-21  7:17       ` [PATCH] [PR111520] set hardcmp eh probs (was: rename make_eh_edges to make_eh_edge) Alexandre Oliva
2023-10-23  7:59         ` Richard Biener
2023-10-26  6:23       ` [PATCH] rename make_eh_edges to make_eh_edge Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).