From patchwork Tue Nov 5 07:37:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1189377 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-512398-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="vQVkMiAE"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="d3GIDBB1"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 476hMx2Pnlz9sNT for ; Tue, 5 Nov 2019 18:37:49 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=m/f PgnAd+ow7z8PejIxcRt0Y+0TROR7j+39WTemzyo1eW/Gmo3GucivMvmKqBynEY5L 7HqrsOE6wX4BQbWCvuhtz6EOFE727LBPPzF0Eu9CqJOv3fgA2g9W1DHxT5vOJ/0Y fOKt3XMT7WtdcKrI9ONJJlZnToivRvQg2CYd8cDE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; s=default; bh=cgP+TW/Hn u7J+mnn2aPg9jLXMQI=; b=vQVkMiAEgWc09p3R7SsXzLjy0frsvuyd8Tmbe7zlz I/rr3BTQIpPEwGrUZBY3bvKoh8h/fxtvpBKSpZq13X3Zpj9NcEnZ3wxM4NLnfvvU FdFlGhhXT+PrOh9s7a5Au3DsOMZHB21/2YThjlGQrfPaEu48cVmusJea3Q7d3Kcn 4w= Received: (qmail 105763 invoked by alias); 5 Nov 2019 07:37:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 105746 invoked by uid 89); 5 Nov 2019 07:37:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 05 Nov 2019 07:37:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572939458; 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: content-transfer-encoding:content-transfer-encoding; bh=E5TubSIBNEX+eH8Zzpcmi9xP8K9TFPLevwEUY6wxXHE=; b=d3GIDBB1xu7MnRHaZHwl4pKqtih3RUQUAHjLiO2bOFDO13qeLJ6IljnbnfffD87b4dYiAX 9eFT+1HRz+36H6LfoHiVL9aNg+hZ+T9cFdhbZSbD7V/ywFLBEErL1aASuZGBLCnnP03sBn lLr2soCLfULMC26VxQwCNTpVK+OQnDc= 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-151-JSGeYVUaM-iEAgrcgH1IVQ-1; Tue, 05 Nov 2019 02:37:37 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 454D7477; Tue, 5 Nov 2019 07:37:35 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.36.118.135]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DEBCF60BF4; Tue, 5 Nov 2019 07:37:34 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id xA57bWQP032193; Tue, 5 Nov 2019 08:37:33 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id xA57bWku032192; Tue, 5 Nov 2019 08:37:32 +0100 Date: Tue, 5 Nov 2019 08:37:31 +0100 From: Jakub Jelinek To: Richard Biener , Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix compute_objsize ICE on VLA ARRAY_REF (PR tree-optimization/91945) Message-ID: <20191105073731.GO4650@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Mimecast-Spam-Score: 0 Content-Disposition: inline X-IsSubscribed: yes Hi! As the testcase shows, ARRAY_REF on an array with variable length element doesn't have INTEGER_CST TYPE_SIZE_UNIT which the code was assuming. The following patch punts in that case. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-11-05 Jakub Jelinek PR tree-optimization/91945 * builtins.c (compute_objsize): For ARRAY_REF, only multiply off by tpsize if it is both non-NULL and INTEGER_CST, otherwise punt. Formatting fix. * gfortran.dg/pr91945.f90: New test. Jakub --- gcc/builtins.c.jj 2019-10-10 01:33:20.000000000 +0200 +++ gcc/builtins.c 2019-11-04 10:09:21.200301352 +0100 @@ -3626,7 +3626,7 @@ compute_objsize (tree dest, int ostype, } } else if (TREE_CODE (off) == SSA_NAME - && INTEGRAL_TYPE_P (TREE_TYPE (off))) + && INTEGRAL_TYPE_P (TREE_TYPE (off))) { wide_int min, max; enum value_range_kind rng = get_range_info (off, &min, &max); @@ -3680,7 +3680,8 @@ compute_objsize (tree dest, int ostype, if (TREE_CODE (dest) == ARRAY_REF) { tree eltype = TREE_TYPE (dest); - if (tree tpsize = TYPE_SIZE_UNIT (eltype)) + tree tpsize = TYPE_SIZE_UNIT (eltype); + if (tpsize && TREE_CODE (tpsize) == INTEGER_CST) off = fold_build2 (MULT_EXPR, size_type_node, off, tpsize); else return NULL_TREE; --- gcc/testsuite/gfortran.dg/pr91945.f90.jj 2019-11-04 10:13:40.392378534 +0100 +++ gcc/testsuite/gfortran.dg/pr91945.f90 2019-11-04 10:13:21.272667903 +0100 @@ -0,0 +1,5 @@ +! PR tree-optimization/91945 +! { dg-do compile } +! { dg-options "-O3 -fstack-arrays -fno-guess-branch-probability" } + +include 'result_in_spec_1.f90'