From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31596 invoked by alias); 28 Sep 2016 19:47:24 -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 31563 invoked by uid 89); 28 Sep 2016 19:47:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=chr X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Sep 2016 19:47:20 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 19522335F92 for ; Wed, 28 Sep 2016 19:47:19 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-44.ams2.redhat.com [10.36.116.44]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8SJlGvD027345 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 28 Sep 2016 15:47:18 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u8SJlEZB026884; Wed, 28 Sep 2016 21:47:15 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u8SJlDUR026883; Wed, 28 Sep 2016 21:47:13 +0200 Date: Wed, 28 Sep 2016 19:55:00 -0000 From: Jakub Jelinek To: Bernd Schmidt Cc: Jeff Law , gcc-patches@gcc.gnu.org Subject: Re: Patch ping Message-ID: <20160928194713.GK7282@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20160928192450.GJ7282@tucnak.redhat.com> <788754ad-a27a-d64c-d1f2-a1f29de9805b@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <788754ad-a27a-d64c-d1f2-a1f29de9805b@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2016-09/txt/msg02194.txt.bz2 On Wed, Sep 28, 2016 at 09:28:14PM +0200, Bernd Schmidt wrote: > On 09/28/2016 09:24 PM, Jakub Jelinek wrote: > >I'd like to ping the > > > >http://gcc.gnu.org/ml/gcc-patches/2016-09/msg01436.html > > > >patch, containing various fixes for gimple-ssa-sprintf.c. > >If the 0 < var to var > 0 changes are deemed too controversial, I can > >separate them from the other changes. > > I'd like to see them separated because they are obvious and good, so please > install them first. Ok, so here is the separated patch I've installed: 2016-09-28 Jakub Jelinek * gimple-ssa-sprintf.c: Fix comment formatting. (format_integer): Use is_gimple_assign. (pass_sprintf_length::handle_gimple_call): Use gimple_call_builtin_p and gimple_call_fndecl. Reorder case BUILT_IN_SPRINTF_CHK. Fix up BUILT_IN_SNPRINTF_CHK comment. Replace "to to" with "to" in comment. (pass_sprintf_length::execute): Use is_gimple_call. --- gcc/gimple-ssa-sprintf.c.jj 2016-09-21 08:54:15.000000000 +0200 +++ gcc/gimple-ssa-sprintf.c 2016-09-21 15:09:02.209261013 +0200 @@ -37,7 +37,7 @@ along with GCC; see the file COPYING3. The pass handles all forms standard sprintf format directives, including character, integer, floating point, pointer, and strings, - with the standard C flags, widths, and precisions. For integers + with the standard C flags, widths, and precisions. For integers and strings it computes the length of output itself. For floating point it uses MPFR to fornmat known constants with up and down rounding and uses the resulting range of output lengths. For @@ -464,7 +464,7 @@ struct conversion_spec /* Format conversion function that given a conversion specification and an argument returns the formatting result. */ - fmtresult (*fmtfunc) (const conversion_spec &, tree); + fmtresult (*fmtfunc) (const conversion_spec &, tree); /* Return True when a the format flag CHR has been used. */ bool get_flag (char chr) const @@ -1032,10 +1032,10 @@ format_integer (const conversion_spec &s { /* The argument here may be the result of promoting the actual argument to int. Try to determine the type of the actual - argument before promotion and narrow down its range that + argument before promotion and narrow down its range that way. */ gimple *def = SSA_NAME_DEF_STMT (arg); - if (gimple_code (def) == GIMPLE_ASSIGN) + if (is_gimple_assign (def)) { tree_code code = gimple_assign_rhs_code (def); if (code == NOP_EXPR) @@ -2449,18 +2449,10 @@ pass_sprintf_length::handle_gimple_call call_info info = call_info (); info.callstmt = gsi_stmt (gsi); - info.func = gimple_call_fn (info.callstmt); - if (!info.func) - return; - - if (TREE_CODE (info.func) == ADDR_EXPR) - info.func = TREE_OPERAND (info.func, 0); - - if (TREE_CODE (info.func) != FUNCTION_DECL - || !DECL_BUILT_IN(info.func) - || DECL_BUILT_IN_CLASS (info.func) != BUILT_IN_NORMAL) + if (!gimple_call_builtin_p (info.callstmt, BUILT_IN_NORMAL)) return; + info.func = gimple_call_fndecl (info.callstmt); info.fncode = DECL_FUNCTION_CODE (info.func); /* The size of the destination as in snprintf(dest, size, ...). */ @@ -2487,6 +2479,14 @@ pass_sprintf_length::handle_gimple_call info.argidx = 2; break; + case BUILT_IN_SPRINTF_CHK: + // Signature: + // __builtin___sprintf_chk (dst, ost, objsize, format, ...) + idx_objsize = 2; + idx_format = 3; + info.argidx = 4; + break; + case BUILT_IN_SNPRINTF: // Signature: // __builtin_snprintf (dst, size, format, ...) @@ -2498,7 +2498,7 @@ pass_sprintf_length::handle_gimple_call case BUILT_IN_SNPRINTF_CHK: // Signature: - // __builtin___sprintf_chk (dst, size, ost, objsize, format, ...) + // __builtin___snprintf_chk (dst, size, ost, objsize, format, ...) idx_dstsize = 1; idx_objsize = 3; idx_format = 4; @@ -2506,14 +2506,6 @@ pass_sprintf_length::handle_gimple_call info.bounded = true; break; - case BUILT_IN_SPRINTF_CHK: - // Signature: - // __builtin___sprintf_chk (dst, ost, objsize, format, ...) - idx_objsize = 2; - idx_format = 3; - info.argidx = 4; - break; - case BUILT_IN_VSNPRINTF: // Signature: // __builtin_vsprintf (dst, size, format, va) @@ -2556,7 +2548,7 @@ pass_sprintf_length::handle_gimple_call if (idx_dstsize == HOST_WIDE_INT_M1U) { - // For non-bounded functions like sprintf, to to determine + // For non-bounded functions like sprintf, to determine // the size of the destination from the object or pointer // passed to it as the first argument. dstsize = get_destination_size (gimple_call_arg (info.callstmt, 0)); @@ -2667,7 +2660,7 @@ pass_sprintf_length::execute (function * /* Iterate over statements, looking for function calls. */ gimple *stmt = gsi_stmt (si); - if (gimple_code (stmt) == GIMPLE_CALL) + if (is_gimple_call (stmt)) handle_gimple_call (si); } } Jakub