[llvm-commits] [123990] Removed redundant EmittedGlobalVars and EmittedFunctions maps.

bwendlin at apple.com bwendlin at apple.com
Fri Feb 16 17:18:21 PST 2007


Revision: 123990
Author:   bwendlin
Date:     2007-02-16 17:18:16 -0800 (Fri, 16 Feb 2007)

Log Message:
-----------
Removed redundant EmittedGlobalVars and EmittedFunctions maps. Switched to using
the "get*" methods in Module instead.

Modified Paths:
--------------
    apple-local/branches/llvm/gcc/llvm-backend.cpp
    apple-local/branches/llvm/gcc/llvm-convert.cpp
    apple-local/branches/llvm/gcc/llvm-internal.h

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-backend.cpp	2007-02-17 00:10:49 UTC (rev 123989)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp	2007-02-17 01:18:16 UTC (rev 123990)
@@ -76,8 +76,6 @@
 
 std::vector<std::pair<Function*, int> > StaticCtors, StaticDtors;
 std::vector<GlobalValue*> AttributeUsedGlobals;
-std::map<std::string, GlobalVariable*> EmittedGlobalVars;
-std::map<std::string, Function*> EmittedFunctions;
 
 /// PerFunctionPasses - This is the list of cleanup passes run per-function
 /// as each is compiled.  In cases where we are not doing IPO, it includes the 
@@ -588,7 +586,6 @@
     GV->replaceAllUsesWith(ConstantExpr::getBitCast(NGV, GV->getType()));
     delete GV;
     SET_DECL_LLVM(decl, NGV);
-    EmittedGlobalVars[NGV->getName()] = NGV;
     GV = NGV;
   }
  
@@ -759,7 +756,7 @@
     assert(Name[0] && "Function with empty name!");
     // If this function has already been created, reuse the decl.  This happens
     // when we have something like __builtin_memset and memset in the same file.
-    Function *&FnEntry = EmittedFunctions[Name];
+    Function *FnEntry = TheModule->getFunction(Name);
     if (FnEntry == 0) {
       unsigned CC;
       const FunctionType *Ty = 
@@ -810,11 +807,11 @@
     } else {
       // If the global has a name, prevent multiple vars with the same name from
       // being created.
-      GlobalVariable *&GVE = EmittedGlobalVars[Name];
+      GlobalVariable *GVE = TheModule->getGlobalVariable(Name);
     
       if (GVE == 0) {
-        GVE = GV = new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage,0,
-                                      Name, TheModule);
+        GV = new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage,0,
+                                Name, TheModule);
 
         // Check for external weak linkage
         if (DECL_EXTERNAL(decl) && DECL_WEAK(decl))

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-convert.cpp	2007-02-17 00:10:49 UTC (rev 123989)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp	2007-02-17 01:18:16 UTC (rev 123990)
@@ -431,7 +431,7 @@
     else if (DECL_VISIBILITY(FnDecl) == VISIBILITY_DEFAULT)
       Fn->setVisibility(Function::DefaultVisibility);
   } else {
-    Function *&FnEntry = EmittedFunctions[Name];
+    Function *FnEntry = TheModule->getFunction(Name);
     if (FnEntry) {
       assert(FnEntry->getName() == Name && "Same entry, different name?");
       assert(FnEntry->isDeclaration() &&
@@ -455,7 +455,6 @@
       FnEntry->eraseFromParent();
     }
     SET_DECL_LLVM(FnDecl, Fn);
-    FnEntry = Fn;
   }
 
   // The function should not already have a body.

Modified: apple-local/branches/llvm/gcc/llvm-internal.h
===================================================================
--- apple-local/branches/llvm/gcc/llvm-internal.h	2007-02-17 00:10:49 UTC (rev 123989)
+++ apple-local/branches/llvm/gcc/llvm-internal.h	2007-02-17 01:18:16 UTC (rev 123990)
@@ -86,14 +86,6 @@
 /// AttributeUsedGlobals - The list of globals that are marked attribute(used).
 extern std::vector<GlobalValue*> AttributeUsedGlobals;
 
-/// EmittedGlobalVars/EmittedFunctions - Keep track of the global variables and
-/// functions we have already emitted.  GCC periodically likes to create
-/// multiple VAR_DECL nodes with the same name and expects them to be linked
-/// together (particularly the objc front-end) and does the same for functions
-/// e.g. builtin_memset vs memset).  Emulate this functionality.
-extern std::map<std::string, GlobalVariable*> EmittedGlobalVars;
-extern std::map<std::string, Function*> EmittedFunctions;
-
 extern void readLLVMTypesStringTable();
 extern void writeLLVMTypesStringTable();
 extern void readLLVMValuesStringTable();





More information about the llvm-commits mailing list