aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.h
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2010-03-21 10:50:08 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2010-03-21 10:50:08 +0000
commitc0c7bca4e5b8d12699dc93a0da49e9e4bb79671b (patch)
tree508d4388db78f87d35bf26a0400b4b03bc4c1f13 /lib/CodeGen/CodeGenModule.h
parent4a37f65f1c1373c9956d118a012943de2f61edb0 (diff)
downloadsrc-c0c7bca4e5b8d12699dc93a0da49e9e4bb79671b.tar.gz
src-c0c7bca4e5b8d12699dc93a0da49e9e4bb79671b.zip
Update clang to r99115.
Notes
Notes: svn path=/vendor/clang/dist/; revision=205408
Diffstat (limited to 'lib/CodeGen/CodeGenModule.h')
-rw-r--r--lib/CodeGen/CodeGenModule.h72
1 files changed, 30 insertions, 42 deletions
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h
index 9077adedd0b9..febb8560367b 100644
--- a/lib/CodeGen/CodeGenModule.h
+++ b/lib/CodeGen/CodeGenModule.h
@@ -73,7 +73,7 @@ namespace CodeGen {
class CodeGenFunction;
class CGDebugInfo;
class CGObjCRuntime;
-
+ class MangleBuffer;
/// CodeGenModule - This class organizes the cross-function state that is used
/// while generating LLVM code.
@@ -103,38 +103,16 @@ class CodeGenModule : public BlockModule {
llvm::Function *MemMoveFn;
llvm::Function *MemSetFn;
- /// GlobalDeclMap - Mapping of decl names (represented as unique
- /// character pointers from either the identifier table or the set
- /// of mangled names) to global variables we have already
- /// emitted. Note that the entries in this map are the 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 mangled name, not the global name
- /// (which may change with attributes such as asm-labels). The key
- /// to this map should be generated using getMangledName().
- ///
- /// Note that this map always lines up exactly with the contents of the LLVM
- /// IR symbol table, but this is quicker to query since it is doing uniqued
- /// pointer lookups instead of full string lookups.
- llvm::DenseMap<const char*, llvm::GlobalValue*> GlobalDeclMap;
-
// WeakRefReferences - A set of references that have only been seen via
// a weakref so far. This is used to remove the weak of the reference if we ever
// see a direct reference or a definition.
llvm::SmallPtrSet<llvm::GlobalValue*, 10> WeakRefReferences;
- /// \brief Contains the strings used for mangled names.
- ///
- /// FIXME: Eventually, this should map from the semantic/canonical
- /// declaration for each global entity to its mangled name (if it
- /// has one).
- llvm::StringSet<> MangledNames;
-
/// DeferredDecls - This contains all the decls which have definitions but
/// which are deferred for emission and therefore should only be output if
/// they are actually used. If a decl is in this, then it is known to have
- /// not been referenced yet. The key to this map is a uniqued mangled name.
- llvm::DenseMap<const char*, GlobalDecl> DeferredDecls;
+ /// not been referenced yet.
+ llvm::StringMap<GlobalDecl> DeferredDecls;
/// DeferredDeclsToEmit - This is a list of deferred decls which we have seen
/// that *are* actually referenced. These get code generated when the module
@@ -160,10 +138,14 @@ class CodeGenModule : public BlockModule {
llvm::StringMap<llvm::Constant*> CFConstantStringMap;
llvm::StringMap<llvm::Constant*> ConstantStringMap;
- /// CXXGlobalInits - Variables with global initializers that need to run
+ /// CXXGlobalInits - Global variables with initializers that need to run
/// before main.
std::vector<llvm::Constant*> CXXGlobalInits;
+ /// CXXGlobalDtors - Global destructor functions and arguments that need to
+ /// run on termination.
+ std::vector<std::pair<llvm::Constant*,llvm::Constant*> > CXXGlobalDtors;
+
/// CFConstantStringClassRef - Cached reference to the class for constant
/// strings. This value has type int * but is actually an Obj-C class pointer.
llvm::Constant *CFConstantStringClassRef;
@@ -343,14 +325,18 @@ public:
void AddAnnotation(llvm::Constant *C) { Annotations.push_back(C); }
+ /// AddCXXDtorEntry - Add a destructor and object to add to the C++ global
+ /// destructor function.
+ void AddCXXDtorEntry(llvm::Constant *DtorFn, llvm::Constant *Object);
+
/// CreateRuntimeFunction - Create a new runtime function with the specified
/// type and name.
llvm::Constant *CreateRuntimeFunction(const llvm::FunctionType *Ty,
- const char *Name);
+ llvm::StringRef Name);
/// CreateRuntimeVariable - Create a new runtime global variable with the
/// specified type and name.
llvm::Constant *CreateRuntimeVariable(const llvm::Type *Ty,
- const char *Name);
+ llvm::StringRef Name);
void UpdateCompletedType(const TagDecl *TD) {
// Make sure that this type is translated.
@@ -422,13 +408,14 @@ public:
AttributeListType &PAL,
unsigned &CallingConv);
- const char *getMangledName(const GlobalDecl &D);
-
- const char *getMangledName(const NamedDecl *ND);
- const char *getMangledCXXCtorName(const CXXConstructorDecl *D,
- CXXCtorType Type);
- const char *getMangledCXXDtorName(const CXXDestructorDecl *D,
- CXXDtorType Type);
+ void getMangledName(MangleBuffer &Buffer, GlobalDecl D);
+ void getMangledName(MangleBuffer &Buffer, const NamedDecl *ND);
+ void getMangledCXXCtorName(MangleBuffer &Buffer,
+ const CXXConstructorDecl *D,
+ CXXCtorType Type);
+ void getMangledCXXDtorName(MangleBuffer &Buffer,
+ const CXXDestructorDecl *D,
+ CXXDtorType Type);
void EmitTentativeDefinition(const VarDecl *D);
@@ -456,14 +443,12 @@ public:
std::vector<const CXXRecordDecl*> DeferredVtables;
private:
- /// UniqueMangledName - Unique a name by (if necessary) inserting it into the
- /// MangledNames string map.
- const char *UniqueMangledName(const char *NameStart, const char *NameEnd);
+ llvm::GlobalValue *GetGlobalValue(llvm::StringRef Ref);
- llvm::Constant *GetOrCreateLLVMFunction(const char *MangledName,
+ llvm::Constant *GetOrCreateLLVMFunction(llvm::StringRef MangledName,
const llvm::Type *Ty,
GlobalDecl D);
- llvm::Constant *GetOrCreateLLVMGlobal(const char *MangledName,
+ llvm::Constant *GetOrCreateLLVMGlobal(llvm::StringRef MangledName,
const llvm::PointerType *PTy,
const VarDecl *D);
@@ -492,7 +477,7 @@ private:
void EmitGlobalFunctionDefinition(GlobalDecl GD);
void EmitGlobalVarDefinition(const VarDecl *D);
- void EmitAliasDefinition(const ValueDecl *D);
+ void EmitAliasDefinition(GlobalDecl GD);
void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
// C++ related functions.
@@ -519,9 +504,12 @@ private:
/// a C++ destructor Decl.
void EmitCXXDestructor(const CXXDestructorDecl *D, CXXDtorType Type);
- /// EmitCXXGlobalInitFunc - Emit a function that initializes C++ globals.
+ /// EmitCXXGlobalInitFunc - Emit the function that initializes C++ globals.
void EmitCXXGlobalInitFunc();
+ /// EmitCXXGlobalDtorFunc - Emit the function that destroys C++ globals.
+ void EmitCXXGlobalDtorFunc();
+
void EmitCXXGlobalVarDeclInitFunc(const VarDecl *D);
// FIXME: Hardcoding priority here is gross.