From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 331503858402 for ; Mon, 17 Jan 2022 08:08:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 331503858402 Received: by mail-ed1-x533.google.com with SMTP id q25so62089179edb.2 for ; Mon, 17 Jan 2022 00:08:41 -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=m6K3baSAPa6Pwkql5aO2cblFM+aAWGlbjL/1XaG7U/4=; b=ngP7+A2u3sCnVW7OonVm4KbuAaV25KLcXO4VemS4jSBk7yuBmWUWoxEyUAgm2+XL+0 sjN3Ju2hgTsRllthXQFZDJSrGK0F8iJk7VV7dCte78lK0AdDO3uwpj+/nRNek2oC6ZLe bOVwFNiwWMaSjJy3jU6jmTqUewUZJtqncpcrVoztxC48SJ2hQvp/cLN++nO1OP/sr0D5 OZG7pHJaO3mTtAKVBSXFFTIGkRbl1PtmrX3jCyhbO2Ch4d0AnhN2CJq2ttzLmu68tG3U fJuVpYEug0iPO4pM80/q1u7Id/B/JvCUKyoLzeByvXJ4/rHBznvUsUKvTKCzYPHbHtXb FR9Q== X-Gm-Message-State: AOAM532ZrECi6yHESw4TeOuUjfZlgZ51nS/xYdjh0WAzvlGmeV0Es5DW WxxskjJgNWUs9hR0dRv+F24LfvH7/O0gOWFlc5E= X-Google-Smtp-Source: ABdhPJwj4DJryIL5UbUp7Slw2fhCYAtI3IT4D76iqKxd8WtvHx5971xxS6Ps5++a5h0RYjO0iv/ndXZ10lj9RlHDGW0= X-Received: by 2002:a50:fc16:: with SMTP id i22mr6659688edr.345.1642406920123; Mon, 17 Jan 2022 00:08:40 -0800 (PST) MIME-Version: 1.0 References: <20220114182047.6270-3-amonakov@ispras.ru> In-Reply-To: <20220114182047.6270-3-amonakov@ispras.ru> From: Richard Biener Date: Mon, 17 Jan 2022 09:08:29 +0100 Message-ID: Subject: Re: [PATCH 2/3] tree-cfg: do not duplicate 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:08:44 -0000 On Fri, Jan 14, 2022 at 7:21 PM Alexander Monakov wrote: > > A returns_twice call may have associated abnormal edges that correspond > to the "second return" from the call. If the call is duplicated, the > copies of those edges also need to be abnormal, but e.g. tracer does not > enforce that. Just prohibit the (unlikely to be useful) duplication. The general CFG copying routines properly duplicate those edges, no? Tracer uses duplicate_block so it should also get copies of all successor edges of that block. It also only traces along normal edges. What it might miss is abnormal incoming edges - is that what you are referring to? That would be a thing we don't handle in duplicate_block on its own but that callers are expected to do (though I don't see copy_bbs doing that either). I wonder if we can trigger this issue for some testcase? The thing to check would be incoming abnormal edges in can_duplicate_block_p, not (only) returns twice functions? Richard. > gcc/ChangeLog: > > * tree-cfg.c (gimple_can_duplicate_bb_p): Reject blocks with > calls that may return twice. > --- > gcc/tree-cfg.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c > index b7fe313b7..a99f1acb4 100644 > --- a/gcc/tree-cfg.c > +++ b/gcc/tree-cfg.c > @@ -6304,12 +6304,15 @@ gimple_can_duplicate_bb_p (const_basic_block bb) > { > gimple *g = gsi_stmt (gsi); > > - /* An IFN_GOMP_SIMT_ENTER_ALLOC/IFN_GOMP_SIMT_EXIT call must be > + /* Prohibit duplication of returns_twice calls, otherwise associated > + abnormal edges also need to be duplicated properly. > + An IFN_GOMP_SIMT_ENTER_ALLOC/IFN_GOMP_SIMT_EXIT call must be > duplicated as part of its group, or not at all. > The IFN_GOMP_SIMT_VOTE_ANY and IFN_GOMP_SIMT_XCHG_* are part of such a > group, so the same holds there. */ > if (is_gimple_call (g) > - && (gimple_call_internal_p (g, IFN_GOMP_SIMT_ENTER_ALLOC) > + && (gimple_call_flags (g) & ECF_RETURNS_TWICE > + || gimple_call_internal_p (g, IFN_GOMP_SIMT_ENTER_ALLOC) > || gimple_call_internal_p (g, IFN_GOMP_SIMT_EXIT) > || gimple_call_internal_p (g, IFN_GOMP_SIMT_VOTE_ANY) > || gimple_call_internal_p (g, IFN_GOMP_SIMT_XCHG_BFLY) > -- > 2.33.1 >