diff options
author | Alexandre Oliva <oliva@adacore.com> | 2023-10-26 03:06:09 -0300 |
---|---|---|
committer | Alexandre Oliva <oliva@gnu.org> | 2023-10-26 03:19:29 -0300 |
commit | 33d38b431cced81e575b1d17d36cb9e43d64b02b (patch) | |
tree | 365f6ba460c3dde9093fcc388de01115b37955dc /gcc | |
parent | 2f398d148a793282d11f9ab63da987728c2daf4f (diff) | |
download | gcc-33d38b431cced81e575b1d17d36cb9e43d64b02b.zip gcc-33d38b431cced81e575b1d17d36cb9e43d64b02b.tar.gz gcc-33d38b431cced81e575b1d17d36cb9e43d64b02b.tar.bz2 |
set hardcmp eh probs
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/gimple-harden-conditionals.cc | 12 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/torture/harden-comp-pr111520.cc | 17 |
2 files changed, 28 insertions, 1 deletions
diff --git a/gcc/gimple-harden-conditionals.cc b/gcc/gimple-harden-conditionals.cc index 1999e82..bded288 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 0000000..b4381b4 --- /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; +} |