[llvm-commits] CVS: llvm/include/llvm/Function.h LinkAllPasses.h Module.h Value.h ValueSymbolTable.h SymbolTable.h

Reid Spencer reid at x10sys.com
Mon Feb 5 12:48:33 PST 2007



Changes in directory llvm/include/llvm:

Function.h updated: 1.71 -> 1.72
LinkAllPasses.h updated: 1.8 -> 1.9
Module.h updated: 1.81 -> 1.82
Value.h updated: 1.90 -> 1.91
ValueSymbolTable.h updated: 1.3 -> 1.4
SymbolTable.h (r1.54) removed
---
Log message:

For PR411: http://llvm.org/PR411 :
This patch replaces the SymbolTable class with ValueSymbolTable which does
not support types planes. This means that all symbol names in LLVM must now
be unique. The patch addresses the necessary changes to deal with this and
removes code no longer needed as a result. This completes the bulk of the
changes for this PR. Some cleanup patches will follow.


---
Diffs of the changes:  (+27 -19)

 Function.h         |    6 +++---
 LinkAllPasses.h    |    1 -
 Module.h           |   24 +++++++++++++-----------
 Value.h            |    3 ++-
 ValueSymbolTable.h |   12 +++++++++---
 5 files changed, 27 insertions(+), 19 deletions(-)


Index: llvm/include/llvm/Function.h
diff -u llvm/include/llvm/Function.h:1.71 llvm/include/llvm/Function.h:1.72
--- llvm/include/llvm/Function.h:1.71	Tue Jan 30 14:08:38 2007
+++ llvm/include/llvm/Function.h	Mon Feb  5 14:47:19 2007
@@ -63,7 +63,7 @@
   BasicBlockListType  BasicBlocks;      // The basic blocks
   ArgumentListType ArgumentList;        // The formal arguments
 
-  SymbolTable *SymTab;
+  ValueSymbolTable *SymTab;
   unsigned CallingConvention;
 
   friend class SymbolTableListTraits<Function, Module, Module>;
@@ -156,8 +156,8 @@
 
   /// getSymbolTable() - Return the symbol table...
   ///
-  inline       SymbolTable &getValueSymbolTable()       { return *SymTab; }
-  inline const SymbolTable &getValueSymbolTable() const { return *SymTab; }
+  inline       ValueSymbolTable &getValueSymbolTable()       { return *SymTab; }
+  inline const ValueSymbolTable &getValueSymbolTable() const { return *SymTab; }
 
 
   //===--------------------------------------------------------------------===//


Index: llvm/include/llvm/LinkAllPasses.h
diff -u llvm/include/llvm/LinkAllPasses.h:1.8 llvm/include/llvm/LinkAllPasses.h:1.9
--- llvm/include/llvm/LinkAllPasses.h:1.8	Sat Feb  3 17:15:56 2007
+++ llvm/include/llvm/LinkAllPasses.h	Mon Feb  5 14:47:19 2007
@@ -64,7 +64,6 @@
       (void) llvm::createEmitFunctionTablePass();
       (void) llvm::createFunctionInliningPass();
       (void) llvm::createFunctionProfilerPass();
-      (void) llvm::createFunctionResolvingPass();
       (void) llvm::createGCSEPass();
       (void) llvm::createGlobalDCEPass();
       (void) llvm::createGlobalOptimizerPass();


Index: llvm/include/llvm/Module.h
diff -u llvm/include/llvm/Module.h:1.81 llvm/include/llvm/Module.h:1.82
--- llvm/include/llvm/Module.h:1.81	Sat Feb  3 18:40:41 2007
+++ llvm/include/llvm/Module.h	Mon Feb  5 14:47:19 2007
@@ -23,8 +23,6 @@
 class GlobalVariable;
 class GlobalValueRefMap;   // Used by ConstantVals.cpp
 class FunctionType;
