Clean up the linkage model and the computation of linkage.

In general, this forces SILGen and IRGen code that's grabbing
a declaration to state whether it's doing so to define it.

Change SIL serialization to serialize the linkage of functions
and global variables, which means also serializing declarations.

Change the deserializer to use this stored linkage, even when
only deserializing a declaration, and to call a callback to
inform the client that it has deserialized a new entity.

Take advantage of that callback in the linking pass to alter
the deserialized linkage as appropriate for the fact that we
imported the declaration.  This computation should really take
advantage of the relationship between modules, but currently
it does not.

Swift SVN r12090
This commit is contained in:
John McCall
2014-01-09 08:58:07 +00:00
parent 622c2f6ce8
commit 5da6defa1f
48 changed files with 1289 additions and 617 deletions

View File

@@ -18,7 +18,6 @@ using namespace swift;
SILGlobalVariable *SILGlobalVariable::create(SILModule &M, SILLinkage linkage,
StringRef name,
SILType loweredType,
bool isDefinition,
Optional<SILLocation> loc) {
// Get a StringMapEntry for the variable. As a sop to error cases,
// allow the name to have an empty string.
@@ -29,8 +28,7 @@ SILGlobalVariable *SILGlobalVariable::create(SILModule &M, SILLinkage linkage,
name = entry->getKey();
}
auto var = new (M) SILGlobalVariable(M, linkage, name, loweredType,
isDefinition, loc);
auto var = new (M) SILGlobalVariable(M, linkage, name, loweredType, loc);
if (entry) entry->setValue(var);
return var;
@@ -39,13 +37,12 @@ SILGlobalVariable *SILGlobalVariable::create(SILModule &M, SILLinkage linkage,
SILGlobalVariable::SILGlobalVariable(SILModule &Module, SILLinkage Linkage,
StringRef Name, SILType LoweredType,
bool IsDefinition,
Optional<SILLocation> Loc)
: ModuleAndLinkage(&Module, Linkage),
: Module(Module),
Name(Name),
LoweredType(LoweredType),
Location(Loc),
IsDefinition(IsDefinition) {
Linkage(unsigned(Linkage)) {
Module.silGlobals.push_back(this);
}