This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] don't bzero->memset if cfun is memset




--On Thursday, July 11, 2002 07:27:47 PM -0400 DJ Delorie <dj@redhat.com> wrote:


I'm sorry; I guess I was unclear.  Of course you would you bzero
when c is zero; the point is that -- in tandem with my example --
you could end up with a legitimate recursion.
In the case where my patch takes effect, all I'm preventing is
replacing a call to bzero with a call to memset.  If the user codes a
call to memset within a memset function, my patch doesn't take effect.
The point is that calling bzero, where the compiler is turning calls
to bzero into calls to memset, is valid.  So, if memset calling memset
is sometimes reasonable, them memset calling bzero and the comnpiler
turning that into a recursive call to memset is also sometimes
reasonable.

Telling me my patch is wrong won't help solve that.  Tell me what you
want my patch to do, and I'll fix it.  I'm already adding the
DECL_ASSEMBLER_NAME code and fixing index and friends.
That's certainly good.  Adding some documentation around the discussion
of builtins would be good too.  Other than those items, I don't have
any technical issues with the patch -- it's what it's out to accomplish
that bothers me.

What kind of warning would make sense?  "Warning: your perfectly valid
call to bzero is being converted into an infinite loop" ?
We don't know that to be true.  At most we can think it somewhat likely.

What we do know is that, in general, the user wants bzero converted to
memset (or else she would have used -fno-builtin).

We also know that we'll have more code in the compiler; always a bad
thing.

We can suspect (although we don't know) that we haven't thought of
every possible case along these lines, and that now that we've handled
this one not handling those will be even more confusing.

We also know that in practice this alleged misfeature is only going to
occur for people writing C libraries, which is, thankfully, a small
percentage of all people using the compiler.

And we know that there's an easy work-around: using -fno-builtin.

So, I'd just say

 warning: replacing call to `bzero' with call to `memset'
 warning: which may result in infinite recursion
 warning: (to disable the replacement of this call, recompile with
 warning: -fno-builtin)

As always, I will bow to a consensus of the other maintainers, but
I don't think there's much win in the two of us debating this further.

--
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]