-class SymbolTable;
-class TypeSymbolTable;
 
 template<> struct ilist_traits<Function>
   : public SymbolTableListTraits<Function, Module, Module> {
@@ -91,7 +89,7 @@
   FunctionListType FunctionList; ///< The Functions in the module
   LibraryListType LibraryList;   ///< The Libraries needed by the module
   std::string GlobalScopeAsm;    ///< Inline Asm at global scope.
-  SymbolTable *ValSymTab;        ///< Symbol table for values
+  ValueSymbolTable *ValSymTab;   ///< Symbol table for values
   TypeSymbolTable *TypeSymTab;   ///< Symbol table for types
   std::string ModuleID;          ///< Human readable identifier for the module
   std::string TargetTriple;      ///< Platform target triple Module compiled on
@@ -178,17 +176,19 @@
 
   /// getFunction - Look up the specified function in the module symbol table.
   /// If it does not exist, return null.
-  Function *getFunction(const std::string &Name, const FunctionType *Ty);
+  Function *getFunction(const std::string &Name) const;
 
   /// getMainFunction - This function looks up main efficiently.  This is such a
   /// common case, that it is a method in Module.  If main cannot be found, a
   /// null pointer is returned.
-  Function *getMainFunction();
+  Function *getMainFunction() { return getFunction("main"); }
 
   /// getNamedFunction - Return the first function in the module with the
   /// specified name, of arbitrary type.  This method returns null if a function
   /// with the specified name is not found.
-  Function *getNamedFunction(const std::string &Name) const;
+  Function *getNamedFunction(const std::string &Name) const {
+    return getFunction(Name);
+  }
 
 /// @}
 /// @name Global Variable Accessors 
@@ -200,13 +200,15 @@
   /// the top-level PointerType, which represents the address of the global.
   /// If AllowInternal is set to true, this function will return types that
   /// have InternalLinkage. By default, these types are not returned.
-  GlobalVariable *getGlobalVariable(const std::string &Name, const Type *Ty,
-                                    bool AllowInternal = false);
+  GlobalVariable *getGlobalVariable(const std::string &Name, 
+                                    bool AllowInternal = false) const;
 
   /// getNamedGlobal - Return the first global variable in the module with the
   /// specified name, of arbitrary type.  This method returns null if a global
   /// with the specified name is not found.
-  GlobalVariable *getNamedGlobal(const std::string &Name) const;
+  GlobalVariable *getNamedGlobal(const std::string &Name) const {
+    return getGlobalVariable(Name, true);
+  }
   
 /// @}
 /// @name Type Accessors
@@ -238,9 +240,9 @@
   /// Get the Module's list of functions.
   FunctionListType       &getFunctionList()           { return FunctionList; }
   /// Get the symbol table of global variable and function identifiers
-  const SymbolTable      &getValueSymbolTable() const { return *ValSymTab; }
+  const ValueSymbolTable &getValueSymbolTable() const { return *ValSymTab; }
   /// Get the Module's symbol table of global variable and function identifiers.
-  SymbolTable            &getValueSymbolTable()       { return *ValSymTab; }
+  ValueSymbolTable       &getValueSymbolTable()       { return *ValSymTab; }
   /// Get the symbol table of types
   const TypeSymbolTable   &getTypeSymbolTable() const { return *TypeSymTab; }
   /// Get the Module's symbol table of types


Index: llvm/include/llvm/Value.h
diff -u llvm/include/llvm/Value.h:1.90 llvm/include/llvm/Value.h:1.91
--- llvm/include/llvm/Value.h:1.90	Thu Jan 11 06:24:13 2007
+++ llvm/include/llvm/Value.h	Mon Feb  5 14:47:19 2007
@@ -31,7 +31,8 @@
 class Function;
 class GlobalVariable;
 class InlineAsm;
-class SymbolTable;
+class ValueSymbolTable;
+class TypeSymbolTable;
 
 //===----------------------------------------------------------------------===//
 //                                 Value Class


Index: llvm/include/llvm/ValueSymbolTable.h
diff -u llvm/include/llvm/ValueSymbolTable.h:1.3 llvm/include/llvm/ValueSymbolTable.h:1.4
--- llvm/include/llvm/ValueSymbolTable.h:1.3	Wed May 31 15:40:31 2006
+++ llvm/include/llvm/ValueSymbolTable.h	Mon Feb  5 14:47:19 2007
@@ -72,6 +72,12 @@
   /// @brief Get a name unique to this symbol table
   std::string getUniqueName(const std::string &BaseName) const;
 
+  /// @return 1 if the name is in the symbol table, 0 otherwise
+  /// @brief Determine if a name is in the symbol table
+  ValueMap::size_type count(const std::string &name) const { 
+    return vmap.count(name);
+  }
+
   /// This function can be used from the debugger to display the
   /// content of the symbol table while debugging.
   /// @brief Print out symbol table on stderr
@@ -111,10 +117,10 @@
   /// This method removes a value from the symbol table. The name of the
   /// Value is extracted from \p Val and used to lookup the Value in the
   /// symbol table. If the Value is not in the symbol table, this method
-  /// returns false.
-  /// @returns true if \p Val was successfully erased, false otherwise
+  /// returns false. \p Val is not deleted, just removed from the symbol table.
+  /// @returns true if \p Val was successfully removed, false otherwise
   /// @brief Remove a value from the symbol table.
-  bool erase(Value* Val);
+  bool remove(Value* Val);
 
   /// Given a value with a non-empty name, remove its existing
   /// entry from the symbol table and insert a new one for Name.  This is






More information about the llvm-commits mailing list