[deserialization] Create the SILLoader for a SILModule lazily the first time deserialization occurs instead of when the SILModule is created.

This enables us to get around timing issues when we create a SILModule before we
have finished loading all Swift Modules.

This manifested itself in sil-opt where we were unable to deserialize from the
standard library when optimizing a separate *.sil file.

Swift SVN r15670
This commit is contained in:
Michael Gottesman
2014-03-31 08:40:35 +00:00
parent fb22ec4c6e
commit 0d0c00ce15
2 changed files with 25 additions and 9 deletions

View File

@@ -23,6 +23,7 @@
#include "swift/AST/SILOptions.h"
#include "swift/Basic/LangOptions.h"
#include "swift/Basic/Range.h"
#include "swift/Basic/NullablePtr.h"
#include "swift/SIL/SILDeclRef.h"
#include "swift/SIL/SILFunction.h"
#include "swift/SIL/SILGlobalVariable.h"
@@ -144,7 +145,12 @@ private:
std::unique_ptr<SerializationCallback> Callback;
/// The SILLoader used when linking functions into this module.
SerializedSILLoader *SILLoader;
///
/// This is lazily initialized the first time we attempt to
/// deserialize. Previously this was created when the SILModule was
/// constructed. In certain cases this was before all Modules had been loaded
/// causeing us to not
NullablePtr<SerializedSILLoader> SILLoader;
/// The external SIL source to use when linking this module.
SILExternalSource *ExternalSource = nullptr;
@@ -156,6 +162,10 @@ private:
SILModule(const SILModule&) = delete;
void operator=(const SILModule&) = delete;
/// Method which returns the SerializedSILLoader, creating the loader if it
/// has not been created yet.
SerializedSILLoader *getSILLoader();
public:
~SILModule();