From patchwork Tue May 28 12:12:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1940458 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=wQBM17na; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=VfJIWFpm; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=VV1Ro69v; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=eKLX0liV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VpWcY3wjCz20Pb for ; Tue, 28 May 2024 22:13:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BA2713858D35 for ; Tue, 28 May 2024 12:12:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 0008C385B510 for ; Tue, 28 May 2024 12:12:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0008C385B510 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0008C385B510 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716898359; cv=none; b=h9rR+LArlLClyNgDVWHoE2nvMqLlTviAy2eN4kaUKLlBjuJkuV9ORhqZJkVD1wjytk4wiC1/tTOmKnfR85hfaT/V07SVqLPPUz1z+UcRXZhiw4z0tGVt0koA80mhTKxbxO6mj20rHmUVqVrpGpn9MFj70lxI5hfsIKdSWloE+7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716898359; c=relaxed/simple; bh=+Q20e5WruJPBudrXCiqLD5qJ5+1ElqkUKDz+SKRPusE=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=P2L+TIWNmLPhA+OFyNkgHG1ABStWLN2STrByLlS0w9M/Bia/J982HJlB3NhN1JtKac7vPslAY6OZ0sm6bGZskPK7kO4Q97idd3PgZ0Atgz0GBIBcJZtDmZKthZphgmpl9fld1+A9q0Y3/34WLVML3xmuhHJtfwzwavedr5GP+4k= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from murzim.nue2.suse.org (unknown [10.168.4.243]) (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-out1.suse.de (Postfix) with ESMTPS id 0D4F022807 for ; Tue, 28 May 2024 12:12:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716898356; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=b3gIqz1JF3MQABfEAalq6Knn0u5ZijikYRnARAon+Co=; b=wQBM17nawFrTtMuDDx3dSR1mlapbkQ0NIFspX4KGYijYjm6/9xk8A7Khe05ga2SqMttJYi sYxTZ9RzRz0wDPwl/plhpFIr+R/uGsj97OBlDyxMQVQz5FpeWod5uVPCbSpKOc2JZtpCp2 X6TYfI55cERNaNmjtDrZU9G+T4VK/DI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716898356; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=b3gIqz1JF3MQABfEAalq6Knn0u5ZijikYRnARAon+Co=; b=VfJIWFpm2i2IKFcYycSQ5Pkf7ZHB+YsnH3A4mg7DSHy4cbSbxvcuJ1GBtXZiCkyHPJGdyX FTcF8yFoUqKc5XAw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716898354; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=b3gIqz1JF3MQABfEAalq6Knn0u5ZijikYRnARAon+Co=; b=VV1Ro69vl+vc1hpoImQLutGtm27qNIshvAWXz4pBNfwu+YsOa8SSh/dZ8IfI9y5QX3hS3h X1Zn70kLRFz2P5D666bnsPq6/M8RWHfrz/YxTgaQ6AosOqaOGdAWSYyzXQU+RdEefRgruV bSaQ/nGzzwyryE/dLBgHLW4R242+RH8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716898354; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=b3gIqz1JF3MQABfEAalq6Knn0u5ZijikYRnARAon+Co=; b=eKLX0liVkwmrS6hDnZHsJc17GEf1cIL2F/AFReZUgQ1OA1BXBZHee3+FalG8AmU5BGy8dU eRsSCx9EShcm+bCw== Date: Tue, 28 May 2024 14:12:33 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Avoid pessimistic constraints for asm memory constraints MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-1.60 / 50.00]; BAYES_HAM(-2.95)[99.79%]; MISSING_MID(2.50)[]; NEURAL_HAM_LONG(-0.99)[-0.995]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_SHORT(-0.05)[-0.269]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_ONE(0.00)[1]; MISSING_XM_UA(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; FROM_HAS_DN(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[murzim.nue2.suse.org:helo, tree-ssa-structalias.cc:url] X-Spam-Score: -1.60 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Message-Id: <20240528121259.BA2713858D35@sourceware.org> We process asm memory input/outputs with constraints to ESCAPED but for this temporarily build an ADDR_EXPR. The issue is that the used build_fold_addr_expr ends up wrapping the ADDR_EXPR in a conversion which ends up producing &ANYTHING constraints which is quite bad. The following uses get_constraint_for_address_of instead, avoiding the temporary tree and the unhandled conversion. This avoids a gcc.dg/tree-ssa/restrict-9.c FAIL with the fix for PR115236. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. * tree-ssa-structalias.cc (find_func_aliases): Use get_constraint_for_address_of to build escape constraints for asm inputs and outputs. --- gcc/tree-ssa-structalias.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc index 53552b63532..330e64e65da 100644 --- a/gcc/tree-ssa-structalias.cc +++ b/gcc/tree-ssa-structalias.cc @@ -5277,7 +5277,11 @@ find_func_aliases (struct function *fn, gimple *origt) /* A memory constraint makes the address of the operand escape. */ if (!allows_reg && allows_mem) - make_escape_constraint (build_fold_addr_expr (op)); + { + auto_vec tmpc; + get_constraint_for_address_of (op, &tmpc); + make_constraints_to (escaped_id, tmpc); + } /* The asm may read global memory, so outputs may point to any global memory. */ @@ -5306,7 +5310,11 @@ find_func_aliases (struct function *fn, gimple *origt) /* A memory constraint makes the address of the operand escape. */ if (!allows_reg && allows_mem) - make_escape_constraint (build_fold_addr_expr (op)); + { + auto_vec tmpc; + get_constraint_for_address_of (op, &tmpc); + make_constraints_to (escaped_id, tmpc); + } /* Strictly we'd only need the constraint to ESCAPED if the asm clobbers memory, otherwise using something along the lines of per-call clobbers/uses would be enough. */