[llvm] r281808 - Revert "Don't create a SymbolTable in Function when the LLVMContext discards value names (NFC)"

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 16 21:36:47 PDT 2016


Author: mehdi_amini
Date: Fri Sep 16 23:36:46 2016
New Revision: 281808

URL: http://llvm.org/viewvc/llvm-project?rev=281808&view=rev
Log:
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

Modified:
    llvm/trunk/include/llvm/IR/Function.h
    llvm/trunk/lib/IR/Function.cpp

Modified: llvm/trunk/include/llvm/IR/Function.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Function.h?rev=281808&r1=281807&r2=281808&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Function.h (original)
+++ llvm/trunk/include/llvm/IR/Function.h Fri Sep 16 23:36:46 2016
@@ -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
 
   /*

Modified: llvm/trunk/lib/IR/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=281808&r1=281807&r2=281808&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Function.cpp (original)
+++ llvm/trunk/lib/IR/Function.cpp Fri Sep 16 23:36:46 2016
@@ -258,10 +258,7 @@ Function::Function(FunctionType *Ty, Lin
   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();




More information about the llvm-commits mailing list