From patchwork Thu Jun 6 19:32:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1111418 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-502513-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="vNTvo/DT"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SyFxqQ+e"; 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 45KbQj0h51z9s4Y for ; Fri, 7 Jun 2019 05:32:26 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=s9IB6TJAY38uxDN2u1SrmN6Tmdf07M67IUigsdzR8FTF01maSH TLYjzT4LXUBimpXA2cLSCLsvMGND2ClQZM/+4UE4B3y8rOCLMkXCIqitpY14JpwP 0tITykhom46dcz1GIS7atunciFfow3oisxOfA0wueH/61noADjPaBXjTQ= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=zCT7Dj4rq69UloJIvlQRm2OdZo8=; b=vNTvo/DTmVkYLQV70HCz cbcLZbLnfKzGh4E8fxkKAFm62Q0B04wHXAanpa6WC4LEpl4v++ZGbYL/Qj5/tdTI AVA/AEg8RCyL/wLuYbXDIJd3yf6P4vOFmT/NgJr+hXtZwZ1q3IVLYSywDZQG//Ar 7lap6nDbZGn1OoxPN3dRHmQ= Received: (qmail 34988 invoked by alias); 6 Jun 2019 19:32:20 -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 34980 invoked by uid 89); 6 Jun 2019 19:32:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=non-null, surprising, 2018-11, 201811 X-HELO: mail-qk1-f181.google.com Received: from mail-qk1-f181.google.com (HELO mail-qk1-f181.google.com) (209.85.222.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 06 Jun 2019 19:32:18 +0000 Received: by mail-qk1-f181.google.com with SMTP id c70so2218544qkg.7 for ; Thu, 06 Jun 2019 12:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=sR/Cdvts35yroHQZFD5hrEAsu3cy4qxsp3Kc7eDvZao=; b=SyFxqQ+epK0BxsXtgf6ddTzubYCw7TSO+RSS0u1cXsdT7ELFL11BGF0h59ExKTW4Gf OHqXrA49xVCS73yf4DEbaQYDzhcEnNvYrNl9aTwKz/jHK7fR06bA8IbG8qA0up/ecJFu ym+bbrDjnrH7HQR7/DmuCVB2YdAJsOQ1/mJPh+ba6Z5hYvl908YlCAnQKA4SDt7iAayc oqhrQozZiIXvk4E+i0zZSjCwM6BXlxvdSs8VXaHF6HJKxRY+HUfp2dhe5A2i4lfDmvxy ZgDjqVvXnZbOFFWWK4xVEa7xLaPao6vMd5MdnQ53wGpK6WXI5+ul0YEhilBXhJDstOVh tO7w== Received: from [192.168.0.41] (75-166-109-122.hlrn.qwest.net. [75.166.109.122]) by smtp.gmail.com with ESMTPSA id y19sm1691951qty.43.2019.06.06.12.32.14 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jun 2019 12:32:15 -0700 (PDT) To: Jeff Law , gcc-patches From: Martin Sebor Subject: [PATCH] update get_range_strlen description Message-ID: <8de8f5f3-08b9-0c4f-a391-7ac752b1aac8@gmail.com> Date: Thu, 6 Jun 2019 13:32:14 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi Jeff, It looks like the updated comment for get_range_strlen didn't make it into the strlen fixup commits last December and the function still has the old description. (Not surprising given there are at least two overloads of the same function and things moving between them.) I'm going to check in the comment from the patch here: https://gcc.gnu.org/ml/gcc-patches/2018-11/msg02050.html with an additional sentence describing ELTSIZE. Let me know if you'd like me to tweak it or if spot something else. Thanks Martin gcc/ChangeLog: * gimple-fold.c (get_range_strlen): Update comment that didn't make it into r267503 or related commits. diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index b3e931744f8..18860bb7c28 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -1672,30 +1672,16 @@ get_range_strlen (tree arg, bitmap *visited, } } -/* Determine the minimum and maximum value or string length that ARG - refers to and store each in the first two elements of MINMAXLEN. - For expressions that point to strings of unknown lengths that are - character arrays, use the upper bound of the array as the maximum - length. For example, given an expression like 'x ? array : "xyz"' - and array declared as 'char array[8]', MINMAXLEN[0] will be set - to 0 and MINMAXLEN[1] to 7, the longest string that could be - stored in array. - Return true if the range of the string lengths has been obtained - from the upper bound of an array at the end of a struct. Such - an array may hold a string that's longer than its upper bound - due to it being used as a poor-man's flexible array member. - - STRICT is true if it will handle PHIs and COND_EXPRs conservatively - and false if PHIs and COND_EXPRs are to be handled optimistically, - if we can determine string length minimum and maximum; it will use - the minimum from the ones where it can be determined. - STRICT false should be only used for warning code. - When non-null, clear *NONSTR if ARG refers to a constant array - that is known not be nul-terminated. Otherwise set it to - the declaration of the constant non-terminated array. - - ELTSIZE is 1 for normal single byte character strings, and 2 or - 4 for wide characer strings. ELTSIZE is by default 1. */ +/* Try to obtain the range of the lengths of the string(s) referenced + by ARG, or the size of the largest array ARG refers to if the range + of lengths cannot be determined, and store all in *PDATA. ELTSIZE + is the expected size of the string element in bytes: 1 for char and + some power of 2 for wide characters. + Return true if the range [PDATA->MINLEN, PDATA->MAXLEN] is suitable + for optimization. Returning false means that a nonzero PDATA->MINLEN + doesn't reflect the true lower bound of the range when PDATA->MAXLEN + is -1 (in that case, the actual range is indeterminate, i.e., + [0, PTRDIFF_MAX - 2]. */ bool get_range_strlen (tree arg, c_strlen_data *pdata, unsigned eltsize)