]> granicus.if.org Git - llvm/commitdiff
Revert "Don't create a SymbolTable in Function when the LLVMContext discards value...
authorMehdi Amini <mehdi.amini@apple.com>
Sat, 17 Sep 2016 04:36:46 +0000 (04:36 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Sat, 17 Sep 2016 04:36:46 +0000 (04:36 +0000)
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

include/llvm/IR/Function.h
lib/IR/Function.cpp

index 46f5edea6274bc3744c3427af71df23c456f5bd0..129ba308004fae7026cb3e25f5791815f6ce8878 100644 (file)
@@ -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<ValueSymbolTable>
-      SymTab;                             ///< Symbol table of args/instructions
+  ValueSymbolTable *SymTab;               ///< Symbol table of args/instructions
   AttributeSet AttributeSets;             ///< Parameter attributes
 
   /*
index f9f33fef4524d2fb396dc9c79ca5237c56c53d02..fa34158e9c55eb0b49a506646ae0c8ec9c4d891c 100644 (file)
@@ -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<ValueSymbolTable>();
+  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();