From patchwork Mon May 4 12:11:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1282519 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Received: from sourceware.org (server2.sourceware.org [8.43.85.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 ozlabs.org (Postfix) with ESMTPS id 49G1tG2rWPz9sRf for ; Mon, 4 May 2020 22:11:32 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ED80A383E823; Mon, 4 May 2020 12:11:29 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 3520E383E81E for ; Mon, 4 May 2020 12:11:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3520E383E81E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rguenther@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id F0254AE5A; Mon, 4 May 2020 12:11:28 +0000 (UTC) Date: Mon, 4 May 2020 14:11:26 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Adjust integer <-> pointer conversion IL checking Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-25.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, 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: , Cc: ebotcazou@adacore.com Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This patch sits in my trees for quite some years and I always forget to push it - it usually gets triggered by weird targets (PSImode pointers/sizetype) which run into GIMPLE IL checking asserts for pointer -> integer conversions and the "sizetype" special-case not triggering. That special-case should not exist but instead it should be something like the patch below - the whole point of the IL consistecy check is to ensure we know how to extend from pointer to integer. I've bootstrapped / tested the patch on x86_64 where it is a no-op. But from the looks, can you punch any holes in it? (it was able to resolve reporters issues at least). Thanks, Richard. - The existing check doesn't reflect the actual reason why it exists, the patch makes us to use POINTERS_EXTEND_UNSIGNED instead which is specified for ptr_mode and word_mode/Pmode precision. * tree-cfg.c (verify_gimple_assign_unary): Adjust integer to/from pointer conversion checking. --- gcc/tree-cfg.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index e99fb9ff5d1..c6140af50e7 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -3591,13 +3591,21 @@ verify_gimple_assign_unary (gassign *stmt) /* Allow conversions from pointer type to integral type only if there is no sign or zero extension involved. For targets were the precision of ptrofftype doesn't match that - of pointers we need to allow arbitrary conversions to ptrofftype. */ + of pointers we allow conversions to types where + POINTERS_EXTEND_UNSIGNED specifies how that works. */ if ((POINTER_TYPE_P (lhs_type) && INTEGRAL_TYPE_P (rhs1_type)) || (POINTER_TYPE_P (rhs1_type) && INTEGRAL_TYPE_P (lhs_type) && (TYPE_PRECISION (rhs1_type) >= TYPE_PRECISION (lhs_type) - || ptrofftype_p (lhs_type)))) +#if defined(POINTERS_EXTEND_UNSIGNED) + || (TYPE_MODE (rhs1_type) == ptr_mode + && (TYPE_PRECISION (lhs_type) + == BITS_PER_WORD /* word_mode */ + || (TYPE_PRECISION (lhs_type) + == GET_MODE_PRECISION (Pmode)))) +#endif + ))) return false; /* Allow conversion from integral to offset type and vice versa. */