[cfe-commits] r62992 - /cfe/trunk/lib/Lex/TokenLexer.cpp

Chris Lattner sabre at nondot.org
Sun Jan 25 19:46:22 PST 2009


Author: lattner
Date: Sun Jan 25 21:46:22 2009
New Revision: 62992

URL: http://llvm.org/viewvc/llvm-project?rev=62992&view=rev
Log:
Only resolve a macro's instantiation loc once per macro, instead of once
per token lexed from it.  This speeds up clang on c99-intconst-1.c from
the GCC testsuite from 3.64s to 2.66s (36%).  This reduces the number of
binary search FileID lookups from 251570522 to 114175649 on this testcase.

Modified:
    cfe/trunk/lib/Lex/TokenLexer.cpp

Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=62992&r1=62991&r2=62992&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Sun Jan 25 21:46:22 2009
@@ -31,7 +31,14 @@
   Macro = PP.getMacroInfo(Tok.getIdentifierInfo());
   ActualArgs = Actuals;
   CurToken = 0;
+  
   InstantiateLoc = Tok.getLocation();
+
+  // If the instantiation loc is not already a FileID, resolve it here.  If we
+  // don't do this, we end up doing it once per token lexed.
+  if (!InstantiateLoc.isFileID())
+    InstantiateLoc = PP.getSourceManager().getInstantiationLoc(InstantiateLoc);
+  
   AtStartOfLine = Tok.isAtStartOfLine();
   HasLeadingSpace = Tok.hasLeadingSpace();
   Tokens = &*Macro->tokens_begin();





More information about the cfe-commits mailing list