From patchwork Tue Oct 29 10:17:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 99757 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1D6CC385840B for ; Tue, 29 Oct 2024 10:17:58 +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 4FD0F3858D34 for ; Tue, 29 Oct 2024 10:17:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4FD0F3858D34 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 4FD0F3858D34 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=1730197049; cv=none; b=Zf4V+kdRpmuzk1D7Dl1v1Dwy6at8ihy5uj96j/lSldokGAuW4Sg38hd8Bz3gXk7uRsVrc3Ex+wSKbznu+Sbw+3mMAYqyhoQLzwligklNrQIc2lea4sPXWYiUdFwh4Ywr1RKYjPXFnwgWWx2P5oVLi6DfI+QaW712jP76Jdw4OA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730197049; c=relaxed/simple; bh=0z76HCM2oleZQImC5T/hPhkvJDlOUncZE3WuC1MlO1Q=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version:Message-Id; b=CRNBixopjCq8lAbYdvC/2S3pPLgYnUG3EnYqbRSJr9+6UkNTAL+g9b4RFwfNxfooJgC42lO7ogjhNny5pKNfKB7nlPFX+59t2Snz+25kKYaJjI03wycxOLZmCdDgOiLvzWrS4bFGJuO1zncvxxk3uZrFU1a1ublToK80nYvcT3c= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out1.suse.de (Postfix) with ESMTPS id 2D9F92122E for ; Tue, 29 Oct 2024 10:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730197045; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=PA0KvaOt6MptOZpoZ0EA5B0qiwUKws1mYGxBVFAHRHo=; b=D5Dftb5wfcr6IOZwcLMRaF+BLZBmR1k7ZLPAbE1r5ohuZ0dqiGWCGs9EOhxkF+8qqJqKjK uqQGLepb3TM8JajUm+JunKiZzYBHzWexFDfu2o9QJvT5OW55TRR/qFVjPdfy0GY17QrqVG 6yZPx2xLHDAEoUhSKgD5bZh2AjgOmpM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730197045; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=PA0KvaOt6MptOZpoZ0EA5B0qiwUKws1mYGxBVFAHRHo=; b=Kee1bjZ5yG03ziVnkU+aQyYZGA7a5r2ML/FuPBZIOxYTaj/YXVH7/bytaZ+uFixKoz4SHI FfDSDMw5S1I4zPDw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=D5Dftb5w; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Kee1bjZ5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730197045; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=PA0KvaOt6MptOZpoZ0EA5B0qiwUKws1mYGxBVFAHRHo=; b=D5Dftb5wfcr6IOZwcLMRaF+BLZBmR1k7ZLPAbE1r5ohuZ0dqiGWCGs9EOhxkF+8qqJqKjK uqQGLepb3TM8JajUm+JunKiZzYBHzWexFDfu2o9QJvT5OW55TRR/qFVjPdfy0GY17QrqVG 6yZPx2xLHDAEoUhSKgD5bZh2AjgOmpM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730197045; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=PA0KvaOt6MptOZpoZ0EA5B0qiwUKws1mYGxBVFAHRHo=; b=Kee1bjZ5yG03ziVnkU+aQyYZGA7a5r2ML/FuPBZIOxYTaj/YXVH7/bytaZ+uFixKoz4SHI FfDSDMw5S1I4zPDw== 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 13E83139A2 for ; Tue, 29 Oct 2024 10:17:25 +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 6wM0AzW2IGelLwAAD6G6ig (envelope-from ) for ; Tue, 29 Oct 2024 10:17:25 +0000 Date: Tue, 29 Oct 2024 11:17:09 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/117333 - ICE with NULL access size DR MIME-Version: 1.0 Message-Id: <20241029101725.13E83139A2@imap1.dmz-prg2.suse.org> X-Rspamd-Queue-Id: 2D9F92122E X-Spam-Level: X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MISSING_XM_UA(0.00)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim, imap1.dmz-prg2.suse.org:mid, imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -4.51 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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~patchwork=sourceware.org@gcc.gnu.org dr_may_alias_p ICEs when TYPE_SIZE of DR->ref is NULL but this is valid IL when the access size of an aggregate copy can be infered from the RHS. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/117333 * tree-data-ref.cc (dr_may_alias_p): Guard against NULL access size. * gcc.dg/torture/pr117333.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr117333.c | 29 +++++++++++++++++++++++++ gcc/tree-data-ref.cc | 2 ++ 2 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/pr117333.c diff --git a/gcc/testsuite/gcc.dg/torture/pr117333.c b/gcc/testsuite/gcc.dg/torture/pr117333.c new file mode 100644 index 00000000000..38c1b5493a5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr117333.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ + +struct s +{ + unsigned long ul; + int i; + char ac[]; +}; + +const struct s gs = { 3, -4, "abcdef" }; + +void copy_s(struct s*d, const struct s*s) +{ + *d = *s; +} + +unsigned test(struct s*ps, _Bool direct) +{ + if(direct) + *ps = gs; + else + copy_s(ps, &gs); + return sizeof(*ps); +} + +unsigned size(void) +{ + return sizeof(gs); +} diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc index de234c65e94..1fdfef282c7 100644 --- a/gcc/tree-data-ref.cc +++ b/gcc/tree-data-ref.cc @@ -3004,6 +3004,8 @@ dr_may_alias_p (const struct data_reference *a, const struct data_reference *b, && DR_BASE_ADDRESS (b) && operand_equal_p (DR_BASE_ADDRESS (a), DR_BASE_ADDRESS (b)) && operand_equal_p (DR_OFFSET (a), DR_OFFSET (b)) + && tree_size_a + && tree_size_b && poly_int_tree_p (tree_size_a) && poly_int_tree_p (tree_size_b) && !ranges_maybe_overlap_p (wi::to_poly_widest (DR_INIT (a)),