From patchwork Wed Jan 17 18:21:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 188917 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:30f:b0:101:a8e8:374 with SMTP id ia15csp97192dyb; Wed, 17 Jan 2024 10:22:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IEl2HfmtLBM7mWwfIBHgfnE6zhbkzGkZfL2f8Cq4QtiUUmxNbFY0ywrdkO0WZfsVW5Ud4xV X-Received: by 2002:a05:6214:daf:b0:681:2506:2bd8 with SMTP id h15-20020a0562140daf00b0068125062bd8mr9397112qvh.19.1705515753185; Wed, 17 Jan 2024 10:22:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705515753; cv=pass; d=google.com; s=arc-20160816; b=TxupUQySCtrlFs/Z7aMSbwhMDWyK/eMmTVgSlW8B8Tuu1RCFVlfAdHmfZLOXmTRNOi 8X4yLVWsEGAa0JLU20gyyFO1PJnyICzxj6zdzC1ifI3MVlpz5U7dbmgPvDepuA6Au+qW JY3DMlnghW9GyMoKrJ6Yide4aaaa+GCSDXVJe+CMd7uK0CdlChgLB03fHH87IApFftgW BI6oNlP6o2Yo0gZ0UsnLNk95wMoqtCPQs/KzpLxsQ6qIY1WVAH8dmnLPCxk9AJEvLEIc plgNmL/OhW5wAlnkk2rCFtlgrdppfxVB7KxUCgMCXOg7pBe3cobBr0MxlpTKT4f2uoF1 sACw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:date:user-agent :subject:cc:to:from:dkim-signature:dkim-signature:dkim-signature :dkim-signature:arc-filter:dmarc-filter:delivered-to:message-id; bh=eWvKqBPki5s2APyg5UsjIVltDztIRgudvWalEnsxjZs=; fh=WPIAM4Kk6H75izKNqWrbv/BYjkMch6nkxCBoS0RUOUI=; b=nXeljcVvohiUOZ7jUVekRqpttuAYBdULlP6OAbfXmTUj+xQ7STnoxDeNOfcYFLNYtk j5EJ9JaHtyRmu31v6YLZM4vo3C8WW9pYasvyec06qzUKApuQNlLrileLwc7L6K8Ow2Gr bmZu+ba26GQvN7klowwSYIW6QPw0ZDv7bYAwv2IxJRWgbb7sN4JtCv6cj12G+k6gxFiv rYv/ltOsCX+qzCYxzNbmBNf6hbCBb8DCdT1r1krNt/L5g2lfInf2GDH37m4/ifx4RNGT 9lSIJZ5RfD4eacrhlMZxf4p2zWuXTMN8rmIrKhm6rxQaY/H8Hjz6dg1q+NJ3OAElfVHQ jjdA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="F/HBuhoE"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=VTzD4uiu; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="hWbu/uEH"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id j4-20020a0cab84000000b0067f34487d8bsi12251596qvb.467.2024.01.17.10.22.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 10:22:33 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="F/HBuhoE"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=VTzD4uiu; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="hWbu/uEH"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Message-ID: <65a81ae9.0c0a0220.60e4f.1e95SMTPIN_ADDED_BROKEN@mx.google.com> X-Google-Original-Message-ID: Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E0709385840D for ; Wed, 17 Jan 2024 18:22:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 08FED3858CDB for ; Wed, 17 Jan 2024 18:21:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 08FED3858CDB Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 08FED3858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705515712; cv=none; b=aIg+FTipmnHL/f51YH4cdi1YlS/DeS9iYAb5UfDLIwhJRtVesPsu6cLCKoBeuPrLi8IadfEuW2+SfhPvYuZ1drcNK75SF2zGvzcDO9liR7ItslkkC5+CWSpgbISALzx8u2Nd2Oo4C6xKu3HG/BLA8MPd+2YUy/TM2Bgabmc5358= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705515712; c=relaxed/simple; bh=LP1/V87coz/B1H53DjPvb3tHQZ8cTYSf7TdskHxUZN0=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=ZqVQ+VlViG4pUXslMmMB93CzUDgp7mURBgY+o7QmwZkd+XgWapz0jxp6fzMgsLdigW/h9gEEe3j0/AZPdovDjmYWx84O9KWHjdI4eYYTYYqprXs55KwIWrj1Ih2TO1MaKEZt5fqH1vzPnNeAeDT5xu1qAw51P636ZBe8x7JWBcg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D6C181FCE0; Wed, 17 Jan 2024 18:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1705515710; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=eWvKqBPki5s2APyg5UsjIVltDztIRgudvWalEnsxjZs=; b=F/HBuhoEHYVH6ObTRSO4nxLLbeO5bbiuxx3UwOcpsfqelfVebIEKctxW8CQh08HSLxbZDm /lp7xzttY2bGdTdFi6v5XNPJgSgPU342PJdr5kizwCoFqbztsEm/p+IkAM+FpQnH8u2bAE PVJ55QAxSZLW3NwwcVGOmfd1Txu1ZRY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1705515710; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=eWvKqBPki5s2APyg5UsjIVltDztIRgudvWalEnsxjZs=; b=VTzD4uiuoAz7cEM4sBgeCEg27BekoariN8hZDgD5O7Gx0eG3fzKoAGj/ZiCIMVOSFXTqo8 893oehA9hf7xfCCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1705515709; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=eWvKqBPki5s2APyg5UsjIVltDztIRgudvWalEnsxjZs=; b=hWbu/uEHkdT05bJJ2ZJwM+K+SWegTSjD/NRhRM+IjuEfIBmn7FnyRlDtPtUj2ry8iKlUTq CZbD00hZXrlYpb4hN4sPaPLC9SR2AXc5dy2EKjGLHcv6Jcp29y9UP1y55K1NZUWxmgXT3v 9e5pHxvrs77LytwehUFsPXbfCB0dHos= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1705515709; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=eWvKqBPki5s2APyg5UsjIVltDztIRgudvWalEnsxjZs=; b=p47fEKsrIpJSdBZUFeAjrBHu2zXg8ewx+Z3AhEOxyCU6yAF79u0ZGz/EWtnOv3UwUe3l9o 4S+goa4XzYV0UcDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D14C413751; Wed, 17 Jan 2024 18:21:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id /cAUM70aqGXLTwAAD6G6ig (envelope-from ); Wed, 17 Jan 2024 18:21:49 +0000 From: Martin Jambor To: GCC Patches Cc: Richard Biener Subject: [PATCH] sra: Disqualify bases of operands of asm gotos User-Agent: Notmuch/0.38.1 (https://notmuchmail.org) Emacs/29.1 (x86_64-suse-linux-gnu) Date: Wed, 17 Jan 2024 19:21:49 +0100 MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [-0.90 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; TO_DN_ALL(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; INVALID_MSGID(1.70)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Level: X-Spam-Score: -0.90 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, INVALID_MSGID, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788362886212943635 X-GMAIL-MSGID: 1788362886212943635 Hi, PR 110422 shows that SRA can ICE assuming there is a single edge outgoing from a block terminated with an asm goto. We need that for BB-terminating statements so that any adjustments they make to the aggregates can be copied over to their replacements. Because we can't have that after ASM gotos, we need to punt. Bootstrapped and tested on x86_64-linux, OK for master? It will need some tweaking for release branches, is it in principle OK for them too (after testing)? Thanks, Martin gcc/ChangeLog: 2024-01-17 Martin Jambor PR tree-optimization/110422 * tree-sra.cc (scan_function): Disqualify bases of operands of asm gotos. gcc/testsuite/ChangeLog: 2024-01-17 Martin Jambor PR tree-optimization/110422 * gcc.dg/torture/pr110422.c: New test. --- gcc/testsuite/gcc.dg/torture/pr110422.c | 10 +++++++++ gcc/tree-sra.cc | 29 ++++++++++++++++++++----- 2 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr110422.c diff --git a/gcc/testsuite/gcc.dg/torture/pr110422.c b/gcc/testsuite/gcc.dg/torture/pr110422.c new file mode 100644 index 00000000000..2e171a7a19e --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr110422.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +struct T { int x; }; +int foo(void) { + struct T v; + asm goto("" : "+r"(v.x) : : : lab); + return 0; +lab: + return -5; +} diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc index 6a1141b7377..f8e71ec48b9 100644 --- a/gcc/tree-sra.cc +++ b/gcc/tree-sra.cc @@ -1559,15 +1559,32 @@ scan_function (void) case GIMPLE_ASM: { gasm *asm_stmt = as_a (stmt); - for (i = 0; i < gimple_asm_ninputs (asm_stmt); i++) + if (stmt_ends_bb_p (asm_stmt) + && !single_succ_p (gimple_bb (asm_stmt))) { - t = TREE_VALUE (gimple_asm_input_op (asm_stmt, i)); - ret |= build_access_from_expr (t, asm_stmt, false); + for (i = 0; i < gimple_asm_ninputs (asm_stmt); i++) + { + t = TREE_VALUE (gimple_asm_input_op (asm_stmt, i)); + disqualify_base_of_expr (t, "OP of asm goto."); + } + for (i = 0; i < gimple_asm_noutputs (asm_stmt); i++) + { + t = TREE_VALUE (gimple_asm_output_op (asm_stmt, i)); + disqualify_base_of_expr (t, "OP of asm goto."); + } } - for (i = 0; i < gimple_asm_noutputs (asm_stmt); i++) + else { - t = TREE_VALUE (gimple_asm_output_op (asm_stmt, i)); - ret |= build_access_from_expr (t, asm_stmt, true); + for (i = 0; i < gimple_asm_ninputs (asm_stmt); i++) + { + t = TREE_VALUE (gimple_asm_input_op (asm_stmt, i)); + ret |= build_access_from_expr (t, asm_stmt, false); + } + for (i = 0; i < gimple_asm_noutputs (asm_stmt); i++) + { + t = TREE_VALUE (gimple_asm_output_op (asm_stmt, i)); + ret |= build_access_from_expr (t, asm_stmt, true); + } } } break;