mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 08:30:47 +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
|
/// Codegen traversal
|
||||||
void codegen(IRState* ir);
|
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;
|
std::string intrinsicName;
|
||||||
uint32_t priority;
|
uint32_t priority;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "gen/llvmhelpers.h"
|
#include "gen/llvmhelpers.h"
|
||||||
#include "gen/logger.h"
|
#include "gen/logger.h"
|
||||||
#include "gen/tollvm.h"
|
#include "gen/tollvm.h"
|
||||||
|
#include "gen/utils.h"
|
||||||
#include "llvm/Analysis/ValueTracking.h"
|
#include "llvm/Analysis/ValueTracking.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
namespace cl = llvm::cl;
|
namespace cl = llvm::cl;
|
||||||
|
@ -285,17 +286,8 @@ static void DtoCreateNestedContextType(FuncDeclaration* fd) {
|
||||||
return;
|
return;
|
||||||
fd->ir.irFunc->nestedContextCreated = true;
|
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
|
// construct nested variables array
|
||||||
if (!fd->nestedVars.empty())
|
if (fd->closureVars.dim != 0)
|
||||||
{
|
{
|
||||||
Logger::println("has nested frame");
|
Logger::println("has nested frame");
|
||||||
// start with adding all enclosing parent frames until a static parent is reached
|
// 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.
|
// Add the direct nested variables of this function, and update their indices to match.
|
||||||
// TODO: optimize ordering for minimal space usage?
|
// TODO: optimize ordering for minimal space usage?
|
||||||
for (std::set<VarDeclaration*>::iterator i=fd->nestedVars.begin(); i!=fd->nestedVars.end(); ++i)
|
VarDeclarationIter closureVarsIter(fd->closureVars);
|
||||||
{
|
for (; closureVarsIter.more(); closureVarsIter.next()) {
|
||||||
VarDeclaration* vd = *i;
|
VarDeclaration* vd = *closureVarsIter;
|
||||||
if (!vd->ir.irLocal)
|
if (!vd->ir.irLocal)
|
||||||
vd->ir.irLocal = new IrLocal(vd);
|
vd->ir.irLocal = new IrLocal(vd);
|
||||||
|
|
||||||
|
@ -404,7 +396,7 @@ void DtoCreateNestedContext(FuncDeclaration* fd) {
|
||||||
DtoCreateNestedContextType(fd);
|
DtoCreateNestedContextType(fd);
|
||||||
|
|
||||||
// construct nested variables array
|
// construct nested variables array
|
||||||
if (!fd->nestedVars.empty())
|
if (fd->closureVars.dim != 0)
|
||||||
{
|
{
|
||||||
IrFunction* irfunction = fd->ir.irFunc;
|
IrFunction* irfunction = fd->ir.irFunc;
|
||||||
unsigned depth = irfunction->depth;
|
unsigned depth = irfunction->depth;
|
||||||
|
@ -451,9 +443,9 @@ void DtoCreateNestedContext(FuncDeclaration* fd) {
|
||||||
irfunction->nestedVar = frame;
|
irfunction->nestedVar = frame;
|
||||||
|
|
||||||
// go through all nested vars and assign addresses where possible.
|
// go through all nested vars and assign addresses where possible.
|
||||||
for (std::set<VarDeclaration*>::iterator i=fd->nestedVars.begin(); i!=fd->nestedVars.end(); ++i)
|
VarDeclarationIter closureVarsIter(fd->closureVars);
|
||||||
{
|
for (; closureVarsIter.more(); closureVarsIter.next()) {
|
||||||
VarDeclaration* vd = *i;
|
VarDeclaration* vd = *closureVarsIter;
|
||||||
|
|
||||||
LLValue* gep = DtoGEPi(frame, 0, vd->ir.irLocal->nestedIndex, vd->toChars());
|
LLValue* gep = DtoGEPi(frame, 0, vd->ir.irLocal->nestedIndex, vd->toChars());
|
||||||
if (vd->isParameter()) {
|
if (vd->isParameter()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue