This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: number of vector template instances and pointers
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: GCC Mailing List <gcc at gcc dot gnu dot org>
- Cc: Fery <engard dot ferenc at innomed dot hu>,"crossgcc at sources dot redhat dot com" <crossgcc at sources dot redhat dot com>
- Date: Mon, 20 Sep 2004 09:25:22 -0700
- Subject: Re: number of vector template instances and pointers
- References: <414EAD5B.C7A34222@innomed.hu> <414EEF30.7030800@kegel.com>
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.