Skip to content

Commit ecbcacd

Browse files
committed
SIL Analysis: Rename InvalidationKind::FunctionData to InvalidationKind::Effects
This invalidation kind is used when a compute-effects pass changes function effects. Also, let optimization passes which don't change effects only invalidate the `FunctionBody` and not `Everything`.
1 parent 1edcd89 commit ecbcacd

File tree

20 files changed

+32
-33
lines changed

20 files changed

+32
-33
lines changed

SwiftCompilerSources/Sources/Optimizer/PassManager/PassContext.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ struct PassContext {
119119
}
120120

121121
func modifyEffects(in function: Function, _ body: (inout FunctionEffects) -> ()) {
122-
notifyFunctionDataChanged()
122+
notifyEffectsChanged()
123123
function._modifyEffects(body)
124124
}
125125

@@ -139,8 +139,8 @@ struct PassContext {
139139
PassContext_notifyChanges(_bridged, branchesChanged)
140140
}
141141

142-
fileprivate func notifyFunctionDataChanged() {
143-
PassContext_notifyChanges(_bridged, functionDataChanged)
142+
fileprivate func notifyEffectsChanged() {
143+
PassContext_notifyChanges(_bridged, effectsChanged)
144144
}
145145
}
146146

@@ -243,7 +243,7 @@ extension RefCountingInst {
243243

244244
extension Function {
245245
func set(needStackProtection: Bool, _ context: PassContext) {
246-
context.notifyFunctionDataChanged()
246+
context.notifyEffectsChanged()
247247
SILFunction_setNeedStackProtection(bridged, needStackProtection ? 1 : 0)
248248
}
249249
}

include/swift/SIL/SILBridging.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum ChangeNotificationKind {
3434
instructionsChanged,
3535
callsChanged,
3636
branchesChanged,
37-
functionDataChanged
37+
effectsChanged
3838
};
3939

4040
typedef struct {

include/swift/SILOptimizer/Analysis/Analysis.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,10 @@ class SILAnalysis {
6464
/// has been modified.
6565
Branches = 0x4,
6666

67-
/// Any function data other than its body.
67+
/// The function effects.
6868
///
69-
/// It does not trigger any analysis invalidation, but tells the pass
70-
/// manager that some changes were made.
71-
FunctionData = 0x8,
69+
/// The computed effects of the function are invalidated.
70+
Effects = 0x8,
7271

7372
/// Convenience states:
7473
FunctionBody = Calls | Branches | Instructions,
@@ -77,7 +76,7 @@ class SILAnalysis {
7776

7877
BranchesAndInstructions = Branches | Instructions,
7978

80-
Everything = Calls | Branches | Instructions | FunctionData,
79+
Everything = FunctionBody | Effects,
8180
};
8281

8382
private:

include/swift/SILOptimizer/Analysis/DifferentiableActivityAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class DifferentiableActivityAnalysis
8383
}
8484

8585
virtual bool shouldInvalidate(SILAnalysis::InvalidationKind k) override {
86-
return k & InvalidationKind::Everything;
86+
return k & InvalidationKind::FunctionBody;
8787
}
8888

8989
virtual std::unique_ptr<DifferentiableActivityCollection>

lib/SILOptimizer/FunctionSignatureTransforms/ExistentialSpecializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ void ExistentialSpecializer::specializeExistentialArgsInAppliesWithinFunction(
345345

346346
/// Invalidate analysis results of Callee.
347347
PM->invalidateAnalysis(Callee,
348-
SILAnalysis::InvalidationKind::Everything);
348+
SILAnalysis::InvalidationKind::FunctionBody);
349349
}
350350
}
351351
}

lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ class FunctionSignatureOpts : public SILFunctionTransform {
881881
// The old function must be a thunk now.
882882
assert(F->isThunk() && "Old function should have been turned into a thunk");
883883

884-
invalidateAnalysis(SILAnalysis::InvalidationKind::Everything);
884+
invalidateAnalysis(SILAnalysis::InvalidationKind::FunctionBody);
885885

886886
// Make sure the PM knows about this function. This will also help us
887887
// with self-recursion.

lib/SILOptimizer/IPO/CapturePropagation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ void CapturePropagation::run() {
616616
}
617617
}
618618
if (HasChanged) {
619-
invalidateAnalysis(SILAnalysis::InvalidationKind::Everything);
619+
invalidateAnalysis(SILAnalysis::InvalidationKind::FunctionBody);
620620
}
621621
}
622622

lib/SILOptimizer/IPO/ClosureSpecializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ void SILClosureSpecializerTransform::run() {
10031003

10041004
// Invalidate everything since we delete calls as well as add new
10051005
// calls and branches.
1006-
invalidateAnalysis(SILAnalysis::InvalidationKind::Everything);
1006+
invalidateAnalysis(SILAnalysis::InvalidationKind::FunctionBody);
10071007
}
10081008

10091009
static void markReabstractionPartialApplyAsUsed(

lib/SILOptimizer/IPO/UsePrespecialized.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class UsePrespecialized: public SILModuleTransform {
4747
auto &M = *getModule();
4848
for (auto &F : M) {
4949
if (replaceByPrespecialized(F)) {
50-
invalidateAnalysis(&F, SILAnalysis::InvalidationKind::Everything);
50+
invalidateAnalysis(&F, SILAnalysis::InvalidationKind::FunctionBody);
5151
}
5252
}
5353
}

lib/SILOptimizer/Mandatory/CapturePromotion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,7 @@ void CapturePromotionPass::processFunction(
16491649
processPartialApplyInst(funcBuilder, pai, indicesPair.second, worklist);
16501650
(void)clonedFn;
16511651
}
1652-
invalidateAnalysis(func, SILAnalysis::InvalidationKind::Everything);
1652+
invalidateAnalysis(func, SILAnalysis::InvalidationKind::FunctionBody);
16531653
}
16541654

16551655
SILTransform *swift::createCapturePromotion() {

0 commit comments

Comments
 (0)