@@ -230,11 +230,36 @@ class DebugPrintEnabler {
230
230
}
231
231
};
232
232
233
+ // ===----------------------------------------------------------------------===//
234
+ // Serialization Notification Implementation
235
+ // ===----------------------------------------------------------------------===//
236
+
237
+ namespace {
238
+
239
+ class PassManagerDeserializationNotificationHandler final
240
+ : public DeserializationNotificationHandler {
241
+ NullablePtr<SILPassManager> pm;
242
+
243
+ public:
244
+ PassManagerDeserializationNotificationHandler (SILPassManager *pm) : pm(pm) {}
245
+ ~PassManagerDeserializationNotificationHandler () override = default ;
246
+
247
+ StringRef getName () const override {
248
+ return " PassManagerDeserializationNotificationHandler" ;
249
+ }
250
+
251
+ // / Observe that we deserialized a function declaration.
252
+ void didDeserialize (ModuleDecl *mod, SILFunction *fn) override {
253
+ pm.get ()->notifyAnalysisOfFunction (fn);
254
+ }
255
+ };
256
+
257
+ } // end anonymous namespace
233
258
234
259
SILPassManager::SILPassManager (SILModule *M, llvm::StringRef Stage,
235
- bool isMandatoryPipeline) :
236
- Mod(M), StageName(Stage), isMandatoryPipeline(isMandatoryPipeline) {
237
-
260
+ bool isMandatoryPipeline)
261
+ : Mod(M), StageName(Stage), isMandatoryPipeline(isMandatoryPipeline),
262
+ deserializationNotificationHandler( nullptr ) {
238
263
#define ANALYSIS (NAME ) \
239
264
Analyses.push_back (create##NAME##Analysis (Mod));
240
265
#include " swift/SILOptimizer/Analysis/Analysis.def"
@@ -243,6 +268,11 @@ SILPassManager::SILPassManager(SILModule *M, llvm::StringRef Stage,
243
268
A->initialize (this );
244
269
M->registerDeleteNotificationHandler (A);
245
270
}
271
+
272
+ std::unique_ptr<DeserializationNotificationHandler> handler (
273
+ new PassManagerDeserializationNotificationHandler (this ));
274
+ deserializationNotificationHandler = handler.get ();
275
+ M->registerDeserializationNotificationHandler (std::move (handler));
246
276
}
247
277
248
278
SILPassManager::SILPassManager (SILModule *M, irgen::IRGenModule *IRMod,
@@ -539,6 +569,10 @@ SILPassManager::~SILPassManager() {
539
569
assert (IRGenPasses.empty () && " Must add IRGen SIL passes that were "
540
570
" registered to the list of transformations" );
541
571
572
+ // Remove our deserialization notification handler.
573
+ Mod->removeDeserializationNotificationHandler (
574
+ deserializationNotificationHandler);
575
+
542
576
// Free all transformations.
543
577
for (auto *T : Transformations)
544
578
delete T;
0 commit comments