Memory Allocation Optimized away with new by not with ::operator new

Hi,

I’ve made my own version of std::vector which is called il::Vector. Due to http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3664.html, LLVM can optimise away memory allocation. Therefore, the following code optimise away all memory allocation for w resulting in a single allocation during the whole program (for v).

When using my own vector implementation, I realised that the allocation were not optimized away because I was using ::operator new. When I’ve switched back to new, the optimisation came back.

Is it expected or a bug from LLVM?

François Fayard
Founder & Consultant - Inside Loop
Tel: +33 (0)6 01 44 06 93
Web: www.insideloop.io

Twitter: @insideloop_io

Didn’t we just have this discussion on cfe-dev? (or is there something different I’ve missed?)

I’ve missed it. I did a quick search and the only thread I found is back from 2013. Could you please provide me with a link to the thread?

François Fayard
Founder & Consultant - Inside Loop
Tel: +33 (0)6 01 44 06 93
Web: www.insideloop.io

Twitter: @insideloop_io

maybe you mist my post http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-May/085196.html

you have several root-postings in llvmdev (search for "Memory Allocation Optimized" in the archiv and you will see)
http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-May/thread.html

Sorry for the different root-postings. I’ve mixed up 2 different email address.

I’ve seen your post referring to this 2013 thread. It was very helpful thanks.