This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C compile time


On Wed, 18 Jun 2003, Wolfgang Bangerth wrote:

> > Here is an idiom widely used in the LLVM code base, for example:
> > http://llvm.cs.uiuc.edu/doxygen/GCSE_8cpp-source.html
>
> Is this guaranteed to work? I mean, how can the address of a function with
> static linkage be used in a virtual function table? (I think it should work,
> since the vt can only be set up in this very file, but still...)

It is guaranteed to work, and the vtable itself should be marked static as
well.  The idea is that there is a public accessor function:

// createGCSEPass - The public interface to this file...
Pass *createGCSEPass() { return new GCSE(); }

Which indirectly exposes the pass to the outside world.

> > Besides the fact that my project would benefit a lot from this, if there
> > is no reason to not mark the methods static, we should.
>
> If the class itself is declared in a an anonymous namespace, I agree.
> Not that I'm opposed to your proposal, it's just that I don't see a whole lot
> of code out there that uses this idiom. I wouldn't want to trade this feature
> against another 10% slowdown in the compiler ;-)

Me neither!  This _shouldn't_ slow down the compiler at all, in fact I
expect it to help the linker and dynamic linkers a bit.  You're probably
right that not a whole lot of code uses anonymous namespaces, but I think
more and more is.  I don't think we should "mangle" C static functions
into "unique" names instead of marking them static, which is basically
the situation we are in with anon-namespaces now...

Perhaps I should file a (feature request) bug report?

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]