From 2eb43796082242045db4e05519df002cb2cab93e Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 24 Jul 2014 01:13:23 +0000 Subject: [PATCH] Remove unused Prev pointer from MacroInfo chain. Remove pointless MICache: it only ever contained up to 1 object, and was only non-empty when recovering from an error. There's no performance or memory win from maintaining this cache. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213825 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Lex/Preprocessor.h | 5 ----- lib/Lex/PPDirectives.cpp | 31 ++----------------------------- lib/Lex/Preprocessor.cpp | 4 ++-- 3 files changed, 4 insertions(+), 36 deletions(-) diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index d4b4ba2469..3686932fb3 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -433,17 +433,12 @@ private: // Cached tokens state. struct MacroInfoChain { MacroInfo MI; MacroInfoChain *Next; - MacroInfoChain *Prev; }; /// MacroInfos are managed as a chain for easy disposal. This is the head /// of that list. MacroInfoChain *MIChainHead; - /// A "freelist" of MacroInfo objects that can be reused for quick - /// allocation. - MacroInfoChain *MICache; - struct DeserializedMacroInfoChain { MacroInfo MI; unsigned OwningModuleID; // MUST be immediately after the MacroInfo object diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index a8e27c71da..c38080f715 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -34,23 +34,10 @@ using namespace clang; //===----------------------------------------------------------------------===// MacroInfo *Preprocessor::AllocateMacroInfo() { - MacroInfoChain *MIChain; - - if (MICache) { - MIChain = MICache; - MICache = MICache->Next; - } - else { - MIChain = BP.Allocate(); - } - + MacroInfoChain *MIChain = BP.Allocate(); MIChain->Next = MIChainHead; - MIChain->Prev = nullptr; - if (MIChainHead) - MIChainHead->Prev = MIChain; MIChainHead = MIChain; - - return &(MIChain->MI); + return &MIChain->MI; } MacroInfo *Preprocessor::AllocateMacroInfo(SourceLocation L) { @@ -101,20 +88,6 @@ Preprocessor::AllocateVisibilityMacroDirective(SourceLocation Loc, /// \brief Release the specified MacroInfo to be reused for allocating /// new MacroInfo objects. void Preprocessor::ReleaseMacroInfo(MacroInfo *MI) { - MacroInfoChain *MIChain = (MacroInfoChain *)MI; - if (MacroInfoChain *Prev = MIChain->Prev) { - MacroInfoChain *Next = MIChain->Next; - Prev->Next = Next; - if (Next) - Next->Prev = Prev; - } else { - assert(MIChainHead == MIChain); - MIChainHead = MIChain->Next; - MIChainHead->Prev = nullptr; - } - MIChain->Next = MICache; - MICache = MIChain; - MI->Destroy(); } diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 4a11803aa9..963b715716 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -70,7 +70,7 @@ Preprocessor::Preprocessor(IntrusiveRefCntPtr PPOpts, SkipMainFilePreamble(0, true), CurPPLexer(nullptr), CurDirLookup(nullptr), CurLexerKind(CLK_Lexer), CurSubmodule(nullptr), Callbacks(nullptr), MacroArgCache(nullptr), Record(nullptr), - MIChainHead(nullptr), MICache(nullptr), DeserialMIChainHead(nullptr) { + MIChainHead(nullptr), DeserialMIChainHead(nullptr) { OwnsHeaderSearch = OwnsHeaders; ScratchBuf = new ScratchBuffer(SourceMgr); @@ -142,7 +142,7 @@ Preprocessor::~Preprocessor() { IncludeMacroStack.clear(); // Free any macro definitions. - for (MacroInfoChain *I = MIChainHead ; I ; I = I->Next) + for (MacroInfoChain *I = MIChainHead; I; I = I->Next) I->MI.Destroy(); // Free any cached macro expanders. -- 2.40.0