From: Mehdi Amini Date: Sat, 17 Sep 2016 04:36:46 +0000 (+0000) Subject: Revert "Don't create a SymbolTable in Function when the LLVMContext discards value... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=977635df54f2330ba187c1a257eae3a7cfdaa79a;p=llvm Revert "Don't create a SymbolTable in Function when the LLVMContext discards value names (NFC)" This reverts commit r281806. It introduces undefined behavior as an API is returning a reference to the Symtab git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281808 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/Function.h b/include/llvm/IR/Function.h index 46f5edea627..129ba308004 100644 --- a/include/llvm/IR/Function.h +++ b/include/llvm/IR/Function.h @@ -50,8 +50,7 @@ private: // Important things that make up a function! BasicBlockListType BasicBlocks; ///< The basic blocks mutable ArgumentListType ArgumentList; ///< The formal arguments - std::unique_ptr - SymTab; ///< Symbol table of args/instructions + ValueSymbolTable *SymTab; ///< Symbol table of args/instructions AttributeSet AttributeSets; ///< Parameter attributes /* diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp index f9f33fef452..fa34158e9c5 100644 --- a/lib/IR/Function.cpp +++ b/lib/IR/Function.cpp @@ -258,10 +258,7 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage, const Twine &name, assert(FunctionType::isValidReturnType(getReturnType()) && "invalid return type"); setGlobalObjectSubClassData(0); - - // We only need a symbol table for a function if the context keeps value names - if (!getContext().shouldDiscardValueNames()) - SymTab = make_unique(); + SymTab = new ValueSymbolTable(); // If the function has arguments, mark them as lazily built. if (Ty->getNumParams()) @@ -282,6 +279,7 @@ 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();