]> granicus.if.org Git - clang/commitdiff
remove my hacks that aggressively threw away multiple
authorChris Lattner <sabre@nondot.org>
Mon, 26 Jan 2009 20:24:53 +0000 (20:24 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 26 Jan 2009 20:24:53 +0000 (20:24 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63036 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/MacroArgs.cpp
lib/Lex/PPDirectives.cpp
lib/Lex/PPMacroExpansion.cpp
lib/Lex/TokenLexer.cpp

index c3d7738afe0df5fc917340fe541b6e80c9058dd8..7a805f349f2df281300c742bb56b2e6539e6f229 100644 (file)
@@ -120,12 +120,6 @@ MacroArgs::getPreExpArgument(unsigned Arg, Preprocessor &PP) {
     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
index 099dfb4aef09b934fc3cc47c7b49e5288f2c25bc..4bf012c1b119a49cc2831e047793ef6c33d09ca9 100644 (file)
@@ -1206,12 +1206,6 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) {
   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 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) {
     // 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
index b3e921c36894aa905b3a0389045ff409f57909d5..8eada6003d81dfbcfd299d1680db4175f965ad54 100644 (file)
@@ -340,13 +340,6 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
           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 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
     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;
index 7ae61beb8882d322f3a4401d3e51eda0b52b226e..40f6640cd75c0145bd0aa58af0c43daa84fdcafc 100644 (file)
@@ -33,12 +33,6 @@ void TokenLexer::Init(Token &Tok, MacroArgs *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();