Change CodeGen of global decls to key off of the name (instead of
having multiple bindings from all the possible decls which
conceptually map to the same global).
- This eliminates CodeGen depending on the LLVM module for name
lookup.
- This also eliminates the need for ReplaceMapValuesWith (hurrah).
- This handles lookups for FunctionDecls correctly in the presence of
aliases, this was previously broken.
- WIP: Can still clean up & unify variable and function emission.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54382 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h
index c243590..d90ebb4 100644
--- a/lib/CodeGen/CodeGenModule.h
+++ b/lib/CodeGen/CodeGenModule.h
@@ -69,11 +69,13 @@
llvm::Function *MemMoveFn;
llvm::Function *MemSetFn;
- /// GlobalDeclMap - Mapping of decls to global variables we have
+ /// GlobalDeclMap - Mapping of decl names global variables we have
/// already emitted. Note that the entries in this map are the
- /// actual global and therefore may not be of the same type as the
- /// decl, they should be bitcasted on retrieval.
- llvm::DenseMap<const Decl*, llvm::GlobalValue*> GlobalDeclMap;
+ /// actual globals and therefore may not be of the same type as the
+ /// decl, they should be bitcasted on retrieval. Also note that the
+ /// globals are keyed on their source name, not the global name
+ /// (which may change with attributes such as asm-labels).
+ llvm::StringMap<llvm::GlobalValue*> GlobalDeclMap;
/// List of static global for which code generation is delayed. When
/// the translation unit has been fully processed we will lazily
@@ -172,11 +174,6 @@
VisibilityAttr::VisibilityTypes);
private:
- /// ReplaceMapValuesWith - This is a really slow and bad function that
- /// searches for any entries in GlobalDeclMap that point to OldVal, changing
- /// them to point to NewVal. This is badbadbad, FIXME!
- void ReplaceMapValuesWith(llvm::GlobalValue *OldVal, llvm::GlobalValue *NewVal);
-
void SetFunctionAttributes(const FunctionDecl *FD,
llvm::Function *F,
const llvm::FunctionType *FTy);