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

@@ -15,8 +15,10 @@
namespace swift {
class ASTContext;
class Module;
class SILDeserializer;
class SILFunction;
class SILGlobalVariable;
class SILModule;
class SILVTable;
@@ -24,15 +26,42 @@ class SILVTable;
/// in ASTContext. It provides lookupSILFunction that will perform lookup
/// on each SILDeserializer.
class SerializedSILLoader {
public:
class Callback {
public:
/// Observe that we deserialized a function declaration.
virtual void didDeserialize(Module *M, SILFunction *fn) {}
/// Observe that we successfully deserialized a function body.
virtual void didDeserializeBody(Module *M, SILFunction *fn) {}
/// Observe that we deserialized a global variable declaration.
virtual void didDeserialize(Module *M, SILGlobalVariable *var) {}
/// Observe that we deserialized a v-table declaration.
virtual void didDeserialize(Module *M, SILVTable *vtable) {}
virtual ~Callback() {}
private:
virtual void _anchor();
};
private:
std::vector<std::unique_ptr<SILDeserializer> > LoadedSILSections;
explicit SerializedSILLoader(ASTContext &ctx, SILModule *SILMod);
explicit SerializedSILLoader(ASTContext &ctx, SILModule *SILMod,
Callback *callback);
public:
static SerializedSILLoader *create(ASTContext &ctx, SILModule *SILMod) {
return new SerializedSILLoader(ctx, SILMod);
/// Create a new loader.
///
/// \param callback - not owned by the loader
static SerializedSILLoader *create(ASTContext &ctx, SILModule *SILMod,
Callback *callback) {
return new SerializedSILLoader(ctx, SILMod, callback);
}
~SerializedSILLoader();
SILFunction *lookupSILFunction(SILFunction *Callee);
SILVTable *lookupVTable(Identifier Name);
/// Deserialize all VTables in all SILModules.