News for hackers. Stuff that matters.
Re:Benchmarking C++ Allocators by the8472 on Monday April 27, 2020 @04:22PM (#22999592)
My understanding is that compilers are allowed to treat malloc specially, i.e. they can assume that it returns non-aliasing memory, does not mutate other memory and can be elided if its result is unused.
Re:Benchmarking C++ Allocators by mehrdadn on Monday April 27, 2020 @05:29PM (#23000292)
I'm not aware of that being a blanket assumption they can make, is it? (Is it in the C++ standard?) That kind of thing is generally dictated by compiler-specific annotations (noalias etc.) which you can put on any function, and which shouldn't apply unless you write them explicitly...
Re:Benchmarking C++ Allocators by gpderetta on Monday April 27, 2020 @08:34PM (#23001979)
on gcc you can use __attribute__((malloc)) to tell the compiler that your function is malloc-like (i.e. its result type won't alias any other pointer), but any call to the litterall 'malloc' function itself is implicitly treated as such even if you do not include the appropriate header and declare it yourself (you can use -fno-builtin-functions or -free-standing or something like that to disable this treatment).
Re:Benchmarking C++ Allocators by jcranmer on Tuesday April 28, 2020 @01:03AM (#23003567)
LLVM is capable of eliminating calls to malloc if it can prove that they don't escape the function.
Re:Benchmarking C++ Allocators by saagarjha on Tuesday April 28, 2020 @03:24AM (#23004416)
Even if the allocation is large?