From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2856 invoked by alias); 20 Feb 2018 20:49:56 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 2696 invoked by uid 89); 20 Feb 2018 20:49:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-12.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Feb 2018 20:49:53 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 547A9A27C1; Tue, 20 Feb 2018 20:49:52 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-85.brq.redhat.com [10.40.204.85]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD6A42166BAE; Tue, 20 Feb 2018 20:49:51 +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 w1KKnnxM030045; Tue, 20 Feb 2018 21:49:50 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w1KKnmd5030044; Tue, 20 Feb 2018 21:49:48 +0100 Date: Tue, 20 Feb 2018 20:49:00 -0000 From: Jakub Jelinek To: Martin Sebor Cc: Richard Biener , Jeff Law , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix pdftex miscompilation due to get_range_strlen (PR tree-optimization/84478) Message-ID: <20180220204948.GJ5867@tucnak> Reply-To: Jakub Jelinek References: <20180220171712.GH5867@tucnak> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg01196.txt.bz2 On Tue, Feb 20, 2018 at 12:03:26PM -0700, Martin Sebor wrote: > PR tree-optimization/84478 - [8 Regression] pdftex miscompilation on i386 > > gcc/ChangeLog: > > PR tree-optimization/84478 > * gimple-fold.c (get_range_strlen): Set *MINLEN to zero. > (get_range_strlen): Reset range on failure. > > gcc/testsuite/ChangeLog: > > PR tree-optimization/84478 > * gcc.c-torture/execute/pr84478.c: New test. > > Index: gcc/gimple-fold.c > =================================================================== > --- gcc/gimple-fold.c (revision 257796) > +++ gcc/gimple-fold.c (working copy) > @@ -1369,7 +1369,10 @@ get_range_strlen (tree arg, tree length[2], bitmap > tree eltype = TREE_TYPE (type); > if (TREE_CODE (type) != ARRAY_TYPE > || !INTEGRAL_TYPE_P (eltype)) > - return false; > + { > + *minlen = ssize_int (0); > + return false; > + } This is just one of the 13 spots where we return false, so this doesn't look safe or sufficient to me, even when you actually honor the return value in 2 argument get_range_strlen. You'd really need to do { if (fuzzy) - *maxlen = build_all_ones_cst (size_type_node); + { + *minlen = size_int (0); + *maxlen = build_all_ones_cst (size_type_node); + } else return false; } or just drop that if (fuzzy) stuff from there, but that breaks the warning tests. It would help if you explained why you think it is a good idea ignoring the other phi arguments if you have one (or more) where you can determine length. One variation of my patch could be instead of adding type 3 change fuzzy from bool to int, and use fuzzy == 1 for the strlen value ranges and fuzzy == 2 for the warning code (i.e. 2 operand get_range_strlen). Note, my patch passed regtest on both x86_64-linux and i686-linux. Jakub