mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Make delete notifications elective
This commit adds a hook that allows passes, analysis or data structures that can be registered as receivers of delete notifications to decide if they want to receive notifications All of the analysis and the currently executing passes are automatically registered to receive notifications and this hook is useful in reducing the runtime overhead. With this change the only analysis that accepts notifications is alias analysis.
This commit is contained in:
@@ -17,7 +17,7 @@ namespace swift {
|
||||
|
||||
class ValueBase;
|
||||
|
||||
/// A protocol (or inferface) for handling value deletion notifications.
|
||||
/// A protocol (or interface) for handling value deletion notifications.
|
||||
///
|
||||
/// This class is used as a base class for any class that need to accept
|
||||
/// instruction deletion notification messages. This is used by passes and
|
||||
@@ -30,6 +30,12 @@ struct DeleteNotificationHandler {
|
||||
|
||||
/// Handle the invalidation message for the value \p Value.
|
||||
virtual void handleDeleteNotification(swift::ValueBase *Value) { }
|
||||
|
||||
/// Returns True if the pass, analysis or other entity wants to receive
|
||||
/// notifications. This callback is called once when the class is being
|
||||
/// registered, and not once per notification. Entities that implement
|
||||
/// this callback should always return a constant answer (true/false).
|
||||
virtual bool needsNotifications() { return false; }
|
||||
};
|
||||
|
||||
} // end swift namespace
|
||||
|
||||
@@ -117,6 +117,9 @@ private:
|
||||
ValueBaseToIndex.invalidateValue(I);
|
||||
}
|
||||
|
||||
virtual bool needsNotifications() override { return true; }
|
||||
|
||||
|
||||
public:
|
||||
AliasAnalysis(SILModule *M) :
|
||||
SILAnalysis(AnalysisKind::Alias), Mod(M), SEA(nullptr) {}
|
||||
|
||||
@@ -681,7 +681,11 @@ lookUpFunctionInVTable(ClassDecl *Class, SILDeclRef Member) {
|
||||
|
||||
void SILModule::
|
||||
registerDeleteNotificationHandler(DeleteNotificationHandler* Handler) {
|
||||
// Ask the handler (that can be an analysis, a pass, or some other data
|
||||
// structure) if it wants to receive delete notifications.
|
||||
if (Handler->needsNotifications()) {
|
||||
NotificationHandlers.insert(Handler);
|
||||
}
|
||||
}
|
||||
|
||||
void SILModule::
|
||||
|
||||
@@ -355,8 +355,6 @@ class SILCombine : public SILFunctionTransform {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void handleDeleteNotification(ValueBase *I) override { }
|
||||
|
||||
StringRef getName() override { return "SIL Combine"; }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user