mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-12 02:43:14 +01:00
Move function codegen data from IrFunction to new FuncGen.
This change reduces memory consumption significantly by releasing the memory held by the STL containers that are now inside FuncGen.
This commit is contained in:
@@ -93,6 +93,37 @@ void IrFuncTy::getParam(Type* dty, int idx, DValue* val, llvm::Value* lval)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FuncGen::FuncGen()
|
||||
{
|
||||
landingPad = NULL;
|
||||
nextUnique.push(0);
|
||||
}
|
||||
|
||||
std::string FuncGen::getScopedLabelName(const char* ident)
|
||||
{
|
||||
if(labelScopes.empty())
|
||||
return std::string(ident);
|
||||
|
||||
std::string result = "__";
|
||||
for(unsigned int i = 0; i < labelScopes.size(); ++i)
|
||||
result += labelScopes[i] + "_";
|
||||
return result + ident;
|
||||
}
|
||||
|
||||
void FuncGen::pushUniqueLabelScope(const char* name)
|
||||
{
|
||||
std::ostringstream uniquename;
|
||||
uniquename << name << nextUnique.top()++;
|
||||
nextUnique.push(0);
|
||||
labelScopes.push_back(uniquename.str());
|
||||
}
|
||||
|
||||
void FuncGen::popLabelScope()
|
||||
{
|
||||
labelScopes.pop_back();
|
||||
nextUnique.pop();
|
||||
}
|
||||
|
||||
IrFunction::IrFunction(FuncDeclaration* fd)
|
||||
{
|
||||
decl = fd;
|
||||
@@ -116,35 +147,6 @@ IrFunction::IrFunction(FuncDeclaration* fd)
|
||||
|
||||
_arguments = NULL;
|
||||
_argptr = NULL;
|
||||
|
||||
landingPad = NULL;
|
||||
|
||||
nextUnique.push(0);
|
||||
}
|
||||
|
||||
std::string IrFunction::getScopedLabelName(const char* ident)
|
||||
{
|
||||
if(labelScopes.empty())
|
||||
return std::string(ident);
|
||||
|
||||
std::string result = "__";
|
||||
for(unsigned int i = 0; i < labelScopes.size(); ++i)
|
||||
result += labelScopes[i] + "_";
|
||||
return result + ident;
|
||||
}
|
||||
|
||||
void IrFunction::pushUniqueLabelScope(const char* name)
|
||||
{
|
||||
std::ostringstream uniquename;
|
||||
uniquename << name << nextUnique.top()++;
|
||||
nextUnique.push(0);
|
||||
labelScopes.push_back(uniquename.str());
|
||||
}
|
||||
|
||||
void IrFunction::popLabelScope()
|
||||
{
|
||||
labelScopes.pop_back();
|
||||
nextUnique.pop();
|
||||
}
|
||||
|
||||
void IrFunction::setNeverInline()
|
||||
|
||||
Reference in New Issue
Block a user