From patchwork Sat Apr 10 06:07:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1464582 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=sAisgw9y; dkim-atps=neutral Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FHPgh1Myhz9s1l for ; Sat, 10 Apr 2021 16:08:14 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D4F253AAAC11; Sat, 10 Apr 2021 06:08:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4F253AAAC11 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1618034888; bh=HYvsdMvs65s7rTF2kF/AnuIUpZo1OkgqXfQH9RxYczc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=sAisgw9yRxPyHqELk3uLQMznQ+ifuNV/hn0VE4h5n+hXDY0+gOozVCo1omaSrkt1Q H70gL9jlMr35zsomQxWUCW1Ab3PKTCVhN+kgZ3XQL23wphAYYR+iXbZRMwjs2aeqHp tGMoeKYeEYVon66QquBxZY3n+kQnqn2fCRJQeHQU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 4AF3F3AAAC0D for ; Sat, 10 Apr 2021 06:08:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4AF3F3AAAC0D Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-158-tqwlD5U3OOmubcm-en6F1A-1; Sat, 10 Apr 2021 02:08:02 -0400 X-MC-Unique: tqwlD5U3OOmubcm-en6F1A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 98AED1856A63; Sat, 10 Apr 2021 06:08:01 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E4BB101E5AF; Sat, 10 Apr 2021 06:08:00 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 13A67wom1841469 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 10 Apr 2021 08:07:58 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 13A67vJa1841468; Sat, 10 Apr 2021 08:07:57 +0200 Date: Sat, 10 Apr 2021 08:07:57 +0200 To: Richard Biener Subject: [PATCH] rtlanal: Another fix for VOIDmode MEMs [PR98601] Message-ID: <20210410060757.GI1179226@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! This is a sequel to the PR85022 changes, inline-asm can (unfortunately) introduce VOIDmode MEMs and in PR85022 they have been changed so that we don't pretend we know their size (as opposed to assuming they have zero size). This time we ICE in rtx_addr_can_trap_p_1 because it assumes that all memory but BLKmode has known size. The patch just treats VOIDmode MEMs like BLKmode in that regard. And, the STRICT_ALIGNMENT change is needed because VOIDmode has GET_MODE_SIZE of 0 and we don't want to check if something is a multiple of 0. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2021-04-10 Jakub Jelinek PR rtl-optimization/98601 * rtlanal.c (rtx_addr_can_trap_p_1): Allow in assert unknown size not just for BLKmode, but also for VOIDmode. For STRICT_ALIGNMENT unaligned_mems handle VOIDmode like BLKmode. * gcc.dg/torture/pr98601.c: New test. Jakub --- gcc/rtlanal.c.jj 2021-03-05 21:51:48.689185518 +0100 +++ gcc/rtlanal.c 2021-04-09 11:15:20.341906331 +0200 @@ -464,12 +464,17 @@ rtx_addr_can_trap_p_1 (const_rtx x, poly machine_mode mode, bool unaligned_mems) { enum rtx_code code = GET_CODE (x); - gcc_checking_assert (mode == BLKmode || known_size_p (size)); + gcc_checking_assert (mode == BLKmode + || mode == VOIDmode + || known_size_p (size)); poly_int64 const_x1; /* The offset must be a multiple of the mode size if we are considering unaligned memory references on strict alignment machines. */ - if (STRICT_ALIGNMENT && unaligned_mems && mode != BLKmode) + if (STRICT_ALIGNMENT + && unaligned_mems + && mode != BLKmode + && mode != VOIDmode) { poly_int64 actual_offset = offset; --- gcc/testsuite/gcc.dg/torture/pr98601.c.jj 2021-04-09 11:18:26.964817854 +0200 +++ gcc/testsuite/gcc.dg/torture/pr98601.c 2021-04-09 11:18:16.758932053 +0200 @@ -0,0 +1,14 @@ +/* PR rtl-optimization/98601 */ +/* { dg-do compile } */ + +void +foo (void *p) +{ + asm ("" : "=m" (*p)); /* { dg-warning "dereferencing 'void \\*' pointer" } */ +} + +void +bar (void *p) +{ + asm volatile ("" : : "m" (*p)); /* { dg-warning "dereferencing 'void \\*' pointer" } */ +}