Skip to content

Commit

Permalink
Support -allinst for old TypeInfo generation strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Jul 25, 2015
1 parent c8adc88 commit b06abfb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/struct.c
Expand Up @@ -56,7 +56,9 @@ FuncDeclaration *search_toString(StructDeclaration *sd)
*/
void semanticTypeInfo(Scope *sc, Type *t)
{
#if 0
if (!global.params.allInst)
return;

class FullTypeInfoVisitor : public Visitor
{
public:
Expand Down Expand Up @@ -125,7 +127,6 @@ void semanticTypeInfo(Scope *sc, Type *t)
FullTypeInfoVisitor v;
v.sc = sc;
t->accept(&v);
#endif
}

/********************************* AggregateDeclaration ****************************/
Expand Down Expand Up @@ -216,7 +217,7 @@ void AggregateDeclaration::semantic3(Scope *sc)
StructDeclaration *sd = isStructDeclaration();
if (!sc) // from runDeferredSemantic3 for TypeInfo generation
{
assert(sd);
assert(sd && global.params.allInst);
sd->semanticTypeInfoMembers();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/toobj.c
Expand Up @@ -1018,7 +1018,7 @@ void toObjFile(Dsymbol *ds, bool multiobj)
if (tid->semanticRun >= PASSobj) // already written
return;

if (tid->tinfo->mod == 0)
if (tid->tinfo->mod == 0 && !global.params.allInst)
{
Dsymbol *sym = tid->tinfo->toDsymbol(NULL);
if (sym)
Expand Down
32 changes: 32 additions & 0 deletions src/typinf.c
Expand Up @@ -69,7 +69,39 @@ void genTypeInfo(Type *torig, Scope *sc)
else
t->vtinfo = getTypeInfoDeclaration(t);
assert(t->vtinfo);

/* If this has a custom implementation in std/typeinfo, then
* do not generate a COMDAT for it.
*/
if (builtinTypeInfo(t))
goto Lskip;

if (global.params.allInst)
{
// Generate COMDAT
if (sc) // if in semantic() pass
{
if (sc->func && sc->func->inNonRoot())
{
// Bugzilla 13043: Avoid linking TypeInfo if it's not
// necessary for root module compilation
}
else
{
// Find module that will go all the way to an object file
Module *m = sc->module->importedFrom;
m->members->push(t->vtinfo);

semanticTypeInfo(sc, t);
}
}
else // if in obj generation pass
{
toObjFile(t->vtinfo, global.params.multiobj);
}
}
}
if (!global.params.allInst)
{
/* If this has a custom implementation in std/typeinfo, then
* do not generate a COMDAT for it.
Expand Down

0 comments on commit b06abfb

Please sign in to comment.