mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-09 20:37:25 +03:00
Frontend: Get rid of unused backend-reserved Symbol
Somewhat reducing memory requirements by stripping the unused fields too.
This commit is contained in:
parent
34e3230ef2
commit
48e8c2ecee
16 changed files with 77 additions and 58 deletions
|
@ -829,9 +829,12 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version (IN_LLVM) {} else
|
||||||
|
{
|
||||||
// Back end
|
// Back end
|
||||||
Symbol* stag; // tag symbol for debug data
|
Symbol* stag; // tag symbol for debug data
|
||||||
Symbol* sinit;
|
Symbol* sinit;
|
||||||
|
}
|
||||||
|
|
||||||
override final inout(AggregateDeclaration) isAggregateDeclaration() inout
|
override final inout(AggregateDeclaration) isAggregateDeclaration() inout
|
||||||
{
|
{
|
||||||
|
|
|
@ -138,9 +138,11 @@ public:
|
||||||
// 'this' type
|
// 'this' type
|
||||||
Type *handleType() { return type; }
|
Type *handleType() { return type; }
|
||||||
|
|
||||||
|
#if !IN_LLVM
|
||||||
// Back end
|
// Back end
|
||||||
Symbol *stag; // tag symbol for debug data
|
Symbol *stag; // tag symbol for debug data
|
||||||
Symbol *sinit;
|
Symbol *sinit;
|
||||||
|
#endif
|
||||||
|
|
||||||
AggregateDeclaration *isAggregateDeclaration() { return this; }
|
AggregateDeclaration *isAggregateDeclaration() { return this; }
|
||||||
void accept(Visitor *v) { v->visit(this); }
|
void accept(Visitor *v) { v->visit(this); }
|
||||||
|
@ -279,7 +281,9 @@ public:
|
||||||
Abstract isabstract; // 0: fwdref, 1: is abstract class, 2: not abstract
|
Abstract isabstract; // 0: fwdref, 1: is abstract class, 2: not abstract
|
||||||
Baseok baseok; // set the progress of base classes resolving
|
Baseok baseok; // set the progress of base classes resolving
|
||||||
ObjcClassDeclaration objc; // Data for a class declaration that is needed for the Objective-C integration
|
ObjcClassDeclaration objc; // Data for a class declaration that is needed for the Objective-C integration
|
||||||
|
#if !IN_LLVM
|
||||||
Symbol *cpp_type_info_ptr_sym; // cached instance of class Id.cpp_type_info_ptr
|
Symbol *cpp_type_info_ptr_sym; // cached instance of class Id.cpp_type_info_ptr
|
||||||
|
#endif
|
||||||
|
|
||||||
static ClassDeclaration *create(Loc loc, Identifier *id, BaseClasses *baseclasses, Dsymbols *members, bool inObject);
|
static ClassDeclaration *create(Loc loc, Identifier *id, BaseClasses *baseclasses, Dsymbols *members, bool inObject);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||||
|
|
|
@ -223,7 +223,10 @@ extern (C++) class ClassDeclaration : AggregateDeclaration
|
||||||
*/
|
*/
|
||||||
ObjcClassDeclaration objc;
|
ObjcClassDeclaration objc;
|
||||||
|
|
||||||
|
version (IN_LLVM) {} else
|
||||||
|
{
|
||||||
Symbol* cpp_type_info_ptr_sym; // cached instance of class Id.cpp_type_info_ptr
|
Symbol* cpp_type_info_ptr_sym; // cached instance of class Id.cpp_type_info_ptr
|
||||||
|
}
|
||||||
|
|
||||||
final extern (D) this(const ref Loc loc, Identifier id, BaseClasses* baseclasses, Dsymbols* members, bool inObject)
|
final extern (D) this(const ref Loc loc, Identifier id, BaseClasses* baseclasses, Dsymbols* members, bool inObject)
|
||||||
{
|
{
|
||||||
|
|
|
@ -543,7 +543,9 @@ public:
|
||||||
// Support for NRVO (named return value optimization)
|
// Support for NRVO (named return value optimization)
|
||||||
bool nrvo_can; // true means we can do it
|
bool nrvo_can; // true means we can do it
|
||||||
VarDeclaration *nrvo_var; // variable to replace with shidden
|
VarDeclaration *nrvo_var; // variable to replace with shidden
|
||||||
|
#if !IN_LLVM
|
||||||
Symbol *shidden; // hidden pointer passed to function
|
Symbol *shidden; // hidden pointer passed to function
|
||||||
|
#endif
|
||||||
|
|
||||||
ReturnStatements *returns;
|
ReturnStatements *returns;
|
||||||
|
|
||||||
|
|
|
@ -360,7 +360,10 @@ extern (C++) final class EnumDeclaration : ScopeDsymbol
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version (IN_LLVM) {} else
|
||||||
|
{
|
||||||
Symbol* sinit;
|
Symbol* sinit;
|
||||||
|
}
|
||||||
|
|
||||||
override void accept(Visitor v)
|
override void accept(Visitor v)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1491,17 +1491,6 @@ else
|
||||||
}
|
}
|
||||||
|
|
||||||
// Back end
|
// Back end
|
||||||
int doppelganger; // sub-module
|
|
||||||
Symbol* cov; // private uint[] __coverage;
|
|
||||||
uint* covb; // bit array of valid code line numbers
|
|
||||||
Symbol* sictor; // module order independent constructor
|
|
||||||
Symbol* sctor; // module constructor
|
|
||||||
Symbol* sdtor; // module destructor
|
|
||||||
Symbol* ssharedctor; // module shared constructor
|
|
||||||
Symbol* sshareddtor; // module shared destructor
|
|
||||||
Symbol* stest; // module unit test
|
|
||||||
Symbol* sfilename; // symbol for filename
|
|
||||||
|
|
||||||
version (IN_LLVM)
|
version (IN_LLVM)
|
||||||
{
|
{
|
||||||
//llvm::Module* genLLVMModule(llvm::LLVMContext& context);
|
//llvm::Module* genLLVMModule(llvm::LLVMContext& context);
|
||||||
|
@ -1516,6 +1505,19 @@ version (IN_LLVM)
|
||||||
void* d_cover_data; // llvm::GlobalVariable* --> private uint[] _d_cover_data;
|
void* d_cover_data; // llvm::GlobalVariable* --> private uint[] _d_cover_data;
|
||||||
Array!size_t d_cover_valid_init; // initializer for _d_cover_valid
|
Array!size_t d_cover_valid_init; // initializer for _d_cover_valid
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int doppelganger; // sub-module
|
||||||
|
Symbol* cov; // private uint[] __coverage;
|
||||||
|
uint* covb; // bit array of valid code line numbers
|
||||||
|
Symbol* sictor; // module order independent constructor
|
||||||
|
Symbol* sctor; // module constructor
|
||||||
|
Symbol* sdtor; // module destructor
|
||||||
|
Symbol* ssharedctor; // module shared constructor
|
||||||
|
Symbol* sshareddtor; // module shared destructor
|
||||||
|
Symbol* stest; // module unit test
|
||||||
|
Symbol* sfilename; // symbol for filename
|
||||||
|
}
|
||||||
|
|
||||||
override inout(Module) isModule() inout
|
override inout(Module) isModule() inout
|
||||||
{
|
{
|
||||||
|
|
|
@ -235,8 +235,16 @@ extern (C++) class Dsymbol : ASTNode
|
||||||
Dsymbol parent;
|
Dsymbol parent;
|
||||||
/// C++ namespace this symbol belongs to
|
/// C++ namespace this symbol belongs to
|
||||||
CPPNamespaceDeclaration cppnamespace;
|
CPPNamespaceDeclaration cppnamespace;
|
||||||
|
version (IN_LLVM)
|
||||||
|
{
|
||||||
|
void* ir; // IrDsymbol*
|
||||||
|
uint llvmInternal;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Symbol* csym; // symbol for code generator
|
Symbol* csym; // symbol for code generator
|
||||||
Symbol* isym; // import version of csym
|
Symbol* isym; // import version of csym
|
||||||
|
}
|
||||||
const(char)* comment; // documentation comment for this Dsymbol
|
const(char)* comment; // documentation comment for this Dsymbol
|
||||||
const Loc loc; // where defined
|
const Loc loc; // where defined
|
||||||
Scope* _scope; // !=null means context to use for semantic()
|
Scope* _scope; // !=null means context to use for semantic()
|
||||||
|
@ -251,14 +259,6 @@ extern (C++) class Dsymbol : ASTNode
|
||||||
// (only use this with ddoc)
|
// (only use this with ddoc)
|
||||||
UnitTestDeclaration ddocUnittest;
|
UnitTestDeclaration ddocUnittest;
|
||||||
|
|
||||||
version (IN_LLVM)
|
|
||||||
{
|
|
||||||
// llvm stuff
|
|
||||||
uint llvmInternal;
|
|
||||||
|
|
||||||
void* ir; // IrDsymbol*
|
|
||||||
}
|
|
||||||
|
|
||||||
final extern (D) this()
|
final extern (D) this()
|
||||||
{
|
{
|
||||||
//printf("Dsymbol::Dsymbol(%p)\n", this);
|
//printf("Dsymbol::Dsymbol(%p)\n", this);
|
||||||
|
|
|
@ -82,7 +82,7 @@ class OverloadSet;
|
||||||
struct AA;
|
struct AA;
|
||||||
#ifdef IN_GCC
|
#ifdef IN_GCC
|
||||||
typedef union tree_node Symbol;
|
typedef union tree_node Symbol;
|
||||||
#else
|
#elif !IN_LLVM
|
||||||
struct Symbol;
|
struct Symbol;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -157,8 +157,13 @@ public:
|
||||||
Dsymbol *parent;
|
Dsymbol *parent;
|
||||||
/// C++ namespace this symbol belongs to
|
/// C++ namespace this symbol belongs to
|
||||||
CPPNamespaceDeclaration *namespace_;
|
CPPNamespaceDeclaration *namespace_;
|
||||||
|
#if IN_LLVM
|
||||||
|
IrDsymbol *ir;
|
||||||
|
uint32_t llvmInternal;
|
||||||
|
#else
|
||||||
Symbol *csym; // symbol for code generator
|
Symbol *csym; // symbol for code generator
|
||||||
Symbol *isym; // import version of csym
|
Symbol *isym; // import version of csym
|
||||||
|
#endif
|
||||||
const utf8_t *comment; // documentation comment for this Dsymbol
|
const utf8_t *comment; // documentation comment for this Dsymbol
|
||||||
Loc loc; // where defined
|
Loc loc; // where defined
|
||||||
Scope *_scope; // !=NULL means context to use for semantic()
|
Scope *_scope; // !=NULL means context to use for semantic()
|
||||||
|
@ -169,13 +174,6 @@ public:
|
||||||
UserAttributeDeclaration *userAttribDecl; // user defined attributes
|
UserAttributeDeclaration *userAttribDecl; // user defined attributes
|
||||||
UnitTestDeclaration *ddocUnittest; // !=NULL means there's a ddoc unittest associated with this symbol (only use this with ddoc)
|
UnitTestDeclaration *ddocUnittest; // !=NULL means there's a ddoc unittest associated with this symbol (only use this with ddoc)
|
||||||
|
|
||||||
#if IN_LLVM
|
|
||||||
// llvm stuff
|
|
||||||
uint32_t llvmInternal;
|
|
||||||
|
|
||||||
IrDsymbol *ir;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static Dsymbol *create(Identifier *);
|
static Dsymbol *create(Identifier *);
|
||||||
const char *toChars() const;
|
const char *toChars() const;
|
||||||
virtual const char *toPrettyCharsHelper(); // helper to print fully qualified (template) arguments
|
virtual const char *toPrettyCharsHelper(); // helper to print fully qualified (template) arguments
|
||||||
|
|
|
@ -56,7 +56,9 @@ public:
|
||||||
|
|
||||||
EnumDeclaration *isEnumDeclaration() { return this; }
|
EnumDeclaration *isEnumDeclaration() { return this; }
|
||||||
|
|
||||||
|
#if !IN_LLVM
|
||||||
Symbol *sinit;
|
Symbol *sinit;
|
||||||
|
#endif
|
||||||
void accept(Visitor *v) { v->visit(this); }
|
void accept(Visitor *v) { v->visit(this); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3056,8 +3056,10 @@ version (IN_LLVM)
|
||||||
// to the memory used to build the literal for resolving such references.
|
// to the memory used to build the literal for resolving such references.
|
||||||
void* inProgressMemory; // llvm::Value*
|
void* inProgressMemory; // llvm::Value*
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Symbol* sym; /// back end symbol to initialize with literal
|
Symbol* sym; /// back end symbol to initialize with literal
|
||||||
|
}
|
||||||
|
|
||||||
/** pointer to the origin instance of the expression.
|
/** pointer to the origin instance of the expression.
|
||||||
* once a new expression is created, origin is set to 'this'.
|
* once a new expression is created, origin is set to 'this'.
|
||||||
|
|
|
@ -41,7 +41,7 @@ class StringExp;
|
||||||
struct UnionExp;
|
struct UnionExp;
|
||||||
#ifdef IN_GCC
|
#ifdef IN_GCC
|
||||||
typedef union tree_node Symbol;
|
typedef union tree_node Symbol;
|
||||||
#else
|
#elif !IN_LLVM
|
||||||
struct Symbol; // back end symbol
|
struct Symbol; // back end symbol
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -463,9 +463,9 @@ public:
|
||||||
// now contain pointers to themselves. While in toElem, contains a pointer
|
// now contain pointers to themselves. While in toElem, contains a pointer
|
||||||
// to the memory used to build the literal for resolving such references.
|
// to the memory used to build the literal for resolving such references.
|
||||||
llvm::Value *inProgressMemory;
|
llvm::Value *inProgressMemory;
|
||||||
#endif
|
#else
|
||||||
|
|
||||||
Symbol *sym; // back end symbol to initialize with literal
|
Symbol *sym; // back end symbol to initialize with literal
|
||||||
|
#endif
|
||||||
|
|
||||||
/** pointer to the origin instance of the expression.
|
/** pointer to the origin instance of the expression.
|
||||||
* once a new expression is created, origin is set to 'this'.
|
* once a new expression is created, origin is set to 'this'.
|
||||||
|
|
|
@ -296,7 +296,10 @@ version (IN_LLVM)
|
||||||
// Support for NRVO (named return value optimization)
|
// Support for NRVO (named return value optimization)
|
||||||
bool nrvo_can = true; /// true means we can do NRVO
|
bool nrvo_can = true; /// true means we can do NRVO
|
||||||
VarDeclaration nrvo_var; /// variable to replace with shidden
|
VarDeclaration nrvo_var; /// variable to replace with shidden
|
||||||
|
version (IN_LLVM) {} else
|
||||||
|
{
|
||||||
Symbol* shidden; /// hidden pointer passed to function
|
Symbol* shidden; /// hidden pointer passed to function
|
||||||
|
}
|
||||||
|
|
||||||
ReturnStatements* returns;
|
ReturnStatements* returns;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ import dmd.root.file;
|
||||||
|
|
||||||
version (IN_LLVM)
|
version (IN_LLVM)
|
||||||
{
|
{
|
||||||
struct Symbol;
|
|
||||||
struct code;
|
struct code;
|
||||||
struct block;
|
struct block;
|
||||||
struct Blockx;
|
struct Blockx;
|
||||||
|
|
|
@ -663,8 +663,11 @@ public:
|
||||||
auto vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd._init);
|
auto vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd._init);
|
||||||
memcpy(cast(void*)vto, cast(void*)vd, __traits(classInstanceSize, VarDeclaration));
|
memcpy(cast(void*)vto, cast(void*)vd, __traits(classInstanceSize, VarDeclaration));
|
||||||
vto.parent = ids.parent;
|
vto.parent = ids.parent;
|
||||||
|
version (IN_LLVM) {} else
|
||||||
|
{
|
||||||
vto.csym = null;
|
vto.csym = null;
|
||||||
vto.isym = null;
|
vto.isym = null;
|
||||||
|
}
|
||||||
|
|
||||||
ids.from.push(vd);
|
ids.from.push(vd);
|
||||||
ids.to.push(vto);
|
ids.to.push(vto);
|
||||||
|
@ -817,8 +820,11 @@ public:
|
||||||
auto vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd._init);
|
auto vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd._init);
|
||||||
memcpy(cast(void*)vto, cast(void*)vd, __traits(classInstanceSize, VarDeclaration));
|
memcpy(cast(void*)vto, cast(void*)vd, __traits(classInstanceSize, VarDeclaration));
|
||||||
vto.parent = ids.parent;
|
vto.parent = ids.parent;
|
||||||
|
version (IN_LLVM) {} else
|
||||||
|
{
|
||||||
vto.csym = null;
|
vto.csym = null;
|
||||||
vto.isym = null;
|
vto.isym = null;
|
||||||
|
}
|
||||||
|
|
||||||
ids.from.push(vd);
|
ids.from.push(vd);
|
||||||
ids.to.push(vto);
|
ids.to.push(vto);
|
||||||
|
@ -846,8 +852,11 @@ public:
|
||||||
auto vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd._init);
|
auto vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd._init);
|
||||||
memcpy(cast(void*)vto, cast(void*)vd, __traits(classInstanceSize, VarDeclaration));
|
memcpy(cast(void*)vto, cast(void*)vd, __traits(classInstanceSize, VarDeclaration));
|
||||||
vto.parent = ids.parent;
|
vto.parent = ids.parent;
|
||||||
|
version (IN_LLVM) {} else
|
||||||
|
{
|
||||||
vto.csym = null;
|
vto.csym = null;
|
||||||
vto.isym = null;
|
vto.isym = null;
|
||||||
|
}
|
||||||
|
|
||||||
ids.from.push(vd);
|
ids.from.push(vd);
|
||||||
ids.to.push(vto);
|
ids.to.push(vto);
|
||||||
|
|
28
dmd/module.h
28
dmd/module.h
|
@ -147,6 +147,20 @@ public:
|
||||||
|
|
||||||
// Back end
|
// Back end
|
||||||
|
|
||||||
|
#if IN_LLVM
|
||||||
|
llvm::Module *genLLVMModule(llvm::LLVMContext &context);
|
||||||
|
void checkAndAddOutputFile(const FileName &file);
|
||||||
|
void makeObjectFilenameUnique();
|
||||||
|
|
||||||
|
bool llvmForceLogging;
|
||||||
|
bool noModuleInfo; /// Do not emit any module metadata.
|
||||||
|
|
||||||
|
// Coverage analysis
|
||||||
|
llvm::GlobalVariable
|
||||||
|
*d_cover_valid; // private immutable size_t[] _d_cover_valid;
|
||||||
|
llvm::GlobalVariable *d_cover_data; // private uint[] _d_cover_data;
|
||||||
|
Array<size_t> d_cover_valid_init; // initializer for _d_cover_valid
|
||||||
|
#else
|
||||||
int doppelganger; // sub-module
|
int doppelganger; // sub-module
|
||||||
Symbol *cov; // private uint[] __coverage;
|
Symbol *cov; // private uint[] __coverage;
|
||||||
unsigned *covb; // bit array of valid code line numbers
|
unsigned *covb; // bit array of valid code line numbers
|
||||||
|
@ -159,20 +173,6 @@ public:
|
||||||
Symbol *stest; // module unit test
|
Symbol *stest; // module unit test
|
||||||
|
|
||||||
Symbol *sfilename; // symbol for filename
|
Symbol *sfilename; // symbol for filename
|
||||||
|
|
||||||
#if IN_LLVM
|
|
||||||
// LDC
|
|
||||||
llvm::Module* genLLVMModule(llvm::LLVMContext& context);
|
|
||||||
void checkAndAddOutputFile(const FileName &file);
|
|
||||||
void makeObjectFilenameUnique();
|
|
||||||
|
|
||||||
bool llvmForceLogging;
|
|
||||||
bool noModuleInfo; /// Do not emit any module metadata.
|
|
||||||
|
|
||||||
// Coverage analysis
|
|
||||||
llvm::GlobalVariable* d_cover_valid; // private immutable size_t[] _d_cover_valid;
|
|
||||||
llvm::GlobalVariable* d_cover_data; // private uint[] _d_cover_data;
|
|
||||||
Array<size_t> d_cover_valid_init; // initializer for _d_cover_valid
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Module *isModule() { return this; }
|
Module *isModule() { return this; }
|
||||||
|
|
11
gen/toir.cpp
11
gen/toir.cpp
|
@ -2924,14 +2924,3 @@ bool toInPlaceConstruction(DLValue *lhs, Expression *rhs) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// FIXME: Implement & place in right module
|
|
||||||
Symbol *toModuleAssert(Module *m) { return nullptr; }
|
|
||||||
|
|
||||||
// FIXME: Implement & place in right module
|
|
||||||
Symbol *toModuleUnittest(Module *m) { return nullptr; }
|
|
||||||
|
|
||||||
// FIXME: Implement & place in right module
|
|
||||||
Symbol *toModuleArray(Module *m) { return nullptr; }
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue