aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.h
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-08-01 00:01:51 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-08-01 00:01:51 +0000
commit6bfed7e411adc46eaf616371f85f68305c6e6257 (patch)
tree276afccc553fe87d22f0651853325919898753f4 /lib/CodeGen/CodeGenModule.h
parent3068ae0feb5d477477f45045f7ec9d0414fe57f3 (diff)
Support constructor and destructor attributes in CodeGen
- There is an miscompilation issue remaining due to a poor interaction between the delayed emission of static functions and the emission of constructors, but that already existed prior to this change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54258 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.h')
-rw-r--r--lib/CodeGen/CodeGenModule.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h
index 3a39eb3f79..1fb2cf7ae0 100644
--- a/lib/CodeGen/CodeGenModule.h
+++ b/lib/CodeGen/CodeGenModule.h
@@ -54,6 +54,8 @@ namespace CodeGen {
/// CodeGenModule - This class organizes the cross-module state that is used
/// while generating LLVM code.
class CodeGenModule {
+ typedef std::vector< std::pair<llvm::Constant*, int> > CtorList;
+
ASTContext &Context;
const LangOptions &Features;
llvm::Module &TheModule;
@@ -80,7 +82,16 @@ class CodeGenModule {
/// which actually define something.
std::vector<const ValueDecl*> StaticDecls;
- std::vector<llvm::Constant*> GlobalCtors;
+ /// GlobalCtors - Store the list of global constructors and their
+ /// respective priorities to be emitted when the translation unit is
+ /// complete.
+ CtorList GlobalCtors;
+
+ /// GlobalDtors - Store the list of global destructors and their
+ /// respective priorities to be emitted when the translation unit is
+ /// complete.
+ CtorList GlobalDtors;
+
std::vector<llvm::Constant*> Annotations;
llvm::StringMap<llvm::Constant*> CFConstantStringMap;
@@ -173,9 +184,17 @@ private:
llvm::GlobalValue *EmitForwardFunctionDefinition(const FunctionDecl *D);
void EmitGlobalFunctionDefinition(const FunctionDecl *D);
void EmitGlobalVarDefinition(const VarDecl *D);
+
+ // FIXME: Hardcoding priority here is gross.
+ void AddGlobalCtor(llvm::Function * Ctor, int Priority=65535);
+ void AddGlobalDtor(llvm::Function * Dtor, int Priority=65535);
+
+ /// EmitCtorList - Generates a global array of functions and
+ /// priorities using the given list and name. This array will have
+ /// appending linkage and is suitable for use as a LLVM constructor
+ /// or destructor array.
+ void EmitCtorList(const CtorList &Fns, const char *GlobalName);
- void AddGlobalCtor(llvm::Function * Ctor);
- void EmitGlobalCtors(void);
void EmitAnnotations(void);
void EmitStatics(void);