From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id A9F05385840E; Sat, 21 Oct 2023 03:48:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9F05385840E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697860126; bh=DfJI2t8wlGEf9W0tQTj2hz4wQA91CNh6pFTywbtjOZ0=; h=From:To:Subject:Date:From; b=Eag62aa4zufl8uIMm0jb7uQc6nNsVowUFvWdMcT9VcDZvYAW/NC9otMMXKLhZJ5Q4 l3ZAsiQPuEDfyei7Y+kPqYdje1sM7/fsSd+Q4hReRMvu81b25ENyw1kzeTQ5J3ogds l7J8RtOBXZdUoWPQ9Sk2Rg/6VO4oGEMgf0FPzPeE= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] set hardcmp eh probs X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: abbba098e8d5137249c492ddd5cb1ac7186a4464 X-Git-Newrev: 5c5be482ff00ae0dbfb71f6d2ad09930ac44fce8 Message-Id: <20231021034846.A9F05385840E@sourceware.org> Date: Sat, 21 Oct 2023 03:48:46 +0000 (GMT) List-Id: https://gcc.gnu.org/g:5c5be482ff00ae0dbfb71f6d2ad09930ac44fce8 commit 5c5be482ff00ae0dbfb71f6d2ad09930ac44fce8 Author: Alexandre Oliva Date: Sat Oct 21 00:30:33 2023 -0300 set hardcmp eh probs Diff: --- gcc/gimple-harden-conditionals.cc | 12 +++++++++++- gcc/testsuite/g++.dg/torture/harden-comp-pr111520.cc | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/gcc/gimple-harden-conditionals.cc b/gcc/gimple-harden-conditionals.cc index 1999e827a04c..bded28898506 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 000000000000..b4381b4d84ec --- /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; +}