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: timing of lexical analysis in -ftime-report


blhewitt at attbi dot com writes:

> Hi, I hope that this is the appropriate forum for my question.  I'm very 
> uncertain that this is a defect in gcc - I'm just looking for a better 
> understanding of what gcc is doing.
>
> I've been looking at gcc internals (specifically gcc 3.2.2) for a class I'm 
> taking, and I've observed that the function _cpp_lex_direct in cpplex.c 
> appears to be doing what would be considered lexical analysis in compiler 
> theory.

This is true.

> However, since this function is called by cpp_get_token in c_lex.c 
> (with a few functions in between), -ftime-report classifies any time spent in 
> the _cpp_lex_direct function as "preprocessing" (TV_CPP).

This is also true.

> My question then: Are the phases reported in -ftime-report intended to 
> correspond at all closely to "traditional" notions of compiler phases?  If 
> not, is the intention for -ftime-report to just give a starting point to 
> compare the performance of different sections of gcc, and the phase ids are 
> really just an id for a particular gcc section meant to be used for reference 
> and not for theoretical application?

The primary function is indeed to give a starting point for
performance comparisons of different sections of gcc.  But we do
intend the names of the different passes to reflect what they are
called in compiler theory, because that makes it easier to understand.

For C and its descendants, it happens that the preprocessor has to do
almost all the work of lexical analysis, and there's no point in doing
it twice.  Thus, the majority of time performing lexical analysis
happens under TV_CPP.  If you were to look at, say, Fortran source
code you would find that lexical analysis is attributed to TV_LEX,
since that language does not use the C preprocessor.

zw


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