Skip to content

Commit beebd5a

Browse files
committed
PassManager: add a invalidation kind for non-body function data
E.g. used if function effects are changed. This tells the passmanager that something changed, but no SIL-specific analysis have to be invalidated.
1 parent 3bba7ca commit beebd5a

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

SwiftCompilerSources/Sources/Optimizer/PassManager/PassContext.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ struct PassContext {
117117
}
118118

119119
func modifyEffects(in function: Function, _ body: (inout FunctionEffects) -> ()) {
120+
notifyFunctionDataChanged()
120121
function._modifyEffects(body)
121-
// TODO: do we need to notify any changes?
122122
}
123123

124124
//===--------------------------------------------------------------------===//
@@ -136,6 +136,10 @@ struct PassContext {
136136
fileprivate func notifyBranchesChanged() {
137137
PassContext_notifyChanges(_bridged, branchesChanged)
138138
}
139+
140+
fileprivate func notifyFunctionDataChanged() {
141+
PassContext_notifyChanges(_bridged, functionDataChanged)
142+
}
139143
}
140144

141145
//===----------------------------------------------------------------------===//

include/swift/SIL/SILBridging.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ enum {
2929
enum ChangeNotificationKind {
3030
instructionsChanged,
3131
callsChanged,
32-
branchesChanged
32+
branchesChanged,
33+
functionDataChanged
3334
};
3435

3536
typedef struct {

include/swift/SILOptimizer/Analysis/Analysis.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,20 @@ class SILAnalysis {
6464
/// has been modified.
6565
Branches = 0x4,
6666

67+
/// Any function data other than its body.
68+
///
69+
/// It does not trigger any analysis invalidation, but tells the pass
70+
/// manager that some changes were made.
71+
FunctionData = 0x8,
72+
6773
/// Convenience states:
6874
FunctionBody = Calls | Branches | Instructions,
6975

7076
CallsAndInstructions = Calls | Instructions,
7177

7278
BranchesAndInstructions = Branches | Instructions,
7379

74-
Everything = Calls | Branches | Instructions,
80+
Everything = Calls | Branches | Instructions | FunctionData,
7581
};
7682

7783
private:

lib/SILOptimizer/PassManager/PassManager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,9 @@ void PassContext_notifyChanges(BridgedPassContext passContext,
13801380
case branchesChanged:
13811381
inv->notifyChanges(SILAnalysis::InvalidationKind::BranchesAndInstructions);
13821382
break;
1383+
case functionDataChanged:
1384+
inv->notifyChanges(SILAnalysis::InvalidationKind::FunctionData);
1385+
break;
13831386
}
13841387
}
13851388

0 commit comments

Comments
 (0)