From a53d49e1b547a9658be46865d687aeb481b3b32c Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Sat, 17 Sep 2016 06:00:02 +0000 Subject: 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. This is a recommit of r281806 after fixing the accessor to return a pointer instead of a reference and updating all the call-sites. llvm-svn: 281813 --- llvm/lib/IR/Function.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'llvm/lib/IR/Function.cpp') diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index fa34158e9c5..f9f33fef452 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/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(); -- cgit v1.2.3