[cfe-commits] r63036 - in /cfe/trunk/lib/Lex: MacroArgs.cpp PPDirectives.cpp PPMacroExpansion.cpp TokenLexer.cpp

Chris Lattner sabre at nondot.org
Mon Jan 26 12:24:54 PST 2009


Author: lattner
Date: Mon Jan 26 14:24:53 2009
New Revision: 63036

URL: http://llvm.org/viewvc/llvm-project?rev=63036&view=rev
Log:
remove my hacks that aggressively threw away multiple 
instantiation history in an effort to speed up c99-intconst-1.c.
Now that multiple nested instantiations are allowed, we just
make them and don't pay the cost of lookups.  With the other
changes that went in before this, reverting this is actually
a speedup for c99-intconst-1.c, speeding it up from 1.96s to 1.80s,
and preserves much better loc info.

Modified:
    cfe/trunk/lib/Lex/MacroArgs.cpp
    cfe/trunk/lib/Lex/PPDirectives.cpp
    cfe/trunk/lib/Lex/PPMacroExpansion.cpp
    cfe/trunk/lib/Lex/TokenLexer.cpp

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

==============================================================================
--- cfe/trunk/lib/Lex/MacroArgs.cpp (original)
+++ cfe/trunk/lib/Lex/MacroArgs.cpp Mon Jan 26 14:24:53 2009
@@ -120,12 +120,6 @@
     Result.push_back(Token());
     Token &Tok = Result.back();
     PP.Lex(Tok);
-    
-    // Eagerly resolve instantiation ID's to their spelling location.  This
-    // makes it so we only have to get the spelling loc once per macro argument
-    // preexpansion instead of once per each time the token is expanded.
-    if (!Tok.getLocation().isFileID())
-      Tok.setLocation(PP.getSourceManager().getSpellingLoc(Tok.getLocation()));
   } while (Result.back().isNot(tok::eof));
   
   // Pop the token stream off the top of the stack.  We know that the internal

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

==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Mon Jan 26 14:24:53 2009
@@ -1206,12 +1206,6 @@
   if (MI->isObjectLike()) {
     // Object-like macros are very simple, just read their body.
     while (Tok.isNot(tok::eom)) {
-      // If this token has a virtual location, resolve it down to its spelling
-      // location.  This is not strictly needed, but avoids extra resolutions
-      // for macros that are expanded frequently.
-      if (!Tok.getLocation().isFileID())
-        Tok.setLocation(SourceMgr.getSpellingLoc(Tok.getLocation()));
-      
       MI->AddTokenToBody(Tok);
       // Get the next token of the macro.
       LexUnexpandedToken(Tok);
@@ -1221,12 +1215,6 @@
     // Otherwise, read the body of a function-like macro.  This has to validate
     // the # (stringize) operator.
     while (Tok.isNot(tok::eom)) {
-      // If this token has a virtual location, resolve it down to its spelling
-      // location.  This is not strictly needed, but avoids extra resolutions
-      // for macros that are expanded frequently.
-      if (!Tok.getLocation().isFileID())
-        Tok.setLocation(SourceMgr.getSpellingLoc(Tok.getLocation()));
-      
       MI->AddTokenToBody(Tok);
 
       // Check C99 6.10.3.2p1: ensure that # operators are followed by macro

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

==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Mon Jan 26 14:24:53 2009
@@ -340,13 +340,6 @@
           if (!MI->isEnabled())
             Tok.setFlag(Token::DisableExpand);
       }
-      
-      // If this token has instantiation location, resolve it down to its
-      // spelling location.  This is not strictly needed, but avoids extra
-      // resolutions for macros that are expanded frequently.
-      if (!Tok.getLocation().isFileID())
-        Tok.setLocation(SourceMgr.getSpellingLoc(Tok.getLocation()));
-  
       ArgTokens.push_back(Tok);
     }
 
@@ -359,7 +352,7 @@
     Token EOFTok;
     EOFTok.startToken();
     EOFTok.setKind(tok::eof);
-    EOFTok.setLocation(SourceMgr.getSpellingLoc(Tok.getLocation()));
+    EOFTok.setLocation(Tok.getLocation());
     EOFTok.setLength(0);
     ArgTokens.push_back(EOFTok);
     ++NumActuals;

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

==============================================================================
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Mon Jan 26 14:24:53 2009
@@ -33,12 +33,6 @@
   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