mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Update the pass manager to allow for function creation in function passes.
Add interfaces and update the pass execution logic to allow function passes to create new functions, or ask for functions to be optimized prior to continuing. Doing so results in the pass pipeline halting execution on the current function, and continuing with newly added functions, returning to the previous function after the newly added functions are fully optimized.
This commit is contained in:
@@ -92,6 +92,13 @@ public:
|
||||
/// \brief Run one iteration of the optimization pipeline.
|
||||
void runOneIteration();
|
||||
|
||||
/// \brief Add a function to the function pass worklist.
|
||||
void addFunctionToWorklist(SILFunction *F) {
|
||||
assert(F && F->isDefinition() && F->shouldOptimize() &&
|
||||
"Expected optimizable function definition!");
|
||||
FunctionWorklist.push_back(F);
|
||||
}
|
||||
|
||||
/// \brief Broadcast the invalidation of the module to all analysis.
|
||||
void invalidateAnalysis(SILAnalysis::InvalidationKind K) {
|
||||
assert(K != SILAnalysis::InvalidationKind::Nothing &&
|
||||
|
||||
@@ -96,6 +96,12 @@ namespace swift {
|
||||
|
||||
void injectFunction(SILFunction *Func) { F = Func; }
|
||||
|
||||
/// \brief Notify the pass manager of a function that needs to be
|
||||
/// processed by the function passes.
|
||||
void notifyPassManagerOfFunction(SILFunction *F) {
|
||||
PM->addFunctionToWorklist(F);
|
||||
}
|
||||
|
||||
protected:
|
||||
SILFunction *getFunction() { return F; }
|
||||
|
||||
@@ -139,4 +145,3 @@ namespace swift {
|
||||
} // end namespace swift
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user