From: Mehdi Amini Date: Sat, 17 Sep 2016 03:39:01 +0000 (+0000) Subject: Don't create a SymbolTable in Function when the LLVMContext discards value names... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3e722b9108e5cbb8d4242fd80a8382c8cd57bbe;p=llvm Don't create a SymbolTable in Function when the LLVMContext discards value names (NFC) The ValueSymbolTable is used to detect name conflict and rename instructions automatically. This is not needed when the value names are automatically discarded by the LLVMContext. No functional change intended, just saving a little bit of memory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281806 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/Function.h b/include/llvm/IR/Function.h index 129ba308004..46f5edea627 100644 --- a/include/llvm/IR/Function.h +++ b/include/llvm/IR/Function.h @@ -50,7 +50,8 @@ private: // Important things that make up a function! BasicBlockListType BasicBlocks; ///< The basic blocks mutable ArgumentListType ArgumentList; ///< The formal arguments - ValueSymbolTable *SymTab; ///< Symbol table of args/instructions + std::unique_ptr + SymTab; ///< Symbol table of args/instructions AttributeSet AttributeSets; ///< Parameter attributes /* diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp index fa34158e9c5..f9f33fef452 100644 --- a/lib/IR/Function.cpp +++ b/lib/IR/Function.cpp @@ -258,7 +258,10 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage, const Twine &name, assert(FunctionType::isValidReturnType(getReturnType()) && "invalid return type"); setGlobalObjectSubClassData(0); - SymTab = new ValueSymbolTable(); + + // We only need a symbol table for a function if the context keeps value names + if (!getContext().shouldDiscardValueNames()) + SymTab = make_unique(); // If the function has arguments, mark them as lazily built. if (Ty->getNumParams()) @@ -279,7 +282,6 @@ Function::~Function() { // Delete all of the method arguments and unlink from symbol table... ArgumentList.clear(); - delete SymTab; // Remove the function from the on-the-side GC table. clearGC();