diff --git a/gen/functions.cpp b/gen/functions.cpp index e431169e..c68a8cc2 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -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); } } diff --git a/gen/irstate.h b/gen/irstate.h index 2b2d91b9..66c5819f 100644 --- a/gen/irstate.h +++ b/gen/irstate.h @@ -160,14 +160,14 @@ struct IRState llvm::DIFactory difactory; // static ctors/dtors/unittests - typedef std::vector FuncDeclVector; - FuncDeclVector ctors; - FuncDeclVector dtors; + typedef std::list 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 diff --git a/gen/toobj.cpp b/gen/toobj.cpp index b82845a6..80971bba 100644 --- a/gen/toobj.cpp +++ b/gen/toobj.cpp @@ -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 &funcs) +static llvm::Function* build_module_function(const std::string &name, const std::list &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 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; iir.irFunc->func; + typedef std::list::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)); }