File tree Expand file tree Collapse file tree 4 files changed +15
-0
lines changed
SwiftCompilerSources/Sources/Optimizer
InstructionSimplification
include/swift/SILOptimizer Expand file tree Collapse file tree 4 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,8 @@ private extension BuiltinInst {
101
101
guard let callee = calleeOfOnce, callee. isDefinition else {
102
102
return
103
103
}
104
+ context. notifyDependency ( onBodyOf: callee)
105
+
104
106
// If the callee is side effect-free we can remove the whole builtin "once".
105
107
// We don't use the callee's memory effects but instead look at all callee instructions
106
108
// because memory effects are not computed in the Onone pipeline, yet.
Original file line number Diff line number Diff line change @@ -210,6 +210,12 @@ extension MutatingContext {
210
210
func notifyBranchesChanged( ) {
211
211
_bridged. asNotificationHandler ( ) . notifyChanges ( . branchesChanged)
212
212
}
213
+
214
+ /// Notifies the pass manager that the optimization result of the current pass depends
215
+ /// on the body (i.e. SIL instructions) of another function than the currently optimized one.
216
+ func notifyDependency( onBodyOf otherFunction: Function ) {
217
+ _bridged. notifyDependencyOnBodyOf ( otherFunction. bridged)
218
+ }
213
219
}
214
220
215
221
/// The context which is passed to the run-function of a FunctionPass.
Original file line number Diff line number Diff line change @@ -171,6 +171,7 @@ struct BridgedPassContext {
171
171
172
172
SWIFT_IMPORT_UNSAFE BridgedOwnedString getModuleDescription () const ;
173
173
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedChangeNotificationHandler asNotificationHandler () const ;
174
+ BRIDGED_INLINE void notifyDependencyOnBodyOf (BridgedFunction otherFunction) const ;
174
175
BRIDGED_INLINE SILStage getSILStage () const ;
175
176
BRIDGED_INLINE bool hadError () const ;
176
177
BRIDGED_INLINE bool moduleIsSerialized () const ;
Original file line number Diff line number Diff line change @@ -137,6 +137,12 @@ BridgedChangeNotificationHandler BridgedPassContext::asNotificationHandler() con
137
137
return {invocation};
138
138
}
139
139
140
+ void BridgedPassContext::notifyDependencyOnBodyOf (BridgedFunction otherFunction) const {
141
+ // Currently `otherFunction` is ignored. We could design a more accurate dependency system
142
+ // in the pass manager, which considers the actual function. But it's probaboly not worth the effort.
143
+ invocation->getPassManager ()->setDependingOnCalleeBodies ();
144
+ }
145
+
140
146
BridgedPassContext::SILStage BridgedPassContext::getSILStage () const {
141
147
return (SILStage)invocation->getPassManager ()->getModule ()->getStage ();
142
148
}
You can’t perform that action at this time.
0 commit comments