public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marc Glisse <marc.glisse@inria.fr>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org,
	    Gabriel Dos Reis <gdr@integrable-solutions.net>
Subject: Re: [PATCH] Add __attribute__((malloc) to allocator and remove unused code
Date: Thu, 17 May 2018 11:01:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.21.1805171230450.22383@stedding.saclay.inria.fr> (raw)
In-Reply-To: <20180514153713.GA4320@redhat.com>

On Mon, 14 May 2018, Jonathan Wakely wrote:

> As discussed at https://gcc.gnu.org/ml/libstdc++/2018-01/msg00073.html
> we can simplify the allocator function for valarray memory. I also
> noticed that the _Array(size_t) constructor is never used.
>
> 	* include/bits/valarray_array.h (__valarray_get_memory): Remove.
> 	(__valarray_get_storage): Call operator new directly. Remove ignored
> 	top-level restrict qualifier and add malloc attribute instead.

I am trying to understand the point of adding this attribute. The function 
is just

{ return static_cast<_Tp*>(operator new(__n * sizeof(_Tp))); }

The idea is that it isn't safe (? see PR 23383) to mark operator new with 
the attribute, but it is safe for this particular use?

When optimizing, I certainly hope this trivial function gets inlined, and 
then the attribute is lost (should the inliner add 'restrict' when 
inlining a function with attribute malloc?) and all that matters is 
operator new.

-- 
Marc Glisse

  reply	other threads:[~2018-05-17 10:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-14 15:55 Jonathan Wakely
2018-05-17 11:01 ` Marc Glisse [this message]
2018-05-17 11:14   ` Jonathan Wakely
2018-05-17 11:25     ` Marc Glisse
2018-05-17 11:29       ` Richard Biener
2018-05-17 12:05         ` Marc Glisse
2018-05-17 13:39           ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.21.1805171230450.22383@stedding.saclay.inria.fr \
    --to=marc.glisse@inria.fr \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gdr@integrable-solutions.net \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).