[Exclusivity] Add deserialization callbacks from the optimizer.

AccessMarkerElimination now registers a callback so that any subsequently
deserialized function bodies will have access markers stripped for optimization.

rdar:31908496 Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of
              incompatible type!") in SILPerformanceInliner
This commit is contained in:
Andrew Trick
2017-05-01 19:32:09 -07:00
parent 87526696ad
commit 195da33d1d
4 changed files with 100 additions and 34 deletions

View File

@@ -74,6 +74,12 @@ class SILModule::SerializationCallback : public SerializedSILLoader::Callback {
return;
}
}
void didDeserializeFunctionBody(ModuleDecl *M, SILFunction *fn) override {
// Callbacks are currently applied in the order they are registered.
for (auto callBack : fn->getModule().getDeserializationCallbacks())
callBack(M, fn);
}
};
SILModule::SILModule(ModuleDecl *SwiftModule, SILOptions &Options,
@@ -726,6 +732,18 @@ lookUpFunctionInVTable(ClassDecl *Class, SILDeclRef Member) {
return nullptr;
}
void SILModule::registerDeserializationCallback(
SILFunctionBodyCallback callBack) {
if (std::find(DeserializationCallbacks.begin(),
DeserializationCallbacks.end(), callBack)
== DeserializationCallbacks.end())
DeserializationCallbacks.push_back(callBack);
}
ArrayRef<SILModule::SILFunctionBodyCallback>
SILModule::getDeserializationCallbacks() {
return DeserializationCallbacks;
}
void SILModule::
registerDeleteNotificationHandler(DeleteNotificationHandler* Handler) {