This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Add malloc predictor (PR middle-end/83023).
- From: Nathan Sidwell <nathan at acm dot org>
- To: Marc Glisse <marc dot glisse at inria dot fr>, Martin Liška <mliska at suse dot cz>
- Cc: gcc-patches at gcc dot gnu dot org, Jan Hubicka <hubicka at ucw dot cz>
- Date: Wed, 1 Aug 2018 08:11:33 -0700
- Subject: Re: [PATCH] Add malloc predictor (PR middle-end/83023).
- References: <firstname.lastname@example.org> <alpine.DEB.email@example.com> <firstname.lastname@example.org> <alpine.DEB.email@example.com> <firstname.lastname@example.org> <alpine.DEB.email@example.com>
On 08/01/2018 05:25 AM, Marc Glisse wrote:
Throwing new is returns_nonnull (errors are reported with exceptions) so
that's fine, but non-throwing new is not:
int* p1 = new(std::nothrow) int;
Here errors are reported by returning 0, so it is common to test if p1
is 0 and this is precisely the case that could benefit from a predictor
but does not have the attribute to do so (there are also consequences on
Agreed. both throwing and non-throwing operator new are malloc-like.
Placement new doesn't throw, it is explicitly defined to return the
passed in pointer (and it's not replaceable by the user). So may return
null, but I don't think any code (outside of a conformance testsuite)
would actually do that.
I can't find words that specify the return value of any allocation
function is unaliased to any existing object. The closest it gets is
that the non-placement forms might be implemented via malloc and friends.