From: Siddhesh Poyarekar <siddhesh@gotplt.org>
To: Jeff Law <jeffreyalaw@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v2 2/3] gimple-fold: Use ranges to simplify _chk calls
Date: Tue, 16 Nov 2021 04:23:12 +0530 [thread overview]
Message-ID: <9ec6de5e-9ac0-af0c-a2c9-70325dc03ed1@gotplt.org> (raw)
In-Reply-To: <c6946a77-99f2-ac6b-78ad-259acb271b49@gmail.com>
On 11/16/21 01:55, Jeff Law wrote:
>
>
> On 11/15/2021 10:33 AM, Siddhesh Poyarekar wrote:
>> Instead of comparing LEN and SIZE only if they are constants, use their
>> ranges to decide if LEN will always be lower than or same as SIZE.
>>
>> This change ends up putting the stringop-overflow warning line number
>> against the strcpy implementation, so adjust the warning check to be
>> line number agnostic.
>>
>> gcc/ChangeLog:
>>
>> * gimple-fold.c (known_lower): New function.
>> (gimple_fold_builtin_strncat_chk,
>> gimple_fold_builtin_memory_chk, gimple_fold_builtin_stxcpy_chk,
>> gimple_fold_builtin_stxncpy_chk,
>> gimple_fold_builtin_snprintf_chk,
>> gimple_fold_builtin_sprintf_chk): Use it.
>>
>> gcc/testsuite/ChangeLog:
>>
>> * gcc.dg/Wobjsize-1.c: Make warning change line agnostic.
>> * gcc.dg/builtin-chk-fold.c: New test.
>>
>>
>
>> @@ -3024,39 +3040,24 @@ gimple_fold_builtin_memory_chk
>> (gimple_stmt_iterator *gsi,
>> }
>> }
>> - if (! tree_fits_uhwi_p (size))
>> - return false;
>> -
>> tree maxlen = get_maxval_strlen (len, SRK_INT_VALUE);
>> - if (! integer_all_onesp (size))
>> + if (! integer_all_onesp (size)
>> + && !known_lower (stmt, len, size) && !known_lower (stmt,
>> maxlen, size))
> Formatting it. Move the trailing && !known_lower (...) to its own line.
>
> OK with the formatting nit fixed.
Thanks, I fixed the nit and pushed the series.
Siddhesh
next prev parent reply other threads:[~2021-11-15 22:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-11 19:41 [PATCH 0/3] gimple-fold improvements Siddhesh Poyarekar
2021-11-11 19:41 ` [PATCH 1/3] gimple-fold: Transform stp*cpy_chk to str*cpy directly Siddhesh Poyarekar
2021-11-12 17:16 ` Prathamesh Kulkarni
2021-11-14 5:48 ` Siddhesh Poyarekar
2021-11-11 19:41 ` [PATCH 2/3] gimple-fold: Use ranges to simplify _chk calls Siddhesh Poyarekar
2021-11-11 19:41 ` [PATCH 3/3] gimple-fold: Use ranges to simplify strncat and snprintf Siddhesh Poyarekar
2021-11-15 10:41 ` Siddhesh Poyarekar
2021-11-15 17:33 ` [PATCH v2 0/3] gimple-fold improvements Siddhesh Poyarekar
2021-11-15 17:33 ` [PATCH v2 1/3] gimple-fold: Transform stp*cpy_chk to str*cpy directly Siddhesh Poyarekar
2021-11-15 19:17 ` Jeff Law
2021-11-15 17:33 ` [PATCH v2 2/3] gimple-fold: Use ranges to simplify _chk calls Siddhesh Poyarekar
2021-11-15 20:25 ` Jeff Law
2021-11-15 22:53 ` Siddhesh Poyarekar [this message]
2021-11-15 17:33 ` [PATCH v2 3/3] gimple-fold: Use ranges to simplify strncat and snprintf Siddhesh Poyarekar
2021-11-15 19:38 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9ec6de5e-9ac0-af0c-a2c9-70325dc03ed1@gotplt.org \
--to=siddhesh@gotplt.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).