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]

Re: PCH, and more generally C++ parser performance


> From: Joe Buck <jbuck@racerx.synopsys.com>
> Date: Tue, 29 Aug 2000 17:31:27 -0700 (PDT)
> Cc: zack@wolery.cumb.org (Zack Weinberg), shebs@apple.com (Stan Shebs),
>         gcc@gcc.gnu.org
> 
> 
> > I claim (and I'd be interested to know if anyone has a counterexample)
> > that if an identifier is never used other than to be declared or
> > defined, then program behaviour is the same as if those declarations
> > were never made.
> 
> There are a couple of things that you're of course already aware of, like
> constructors and destructors that may have side effects, and the impact
> that the existence of a declaration may have on name resolution.

I did indeed think of those.

Constructors, destructors, variable definitions, non-inline procedure
definitions all have to be handled specially, because they all produce
assembler output.  You can't lazily compile

int x = 3;

even in C because even if 'x' is never used in a particular
compilation unit, some other unit might use it.  The options I see for
such code are:

- don't allow these
- don't precompile these
- save a chunk of assembler input which gets stuck in when the PCH is
  used.  This would have the disadvantage that you could have
  conflicts if any assembler was output before the PCH was included,
  so you would have to prohibit this.
- be really clever, make sure the assembler has no conflicts
  by (say) renaming internal symbols.  This would be hard.

My instinct is to start by implementing the first or second, and then
extend it later if that turns out to be too slow.

As for name resolution, I claim that if an identifier 'x' is never
used other than to be declared or defined, it is never relevant to
name resolution.  I suspect that when I get involved in this the first
thing I'll need to do is go through the standards and check that this
is true for C++.  (At least I know it's true in C :-).  The incredibly
complicated C++ name resolution rules were very near the front of my
mind when I was thinking about this.

-- 
- Geoffrey Keating <geoffk@cygnus.com>

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