From: Siddhesh Poyarekar <siddhesh@gotplt.org>
To: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 1/3] gimple-fold: Transform stp*cpy_chk to str*cpy directly
Date: Sun, 14 Nov 2021 11:18:44 +0530 [thread overview]
Message-ID: <3d477ffe-1db4-1aa3-b72c-c16c02de0654@gotplt.org> (raw)
In-Reply-To: <CAAgBjMkj=aQhFOmZk=v8p1pq=zcZJ_4GXvxK_DuCjLKFHZruwQ@mail.gmail.com>
On 11/12/21 22:46, Prathamesh Kulkarni wrote:
> On Fri, 12 Nov 2021 at 01:12, Siddhesh Poyarekar <siddhesh@gotplt.org> wrote:
>>
>> Avoid going through another folding cycle and use the ignore flag to
>> directly transform BUILT_IN_STPCPY_CHK to BUILT_IN_STRCPY when set,
>> likewise for BUILT_IN_STPNCPY_CHK to BUILT_IN_STPNCPY.
>>
>> Dump the transformation in dump_file so that we can verify in tests that
>> the direct transformation actually happened.
>>
>> gcc/ChangeLog:
>>
>> * gimple-fold.c (gimple_fold_builtin_stxcpy_chk,
>> gimple_fold_builtin_stxncpy_chk): Use BUILT_IN_STRNCPY if return
>> value is not used.
>>
>> gcc/testsuite/ChangeLog:
>>
>> * gcc.dg/fold-stringops.c: New test.
>>
>> Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
>> ---
>> gcc/gimple-fold.c | 50 +++++++++++++++++--------
>> gcc/testsuite/gcc.dg/fold-stringops-1.c | 23 ++++++++++++
>> 2 files changed, 57 insertions(+), 16 deletions(-)
>> create mode 100644 gcc/testsuite/gcc.dg/fold-stringops-1.c
>>
>> diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
>> index 6e25a7c05db..92e15784803 100644
>> --- a/gcc/gimple-fold.c
>> +++ b/gcc/gimple-fold.c
>> @@ -3088,6 +3088,19 @@ gimple_fold_builtin_memory_chk (gimple_stmt_iterator *gsi,
>> return true;
>> }
>>
>> +static void
>> +dump_transformation (gimple *from, gimple *to)
> I assume that both from and to will always be builtin calls ?
> In that case, perhaps better to use gcall * here (and in rest of patch).
> Also, needs a top-level comment describing the function.
>> +{
>> + if (dump_file && (dump_flags & TDF_DETAILS))
> Perhaps better to use dump_enabled_p ?
>> + {
>> + fprintf (dump_file, "transformed ");
> Perhaps use dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, ...) ?
> I think you can use gimple_location to get the location.
>
Thanks, I'll fix these up.
Siddhesh
next prev parent reply other threads:[~2021-11-14 5:48 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 [this message]
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
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=3d477ffe-1db4-1aa3-b72c-c16c02de0654@gotplt.org \
--to=siddhesh@gotplt.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=prathamesh.kulkarni@linaro.org \
/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).