public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: number of vector template instances and pointers
       [not found] <414EAD5B.C7A34222@innomed.hu>
@ 2004-09-20 15:40 ` Dan Kegel
  2004-09-20 17:48   ` Joe Buck
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Kegel @ 2004-09-20 15:40 UTC (permalink / raw)
  To: Fery; +Cc: crossgcc, GCC Mailing List

Fery wrote:
> When I create two vectors with different pointer types (e.g.
> vector<char*> and vector<int*>), gcc compiles in two instances of vector
> code. In SH architecture, it means cca. n * 10K of code, which is quite
> big in our project.
> 
> The question is, can I somehow force the compiler to use the same code
> for the two template instances?

If the object code generated for the two is really identical,
then if you really wanted to, you could write a whole-program
optimizer pass that combined them.

This is a topic for the gcc or libstdc++ mailing lists, though,
where people actually know something about this, so I'm redirecting there.
- Dan

-- 
My technical stuff: http://kegel.com
My politics: see http://www.misleader.org for examples of why I'm for regime change

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: number of vector template instances and pointers
  2004-09-20 15:40 ` number of vector template instances and pointers Dan Kegel
@ 2004-09-20 17:48   ` Joe Buck
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Buck @ 2004-09-20 17:48 UTC (permalink / raw)
  To: GCC Mailing List; +Cc: Fery, crossgcc


Fery wrote:
> > When I create two vectors with different pointer types (e.g.
> > vector<char*> and vector<int*>), gcc compiles in two instances of vector
> > code. In SH architecture, it means cca. n * 10K of code, which is quite
> > big in our project.
> > 
> > The question is, can I somehow force the compiler to use the same code
> > for the two template instances?

The answer at the moment is no.

On Mon, Sep 20, 2004 at 07:54:40AM -0700, Dan Kegel wrote:
> If the object code generated for the two is really identical,
> then if you really wanted to, you could write a whole-program
> optimizer pass that combined them.

It would be possible to refactor libstdc++ so that it uses the same
code for those functions of Container<POD> whose code only depends on
sizeof<POD>.  Alternatively and more simply, there could be a
specialization just for Container<T*> that would use common code.
That work has not yet been done.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-09-20 16:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <414EAD5B.C7A34222@innomed.hu>
2004-09-20 15:40 ` number of vector template instances and pointers Dan Kegel
2004-09-20 17:48   ` Joe Buck

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).