From: Richard Biener <richard.guenther@gmail.com>
To: Alexander Monakov <amonakov@ispras.ru>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 3/3] tree-cfg: check placement of returns_twice calls
Date: Mon, 17 Jan 2022 09:12:33 +0100 [thread overview]
Message-ID: <CAFiYyc11YfRqtddJfuhn0aE5QRSMFqcrwWqxHO8N77-z-w_i6A@mail.gmail.com> (raw)
In-Reply-To: <20220114182047.6270-4-amonakov@ispras.ru>
On Fri, Jan 14, 2022 at 7:21 PM Alexander Monakov <amonakov@ispras.ru> wrote:
>
> When a returns_twice call has an associated abnormal edge, the edge
> corresponds to the "second return" from the call. It wouldn't make sense
> if any executable statements appeared between the call and the
> destination of the edge (they wouldn't be re-executed upon the "second
> return"), so verify that.
OK for next stage1.
Thanks,
Richard.
> gcc/ChangeLog:
>
> * tree-cfg.c (gimple_verify_flow_info): Check placement of
> returns_twice calls.
> ---
> gcc/tree-cfg.c | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
> index a99f1acb4..70bd31d3d 100644
> --- a/gcc/tree-cfg.c
> +++ b/gcc/tree-cfg.c
> @@ -5644,6 +5644,7 @@ gimple_verify_flow_info (void)
> }
>
> /* Verify that body of basic block BB is free of control flow. */
> + bool seen_nondebug_stmt = false;
> for (; !gsi_end_p (gsi); gsi_next (&gsi))
> {
> gimple *stmt = gsi_stmt (gsi);
> @@ -5664,6 +5665,38 @@ gimple_verify_flow_info (void)
> gimple_label_label (label_stmt), bb->index);
> err = 1;
> }
> +
> + /* Check that no statements appear between a returns_twice call
> + and its associated abnormal edge. */
> + if (gimple_code (stmt) == GIMPLE_CALL
> + && gimple_call_flags (stmt) & ECF_RETURNS_TWICE)
> + {
> + const char *misplaced = NULL;
> + /* TM is an exception: it points abnormal edges just after the
> + call that starts a transaction, i.e. it must end the BB. */
> + if (gimple_call_builtin_p (stmt, BUILT_IN_TM_START))
> + {
> + if (single_succ_p (bb)
> + && bb_has_abnormal_pred (single_succ (bb))
> + && !gsi_one_nondebug_before_end_p (gsi))
> + misplaced = "not last";
> + }
> + else
> + {
> + if (seen_nondebug_stmt
> + && bb_has_abnormal_pred (bb))
> + misplaced = "not first";
> + }
> + if (misplaced)
> + {
> + error ("returns_twice call is %s in basic block %d",
> + misplaced, bb->index);
> + print_gimple_stmt (stderr, stmt, 0, TDF_SLIM);
> + err = 1;
> + }
> + }
> + if (!is_gimple_debug (stmt))
> + seen_nondebug_stmt = true;
> }
>
> gsi = gsi_last_nondebug_bb (bb);
> --
> 2.33.1
>
prev parent reply other threads:[~2022-01-17 8:12 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-13 14:25 [RFC PATCH] tree-ssa-sink: do not sink to in front of setjmp Alexander Monakov
2021-12-13 14:45 ` Richard Biener
2021-12-13 15:20 ` Alexander Monakov
2021-12-14 11:10 ` Алексей Нурмухаметов
2022-01-03 13:41 ` Richard Biener
2022-01-03 16:35 ` Alexander Monakov
2022-01-04 7:25 ` Richard Biener
2022-01-14 18:20 ` Alexander Monakov
2022-01-14 18:20 ` [PATCH 1/3] " Alexander Monakov
2022-01-17 7:47 ` Richard Biener
2023-11-08 9:04 ` Florian Weimer
2023-11-08 10:01 ` Richard Biener
2023-11-08 13:06 ` Alexander Monakov
2022-01-14 18:20 ` [PATCH 2/3] tree-cfg: do not duplicate returns_twice calls Alexander Monakov
2022-01-17 8:08 ` Richard Biener
2022-07-12 20:10 ` Alexander Monakov
2022-07-13 7:13 ` Richard Biener
2022-07-13 14:57 ` Alexander Monakov
2022-07-14 6:38 ` Richard Biener
2022-07-14 20:12 ` Alexander Monakov
2022-07-19 8:40 ` Richard Biener
2022-07-19 20:00 ` Alexander Monakov
2022-07-13 16:01 ` Jeff Law
2022-01-14 18:20 ` [PATCH 3/3] tree-cfg: check placement of " Alexander Monakov
2022-01-17 8:12 ` Richard Biener [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFiYyc11YfRqtddJfuhn0aE5QRSMFqcrwWqxHO8N77-z-w_i6A@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=amonakov@ispras.ru \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).