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 Sep 15, 2014
1 parent 907f215 commit 4cb3adb
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 @@ -55,7 +55,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 @@ -121,7 +123,6 @@ void semanticTypeInfo(Scope *sc, Type *t)
FullTypeInfoVisitor v;
v.sc = sc;
t->accept(&v);
#endif
}

/********************************* AggregateDeclaration ****************************/
Expand Down Expand Up @@ -211,7 +212,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 @@ -1091,7 +1091,7 @@ void TypeInfoDeclaration::toObjFile(bool multiobj)
if (semanticRun >= PASSobj) // already written
return;

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

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

if (global.params.allInst)
{
// Generate COMDAT
if (sc) // if in semantic() pass
{
if (sc->func && !sc->func->isInstantiated() && 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
{
t->vtinfo->toObjFile(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 4cb3adb

Please sign in to comment.