From: Richard Biener <richard.guenther@gmail.com>
To: Martin Sebor <msebor@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Subject: Re: [PATCH] handle bzero/bcopy in DSE and aliasing (PR 80933, 80934)
Date: Thu, 08 Jun 2017 07:51:00 -0000 [thread overview]
Message-ID: <CAFiYyc2Ne-DHweQ6QC1JmkpKH6SJo+AUz+M02Bs06zXv_t8NcA@mail.gmail.com> (raw)
In-Reply-To: <67a113e7-ee14-8afe-9deb-6c2c26927505@gmail.com>
On Thu, Jun 8, 2017 at 4:33 AM, Martin Sebor <msebor@gmail.com> wrote:
> On 06/07/2017 02:12 PM, Martin Sebor wrote:
>>
>> On 06/07/2017 02:01 PM, Marc Glisse wrote:
>>>
>>> On Wed, 7 Jun 2017, Bernhard Reutner-Fischer wrote:
>>>
>>>> On 7 June 2017 16:46:53 CEST, Martin Sebor <msebor@gmail.com> wrote:
>>>>>
>>>>> On 06/07/2017 02:23 AM, Richard Biener wrote:
>>>>>>
>>>>>> On Wed, Jun 7, 2017 at 5:26 AM, Martin Sebor <msebor@gmail.com>
>>>>>
>>>>> wrote:
>>>>>>>>
>>>>>>>> Note I'd be _much_ more sympathetic to simply canonicalizing all of
>>>>>>>> bzero and bcopy
>>>>>>>> to memset / memmove and be done with all the above complexity.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Attached is an updated patch along these lines. Please let me
>>>>>>> know if it matches your expectations.
>>>>>>
>>>>>>
>>>>>> I think you attached the wrong patch.
>>>>>
>>>>>
>>>>> Yes I did, sorry. The correct one is attached.
>>>>
>>>>
>>>> Under POSIX.1-2008 "optimizing" bzero or bcmp is IMO plain wrong.
>>>>
>>>> It's like optimizing foo() to a random built-in but maybe that's just
>>>> me. If your libc provides a define to a standard function for these
>>>> under a compat knob then fine but otherwise you should fix that.
>>>> *shrug*. Joseph?
>>>
>>>
>>> The patch optimizes __builtin_bzero, which should be ok. The question
>>> (independent from this patch) is then under what conditions bzero should
>>> be detected as a builtin.
>>
>>
>> Yes. The problem is that unlike for C and C++, GCC doesn't have
>> a mechanism to select the target version of POSIX. I think it
>> should.
>>
>> But there is a subtle problem with the patch that needs fixing.
>> Bcopy should not be transformed to memcpy but rather memmove.
>> I'll fix that before committing.
>
>
> Attached is an updated patch with this fix. I also added a cast
> from bcopy and bzero to void to detect accidental uses of the
> return value. Tested on x86_64-linux.
Please do not add foldings to builtins.c but instead add them to gimple-fold.c.
+ /* Call memset and return the result cast to void to detect its use
+ (bzero returns void). */
+ tree call = build_call_expr_loc (loc, fn, 3, dst, integer_zero_node, len);
+ return fold_convert (void_type_node, call);
??? How can the result be used if the original call result was not?
Thanks,
Richard.
> Martin
next prev parent reply other threads:[~2017-06-08 7:51 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-01 20:53 Martin Sebor
2017-06-02 11:12 ` Richard Biener
2017-06-04 15:36 ` Bernhard Reutner-Fischer
2017-06-06 16:54 ` Jeff Law
2017-06-07 3:26 ` Martin Sebor
2017-06-07 8:23 ` Richard Biener
2017-06-07 14:46 ` Martin Sebor
2017-06-07 18:37 ` Bernhard Reutner-Fischer
2017-06-07 20:01 ` Marc Glisse
2017-06-07 20:12 ` Martin Sebor
2017-06-08 2:33 ` Martin Sebor
2017-06-08 7:51 ` Richard Biener [this message]
2017-06-08 16:29 ` Martin Sebor
2017-06-09 12:35 ` Richard Biener
2017-06-09 13:04 ` Jakub Jelinek
2017-06-09 13:36 ` Richard Biener
2017-06-16 20:52 ` Martin Sebor
2017-06-07 20:23 ` Joseph Myers
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=CAFiYyc2Ne-DHweQ6QC1JmkpKH6SJo+AUz+M02Bs06zXv_t8NcA@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=msebor@gmail.com \
--cc=rep.dot.nop@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).