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 {
101101 guard let callee = calleeOfOnce, callee. isDefinition else {
102102 return
103103 }
104+ context. notifyDependency ( onBodyOf: callee)
105+
104106 // If the callee is side effect-free we can remove the whole builtin "once".
105107 // We don't use the callee's memory effects but instead look at all callee instructions
106108 // 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 {
210210 func notifyBranchesChanged( ) {
211211 _bridged. asNotificationHandler ( ) . notifyChanges ( . branchesChanged)
212212 }
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+ }
213219}
214220
215221/// 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 {
171171
172172 SWIFT_IMPORT_UNSAFE BridgedOwnedString getModuleDescription () const ;
173173 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedChangeNotificationHandler asNotificationHandler () const ;
174+ BRIDGED_INLINE void notifyDependencyOnBodyOf (BridgedFunction otherFunction) const ;
174175 BRIDGED_INLINE SILStage getSILStage () const ;
175176 BRIDGED_INLINE bool hadError () const ;
176177 BRIDGED_INLINE bool moduleIsSerialized () const ;
Original file line number Diff line number Diff line change @@ -137,6 +137,12 @@ BridgedChangeNotificationHandler BridgedPassContext::asNotificationHandler() con
137137 return {invocation};
138138}
139139
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+
140146BridgedPassContext::SILStage BridgedPassContext::getSILStage () const {
141147 return (SILStage)invocation->getPassManager ()->getModule ()->getStage ();
142148}
You can’t perform that action at this time.
0 commit comments