Frontend: Get rid of unused backend-reserved Symbol

Somewhat reducing memory requirements by stripping the unused fields too.
This commit is contained in:
Martin Kinkelin 2020-07-01 22:36:48 +02:00
parent 34e3230ef2
commit 48e8c2ecee
16 changed files with 77 additions and 58 deletions

View file

@ -829,9 +829,12 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
return type;
}
version (IN_LLVM) {} else
{
// Back end
Symbol* stag; // tag symbol for debug data
Symbol* sinit;
}
override final inout(AggregateDeclaration) isAggregateDeclaration() inout
{

View file

@ -138,9 +138,11 @@ public:
// 'this' type
Type *handleType() { return type; }
#if !IN_LLVM
// Back end
Symbol *stag; // tag symbol for debug data
Symbol *sinit;
#endif
AggregateDeclaration *isAggregateDeclaration() { return this; }
void accept(Visitor *v) { v->visit(this); }
@ -279,7 +281,9 @@ public:
Abstract isabstract; // 0: fwdref, 1: is abstract class, 2: not abstract
Baseok baseok; // set the progress of base classes resolving
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
#endif
static ClassDeclaration *create(Loc loc, Identifier *id, BaseClasses *baseclasses, Dsymbols *members, bool inObject);
Dsymbol *syntaxCopy(Dsymbol *s);

View file

@ -223,7 +223,10 @@ extern (C++) class ClassDeclaration : AggregateDeclaration
*/
ObjcClassDeclaration objc;
version (IN_LLVM) {} else
{
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)
{

View file

@ -543,7 +543,9 @@ public:
// Support for NRVO (named return value optimization)
bool nrvo_can; // true means we can do it
VarDeclaration *nrvo_var; // variable to replace with shidden
#if !IN_LLVM
Symbol *shidden; // hidden pointer passed to function
#endif
ReturnStatements *returns;

View file

@ -360,7 +360,10 @@ extern (C++) final class EnumDeclaration : ScopeDsymbol
return this;
}
version (IN_LLVM) {} else
{
Symbol* sinit;
}
override void accept(Visitor v)
{

View file

@ -1491,17 +1491,6 @@ else
}
// 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)
{
//llvm::Module* genLLVMModule(llvm::LLVMContext& context);
@ -1516,6 +1505,19 @@ version (IN_LLVM)
void* d_cover_data; // llvm::GlobalVariable* --> private uint[] _d_cover_data;
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
{

View file

@ -235,8 +235,16 @@ extern (C++) class Dsymbol : ASTNode
Dsymbol parent;
/// C++ namespace this symbol belongs to
CPPNamespaceDeclaration cppnamespace;
version (IN_LLVM)
{
void* ir; // IrDsymbol*
uint llvmInternal;
}
else
{
Symbol* csym; // symbol for code generator
Symbol* isym; // import version of csym
}
const(char)* comment; // documentation comment for this Dsymbol
const Loc loc; // where defined
Scope* _scope; // !=null means context to use for semantic()
@ -251,14 +259,6 @@ extern (C++) class Dsymbol : ASTNode
// (only use this with ddoc)
UnitTestDeclaration ddocUnittest;
version (IN_LLVM)
{
// llvm stuff
uint llvmInternal;
void* ir; // IrDsymbol*
}
final extern (D) this()
{
//printf("Dsymbol::Dsymbol(%p)\n", this);

View file

@ -82,7 +82,7 @@ class OverloadSet;
struct AA;
#ifdef IN_GCC
typedef union tree_node Symbol;
#else
#elif !IN_LLVM
struct Symbol;
#endif
@ -157,8 +157,13 @@ public:
Dsymbol *parent;
/// C++ namespace this symbol belongs to
CPPNamespaceDeclaration *namespace_;
#if IN_LLVM
IrDsymbol *ir;
uint32_t llvmInternal;
#else
Symbol *csym; // symbol for code generator
Symbol *isym; // import version of csym
#endif
const utf8_t *comment; // documentation comment for this Dsymbol
Loc loc; // where defined
Scope *_scope; // !=NULL means context to use for semantic()
@ -169,13 +174,6 @@ public:
UserAttributeDeclaration *userAttribDecl; // user defined attributes
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 *);
const char *toChars() const;
virtual const char *toPrettyCharsHelper(); // helper to print fully qualified (template) arguments

View file

@ -56,7 +56,9 @@ public:
EnumDeclaration *isEnumDeclaration() { return this; }
#if !IN_LLVM
Symbol *sinit;
#endif
void accept(Visitor *v) { v->visit(this); }
};

View file

@ -3056,8 +3056,10 @@ version (IN_LLVM)
// to the memory used to build the literal for resolving such references.
void* inProgressMemory; // llvm::Value*
}
else
{
Symbol* sym; /// back end symbol to initialize with literal
}
/** pointer to the origin instance of the expression.
* once a new expression is created, origin is set to 'this'.

View file

@ -41,7 +41,7 @@ class StringExp;
struct UnionExp;
#ifdef IN_GCC
typedef union tree_node Symbol;
#else
#elif !IN_LLVM
struct Symbol; // back end symbol
#endif
@ -463,9 +463,9 @@ public:
// now contain pointers to themselves. While in toElem, contains a pointer
// to the memory used to build the literal for resolving such references.
llvm::Value *inProgressMemory;
#endif
#else
Symbol *sym; // back end symbol to initialize with literal
#endif
/** pointer to the origin instance of the expression.
* once a new expression is created, origin is set to 'this'.

View file

@ -296,7 +296,10 @@ version (IN_LLVM)
// Support for NRVO (named return value optimization)
bool nrvo_can = true; /// true means we can do NRVO
VarDeclaration nrvo_var; /// variable to replace with shidden
version (IN_LLVM) {} else
{
Symbol* shidden; /// hidden pointer passed to function
}
ReturnStatements* returns;

View file

@ -22,7 +22,6 @@ import dmd.root.file;
version (IN_LLVM)
{
struct Symbol;
struct code;
struct block;
struct Blockx;

View file

@ -663,8 +663,11 @@ public:
auto vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd._init);
memcpy(cast(void*)vto, cast(void*)vd, __traits(classInstanceSize, VarDeclaration));
vto.parent = ids.parent;
version (IN_LLVM) {} else
{
vto.csym = null;
vto.isym = null;
}
ids.from.push(vd);
ids.to.push(vto);
@ -817,8 +820,11 @@ public:
auto vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd._init);
memcpy(cast(void*)vto, cast(void*)vd, __traits(classInstanceSize, VarDeclaration));
vto.parent = ids.parent;
version (IN_LLVM) {} else
{
vto.csym = null;
vto.isym = null;
}
ids.from.push(vd);
ids.to.push(vto);
@ -846,8 +852,11 @@ public:
auto vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd._init);
memcpy(cast(void*)vto, cast(void*)vd, __traits(classInstanceSize, VarDeclaration));
vto.parent = ids.parent;
version (IN_LLVM) {} else
{
vto.csym = null;
vto.isym = null;
}
ids.from.push(vd);
ids.to.push(vto);

View file

@ -147,6 +147,20 @@ public:
// 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
Symbol *cov; // private uint[] __coverage;
unsigned *covb; // bit array of valid code line numbers
@ -159,20 +173,6 @@ public:
Symbol *stest; // module unit test
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
Module *isModule() { return this; }

View file

@ -2924,14 +2924,3 @@ bool toInPlaceConstruction(DLValue *lhs, Expression *rhs) {
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; }