Fixed the order of static destructors

This commit is contained in:
Alexey Prokhin
2010-12-30 14:04:24 +03:00
parent 6c2ccaf945
commit 8d7ff66019
3 changed files with 13 additions and 12 deletions

View File

@@ -511,7 +511,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
// shared static dtor
else if (fdecl->isSharedStaticDtorDeclaration()) {
if (mustDefineSymbol(fdecl)) {
gIR->sharedDtors.push_back(fdecl);
gIR->sharedDtors.push_front(fdecl);
}
} else
#endif
@@ -524,7 +524,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
// static dtor
else if (fdecl->isStaticDtorDeclaration()) {
if (mustDefineSymbol(fdecl)) {
gIR->dtors.push_back(fdecl);
gIR->dtors.insert(gIR->dtors.begin(), fdecl);
}
}

View File

@@ -160,14 +160,14 @@ struct IRState
llvm::DIFactory difactory;
// static ctors/dtors/unittests
typedef std::vector<FuncDeclaration*> FuncDeclVector;
FuncDeclVector ctors;
FuncDeclVector dtors;
typedef std::list<FuncDeclaration*> FuncDeclList;
FuncDeclList ctors;
FuncDeclList dtors;
#if DMDV2
FuncDeclVector sharedCtors;
FuncDeclVector sharedDtors;
FuncDeclList sharedCtors;
FuncDeclList sharedDtors;
#endif
FuncDeclVector unitTests;
FuncDeclList unitTests;
// all template instances that had members emitted
// currently only filled for singleobj

View File

@@ -387,14 +387,14 @@ void assemble(const llvm::sys::Path& asmpath, const llvm::sys::Path& objpath)
/* ================================================================== */
static llvm::Function* build_module_function(const std::string &name, const std::vector<FuncDeclaration*> &funcs)
static llvm::Function* build_module_function(const std::string &name, const std::list<FuncDeclaration*> &funcs)
{
if (funcs.empty())
return NULL;
size_t n = funcs.size();
if (n == 1)
return funcs[0]->ir.irFunc->func;
return funcs.front()->ir.irFunc->func;
std::vector<const LLType*> argsTy;
const llvm::FunctionType* fnTy = llvm::FunctionType::get(LLType::getVoidTy(gIR->context()),argsTy,false);
@@ -411,8 +411,9 @@ static llvm::Function* build_module_function(const std::string &name, const std:
DtoDwarfSubProgramInternal(name.c_str(), name.c_str());
#endif
for (size_t i=0; i<n; i++) {
llvm::Function* f = funcs[i]->ir.irFunc->func;
typedef std::list<FuncDeclaration*>::const_iterator Iterator;
for (Iterator itr = funcs.begin(), end = funcs.end(); itr != end; ++itr) {
llvm::Function* f = (*itr)->ir.irFunc->func;
llvm::CallInst* call = builder.CreateCall(f,"");
call->setCallingConv(DtoCallingConv(0, LINKd));
}