[llvm] r179071 - c++ new operators are not malloc-like functions because they do not return uninitialized memory.

Evan Cheng evan.cheng at apple.com
Thu Apr 11 22:45:32 PDT 2013



Sent from my iPad

On Apr 11, 2013, at 9:05 PM, Chandler Carruth <chandlerc at google.com> wrote:

> On Tue, Apr 9, 2013 at 8:48 AM, Evan Cheng <evan.cheng at apple.com> wrote:
>> How do other compilers handle this? Requiring -fno-builtins doesn't seem user friendly.
> 
> I don't know of other compilers that handle this, my suspicion is that they just don't optimize operator new effectively.
> 
> I agree that -fno-builtins isn't user friendly, but I'm not really sure how to design a user friendly interface here because we've actually never seen code that needed this. Can you give examples of the kinds of things you're seeing users want to do here? (I'm happy with contrived examples, I understand the actual code may not be sharable, but as long as the fundamental optimization that ceases to apply is clear that should be enough.)

We received report of a miscompilation when a developer overrode new with one that clears memory and has code that depends on the behavior. 

An slightly less unfriendly solution would be -fno-builtin-new. 

Evan

> 
> I also have co-authored a paper for the C++ committee (and the C committee, but I'm following that less) that may be relevant to folks with interest in how we optimize allocation functions: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3537.html
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130411/7f5228f3/attachment.html>


More information about the llvm-commits mailing list