From patchwork Tue Oct 1 08:17:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1991349 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=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FSlBqy9S; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4XHrRH3bzWz1xtg for ; Tue, 1 Oct 2024 18:18:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6DF133846405 for ; Tue, 1 Oct 2024 08:18:01 +0000 (GMT) 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.129.124]) by sourceware.org (Postfix) with ESMTP id AF46E38650D5 for ; Tue, 1 Oct 2024 08:17:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AF46E38650D5 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AF46E38650D5 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727770647; cv=none; b=xCKidnMCggLiAWDdqbeN9sffmIMWWDLME4MNz14wDzXR2C3AWbm62qGdtKSVf853LppYCqEntuB6YDeIAA6TNQS8vzrWo3GBud3NZN8OGmKwVzCPQde/NE/8FYwSD/7t1okbaf/HTmZJvxSEdBsOHR5z600qhR1iKvwA512JUxc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727770647; c=relaxed/simple; bh=9haRIFSnHniWUTdJeYkGU6E+2oO0i9ErJY7VGJ86Cbc=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=GL2X+oH1/giL1UsZLtO7i4gn78qTH8IH5lkA9foMRtarbDI8pZIRURi4ldGwgV2zwiYqDyT21s/N4Ti4YPPciV7otwx28ZSIOWI69AhZHs+ixDPsAshysbj7V1Jc2qAx4cFjVx00lt/mf7S3h6RNJmx/oJokZMzO/Jh3ZAXdKU0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727770644; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=iAwpwcSHda05m8wc/S6cm5aH2I17vZvHH1psMqCvczw=; b=FSlBqy9SnAQs+4KaMaLg7GDAlc+AjTg2sg2wtYwvMt6zrg9DGSuoin+n0qPSaimvW1zgyO HQ563Pjv/6wq5n72rgWBflsefjCoiZvAGZ30z8xt5npp1iADdp9rpO4eKWPdwYXKJ/aqAu kLTKuMglMUPBIBXk1/pru1Kx7To0BWw= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-271-jCBVWz_NOQGDmh4vEGVWdw-1; Tue, 01 Oct 2024 04:17:22 -0400 X-MC-Unique: jCBVWz_NOQGDmh4vEGVWdw-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 39AC41977034 for ; Tue, 1 Oct 2024 08:17:21 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.61]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1DCEB1944D44; Tue, 1 Oct 2024 08:17:04 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 4918H25K3495535 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 1 Oct 2024 10:17:02 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 4918H2o33495534; Tue, 1 Oct 2024 10:17:02 +0200 Date: Tue, 1 Oct 2024 10:17:01 +0200 From: Jakub Jelinek To: Andrew MacLeod Cc: gcc-patches@gcc.gnu.org Subject: [committed] range-cache: Fix ICE on SSA_NAME with def_stmt not yet in the IL [PR116898] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! Some passes like the bitint lowering queue some statements on edges and only commit them at the end of the pass. If they use ranger at the same time, the ranger might see such SSA_NAMEs and ICE on those. The following patch instead just punts on them. Bootstrapped/regtested on x86_64-linux and i686-linux, preapproved by Andrew in the PR, committed to trunk. 2024-10-01 Jakub Jelinek PR middle-end/116898 * gimple-range-cache.cc (ranger_cache::block_range): If a SSA_NAME with NULL def_bb isn't SSA_NAME_IS_DEFAULT_DEF, return false instead of failing assertion. Formatting fix. * gcc.dg/bitint-110.c: New test. Jakub --- gcc/gimple-range-cache.cc.jj 2024-08-12 10:49:12.687608080 +0200 +++ gcc/gimple-range-cache.cc 2024-09-30 18:50:52.314056272 +0200 @@ -1284,13 +1284,16 @@ ranger_cache::block_range (vrange &r, ba gimple *def_stmt = SSA_NAME_DEF_STMT (name); basic_block def_bb = NULL; if (def_stmt) - def_bb = gimple_bb (def_stmt);; + def_bb = gimple_bb (def_stmt); if (!def_bb) { // If we get to the entry block, this better be a default def // or range_on_entry was called for a block not dominated by - // the def. - gcc_checking_assert (SSA_NAME_IS_DEFAULT_DEF (name)); + // the def. But it could be also SSA_NAME defined by a statement + // not yet in the IL (such as queued edge insertion), in that case + // just punt. + if (!SSA_NAME_IS_DEFAULT_DEF (name)) + return false; def_bb = ENTRY_BLOCK_PTR_FOR_FN (cfun); } --- gcc/testsuite/gcc.dg/bitint-110.c.jj 2024-09-30 18:52:50.098424063 +0200 +++ gcc/testsuite/gcc.dg/bitint-110.c 2024-09-30 18:54:38.183925375 +0200 @@ -0,0 +1,20 @@ +/* PR middle-end/116898 */ +/* { dg-do compile { target bitint575 } } */ +/* { dg-options "-O -finstrument-functions -fnon-call-exceptions" } */ + +_BitInt(127) a; +_BitInt(511) b; + +void +foo (_BitInt(31) c) +{ + do + { + c %= b; +again: + } + while (c); + a /= 0; /* { dg-warning "division by zero" } */ + c -= a; + goto again; +}