mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 08:01:11 +03:00
Remove redundant FuncDeclaration::nestedVars.
The change not only makes the code cleaner but also fixes compilation of multiple files at once. Previously, fd->nestedVars may have been filled twice if fd was a template function instantiated in two modules simultaneously.
This commit is contained in:
parent
5a181d9312
commit
5a10a23cef
2 changed files with 9 additions and 22 deletions
|
@ -930,11 +930,6 @@ public:
|
|||
/// Codegen traversal
|
||||
void codegen(IRState* ir);
|
||||
|
||||
// vars declared in this function that nested funcs reference
|
||||
// is this is not empty, nestedFrameRef is set and these VarDecls
|
||||
// probably have nestedref set too, see VarDeclaration::checkNestedReference
|
||||
std::set<VarDeclaration*> nestedVars;
|
||||
|
||||
std::string intrinsicName;
|
||||
uint32_t priority;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "gen/llvmhelpers.h"
|
||||
#include "gen/logger.h"
|
||||
#include "gen/tollvm.h"
|
||||
#include "gen/utils.h"
|
||||
#include "llvm/Analysis/ValueTracking.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
namespace cl = llvm::cl;
|
||||
|
@ -285,17 +286,8 @@ static void DtoCreateNestedContextType(FuncDeclaration* fd) {
|
|||
return;
|
||||
fd->ir.irFunc->nestedContextCreated = true;
|
||||
|
||||
// fill nestedVars
|
||||
assert(fd->nestedVars.empty() && "nestedVars should only be filled here");
|
||||
size_t nnest = fd->closureVars.dim;
|
||||
for (size_t i = 0; i < nnest; ++i)
|
||||
{
|
||||
VarDeclaration* vd = static_cast<VarDeclaration*>(fd->closureVars.data[i]);
|
||||
fd->nestedVars.insert(vd);
|
||||
}
|
||||
|
||||
// construct nested variables array
|
||||
if (!fd->nestedVars.empty())
|
||||
if (fd->closureVars.dim != 0)
|
||||
{
|
||||
Logger::println("has nested frame");
|
||||
// start with adding all enclosing parent frames until a static parent is reached
|
||||
|
@ -345,9 +337,9 @@ static void DtoCreateNestedContextType(FuncDeclaration* fd) {
|
|||
|
||||
// Add the direct nested variables of this function, and update their indices to match.
|
||||
// TODO: optimize ordering for minimal space usage?
|
||||
for (std::set<VarDeclaration*>::iterator i=fd->nestedVars.begin(); i!=fd->nestedVars.end(); ++i)
|
||||
{
|
||||
VarDeclaration* vd = *i;
|
||||
VarDeclarationIter closureVarsIter(fd->closureVars);
|
||||
for (; closureVarsIter.more(); closureVarsIter.next()) {
|
||||
VarDeclaration* vd = *closureVarsIter;
|
||||
if (!vd->ir.irLocal)
|
||||
vd->ir.irLocal = new IrLocal(vd);
|
||||
|
||||
|
@ -404,7 +396,7 @@ void DtoCreateNestedContext(FuncDeclaration* fd) {
|
|||
DtoCreateNestedContextType(fd);
|
||||
|
||||
// construct nested variables array
|
||||
if (!fd->nestedVars.empty())
|
||||
if (fd->closureVars.dim != 0)
|
||||
{
|
||||
IrFunction* irfunction = fd->ir.irFunc;
|
||||
unsigned depth = irfunction->depth;
|
||||
|
@ -451,9 +443,9 @@ void DtoCreateNestedContext(FuncDeclaration* fd) {
|
|||
irfunction->nestedVar = frame;
|
||||
|
||||
// go through all nested vars and assign addresses where possible.
|
||||
for (std::set<VarDeclaration*>::iterator i=fd->nestedVars.begin(); i!=fd->nestedVars.end(); ++i)
|
||||
{
|
||||
VarDeclaration* vd = *i;
|
||||
VarDeclarationIter closureVarsIter(fd->closureVars);
|
||||
for (; closureVarsIter.more(); closureVarsIter.next()) {
|
||||
VarDeclaration* vd = *closureVarsIter;
|
||||
|
||||
LLValue* gep = DtoGEPi(frame, 0, vd->ir.irLocal->nestedIndex, vd->toChars());
|
||||
if (vd->isParameter()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue