public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>,
	Jakub Jelinek <jakub@redhat.com>
Cc: gcc Patches <gcc-patches@gcc.gnu.org>,
	Richard Biener <rguenther@suse.de>,
	Martin Sebor <msebor@gmail.com>
Subject: Re: PR79715: Special case strcpy/strncpy for dse
Date: Tue, 28 Feb 2017 18:00:00 -0000	[thread overview]
Message-ID: <6844ba90-61e4-356b-0fb2-fa30693771d6@redhat.com> (raw)
In-Reply-To: <CAAgBjMnvg2uPWiZML8trM82B3z+JKKM1O_K=O8S-OYP1gWfz9g@mail.gmail.com>

On 02/28/2017 05:59 AM, Prathamesh Kulkarni wrote:
> On 28 February 2017 at 15:40, Jakub Jelinek <jakub@redhat.com> wrote:
>> On Tue, Feb 28, 2017 at 03:33:11PM +0530, Prathamesh Kulkarni wrote:
>>> Hi,
>>> The attached patch adds special-casing for strcpy/strncpy to dse pass.
>>> Bootstrapped+tested on x86_64-unknown-linux-gnu.
>>> OK for GCC 8 ?
>>
>> What is special on strcpy/strncpy?  Unlike memcpy/memmove/memset, you don't
>> know the length they store (at least not in general), you don't know the
>> value, all you know is that they are for the first argument plain store
>> without remembering the pointer or anything based on it anywhere except in
>> the return value.
>> I believe stpcpy, stpncpy, strcat, strncat at least have the same behavior.
>> On the other side, without knowing the length of the store, you can't treat
>> it as killing something (ok, some calls like strcpy or stpcpy store at least
>> the first byte).
> Well, I assumed a store to dest by strcpy (and friends), which gets
> immediately freed would count
> as a dead store since free would kill the whole memory block pointed
> to by dest ?
Yes.  But does it happen often in practice?  I wouldn't mind exploring 
this for gcc-8, but I'd like to see real-world code where this happens.

jeff

  reply	other threads:[~2017-02-28 17:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-28 10:05 Prathamesh Kulkarni
2017-02-28 10:19 ` Jakub Jelinek
2017-02-28 13:13   ` Prathamesh Kulkarni
2017-02-28 18:00     ` Jeff Law [this message]
2017-03-01  7:54       ` Richard Biener
2017-04-24  9:36         ` Prathamesh Kulkarni
2017-04-28 18:35           ` Jeff Law
2017-05-01 18:17             ` Richard Biener
2017-05-01 21:10               ` Jeff Law
2017-05-01 17:06           ` Martin Sebor

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=6844ba90-61e4-356b-0fb2-fa30693771d6@redhat.com \
    --to=law@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=msebor@gmail.com \
    --cc=prathamesh.kulkarni@linaro.org \
    --cc=rguenther@suse.de \
    /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).