[cfe-commits] r167800 - /cfe/trunk/lib/Lex/Lexer.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Nov 13 14:52:47 PST 2012


On Nov 12, 2012, at 6:48 PM, Sean Silva <silvas at purdue.edu> wrote:

> Did you heed the comment above LexTokenInternal to carefully benchmark
> any changes? If so, please cite the methodology and the results
> obtained.

I got the statistics from 80 runs of "clang -cc1 -Eonly -x objective-c++ t.m" where t.m is

#import <Cocoa/Cocoa.h>
#import <vector>
#import <string>
#import <map>

r167799:
name	  avg  	  min  	  med  	  max  	   SD  	 total 
user	 0.1176	 0.1164	 0.1174	 0.1211	 0.0008	 9.4071
sys		0.0503	 0.0508	 0.0501	 0.0542	 0.0008	 4.0226
wall		0.1705	 0.1688	 0.1697	 0.1784	 0.0015	13.6381

r167800:
name	  avg  	  min  	  med  	  max  	   SD  	 total 
user	 0.1175	 0.1162	 0.1174	 0.1202	 0.0008	 9.3977
sys		0.0501	 0.0489	 0.0497	 0.0501	 0.0007	 4.0106
wall		0.1703	 0.1682	 0.1703	 0.1734	 0.0014	13.6219

r167801:
name	  avg  	  min  	  med  	  max  	   SD  	 total 
user	 0.1181	 0.1166	 0.1180	 0.1218	 0.0009	 9.4467
 sys		0.0486	 0.0488	 0.0485	 0.0508	 0.0010	 3.8909
wall		0.1694	 0.1673	 0.1689	 0.1757	 0.0016	13.5489


> 
> -- Sean Silva
> 
> On Mon, Nov 12, 2012 at 8:02 PM, Argyrios Kyrtzidis <akyrtzi at gmail.com> wrote:
>> Author: akirtzidis
>> Date: Mon Nov 12 19:02:40 2012
>> New Revision: 167800
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=167800&view=rev
>> Log:
>> In Lexer::LexTokenInternal, avoid code duplication; no functionality change.
>> 
>> Modified:
>>    cfe/trunk/lib/Lex/Lexer.cpp
>> 
>> Modified: cfe/trunk/lib/Lex/Lexer.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=167800&r1=167799&r2=167800&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Lex/Lexer.cpp (original)
>> +++ cfe/trunk/lib/Lex/Lexer.cpp Mon Nov 12 19:02:40 2012
>> @@ -3019,26 +3019,8 @@
>>         // it's actually the start of a preprocessing directive.  Callback to
>>         // the preprocessor to handle it.
>>         // FIXME: -fpreprocessed mode??
>> -        if (Result.isAtStartOfLine() && !LexingRawMode && !Is_PragmaLexer) {
>> -          FormTokenWithChars(Result, CurPtr, tok::hash);
>> -          PP->HandleDirective(Result);
>> -
>> -          // As an optimization, if the preprocessor didn't switch lexers, tail
>> -          // recurse.
>> -          if (PP->isCurrentLexer(this)) {
>> -            // Start a new token. If this is a #include or something, the PP may
>> -            // want us starting at the beginning of the line again.  If so, set
>> -            // the StartOfLine flag and clear LeadingSpace.
>> -            if (IsAtStartOfLine) {
>> -              Result.setFlag(Token::StartOfLine);
>> -              Result.clearFlag(Token::LeadingSpace);
>> -              IsAtStartOfLine = false;
>> -            }
>> -            goto LexNextToken;   // GCC isn't tail call eliminating.
>> -          }
>> -
>> -          return PP->Lex(Result);
>> -        }
>> +        if (Result.isAtStartOfLine() && !LexingRawMode && !Is_PragmaLexer)
>> +          goto HandleDirective;
>> 
>>         Kind = tok::hash;
>>       }
>> @@ -3203,25 +3185,8 @@
>>       // it's actually the start of a preprocessing directive.  Callback to
>>       // the preprocessor to handle it.
>>       // FIXME: -fpreprocessed mode??
>> -      if (Result.isAtStartOfLine() && !LexingRawMode && !Is_PragmaLexer) {
>> -        FormTokenWithChars(Result, CurPtr, tok::hash);
>> -        PP->HandleDirective(Result);
>> -
>> -        // As an optimization, if the preprocessor didn't switch lexers, tail
>> -        // recurse.
>> -        if (PP->isCurrentLexer(this)) {
>> -          // Start a new token.  If this is a #include or something, the PP may
>> -          // want us starting at the beginning of the line again.  If so, set
>> -          // the StartOfLine flag and clear LeadingSpace.
>> -          if (IsAtStartOfLine) {
>> -            Result.setFlag(Token::StartOfLine);
>> -            Result.clearFlag(Token::LeadingSpace);
>> -            IsAtStartOfLine = false;
>> -          }
>> -          goto LexNextToken;   // GCC isn't tail call eliminating.
>> -        }
>> -        return PP->Lex(Result);
>> -      }
>> +      if (Result.isAtStartOfLine() && !LexingRawMode && !Is_PragmaLexer)
>> +        goto HandleDirective;
>> 
>>       Kind = tok::hash;
>>     }
>> @@ -3248,4 +3213,26 @@
>> 
>>   // Update the location of token as well as BufferPtr.
>>   FormTokenWithChars(Result, CurPtr, Kind);
>> +  return;
>> +
>> +HandleDirective:
>> +  // We parsed a # character and it's the start of a preprocessing directive.
>> +
>> +  FormTokenWithChars(Result, CurPtr, tok::hash);
>> +  PP->HandleDirective(Result);
>> +
>> +  // As an optimization, if the preprocessor didn't switch lexers, tail
>> +  // recurse.
>> +  if (PP->isCurrentLexer(this)) {
>> +    // Start a new token.  If this is a #include or something, the PP may
>> +    // want us starting at the beginning of the line again.  If so, set
>> +    // the StartOfLine flag and clear LeadingSpace.
>> +    if (IsAtStartOfLine) {
>> +      Result.setFlag(Token::StartOfLine);
>> +      Result.clearFlag(Token::LeadingSpace);
>> +      IsAtStartOfLine = false;
>> +    }
>> +    goto LexNextToken;   // GCC isn't tail call eliminating.
>> +  }
>> +  return PP->Lex(Result);
>> }
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list