From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id 4F4D23858402 for ; Mon, 17 Jan 2022 08:12:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4F4D23858402 Received: by mail-ed1-x536.google.com with SMTP id z22so62103846edd.12 for ; Mon, 17 Jan 2022 00:12:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+Ns+QJv4pBWmpDxVM+mCZfPFqvIKhdPYY9zgkpq/zuc=; b=b+mgfgTjRj8U6QDNEpmdLGc5oXf8nxi0P06x02dvWl8J/7l9NFkq2UMn6xfKj3ivoV dPZlo+rBEGx11J09Yb33P+j4RflW87D27eVFZ7/OE2HsFt18coP++miI1bSE6z57pkQd el2CLoq9n9Vxu7/ti2rvOXyIwJmDFhDA/KtsV05eI6Za/360Dczf/vH8C2rO9hAogHiZ K1uGm/yW9CsaXA5TGI7Z0qKjQji2ga+Z27DfnAr7PwG3ZDB/UY5T6jvgx1HBF0UBfJVQ LU2H11ZpbIS0XEX8hhwO7RFgY3nVZ7YKVQIrTGYXYZPH2dVoLqaiFZAmIfU9YAcl4nO1 JPBg== X-Gm-Message-State: AOAM53393nbR8DRdZ0tIaEAfUirNYM1gCQKsCmnyDoFw5r0BZvOHXhKx 2fqHHqCXPUfr0ihva1bfC8u1n7N4fDIwW+AjjvGCS90E X-Google-Smtp-Source: ABdhPJwd+L0OLjfwn1g6vjyucdSif6IqjlVL/rpRbMiFfKuvzNKH7MSPrezLcAMgwDeotpPmz//XIIEK5zL1GgFWZtw= X-Received: by 2002:a17:907:7f01:: with SMTP id qf1mr15570080ejc.240.1642407164223; Mon, 17 Jan 2022 00:12:44 -0800 (PST) MIME-Version: 1.0 References: <20220114182047.6270-4-amonakov@ispras.ru> In-Reply-To: <20220114182047.6270-4-amonakov@ispras.ru> From: Richard Biener Date: Mon, 17 Jan 2022 09:12:33 +0100 Message-ID: Subject: Re: [PATCH 3/3] tree-cfg: check placement of returns_twice calls To: Alexander Monakov Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Jan 2022 08:12:47 -0000 On Fri, Jan 14, 2022 at 7:21 PM Alexander Monakov 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 >