mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[passes] Replace the old invalidation lattice with a new invalidation scheme.
The old invalidation lattice was incorrect because changes to control flow could cause changes to the call graph, so we've decided to change the way passes invalidate analysis. In the new scheme, the lattice is replaced with a list of traits that passes preserve or invalidate. The current traits are Calls and Branches. Now, passes report which traits they preserve, which is the opposite of the previous implementation where passes needed to report what they invalidate. Node: I tried to limit the changes in this commit to mechanical changes to ease the review. I will cleanup some of the code in a following commit. Swift SVN r26449
This commit is contained in:
@@ -312,8 +312,10 @@ public:
|
||||
// global hoisting will be done.
|
||||
DoGlobalHoisting = !F->isTransparent();
|
||||
if (HasChangedCFG) {
|
||||
DomAnalysis->invalidate(F, SILAnalysis::InvalidationKind::CFG);
|
||||
PostOrder->invalidate(F, SILAnalysis::InvalidationKind::CFG);
|
||||
// We are only invalidating the analysis that we use internally.
|
||||
// We'll invalidate the analysis that are used by other passes at the end.
|
||||
DomAnalysis->invalidate(F, SILAnalysis::PreserveKind::Nothing);
|
||||
PostOrder->invalidate(F, SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
CurrentDef = SILValue();
|
||||
IsLoadedFrom = false;
|
||||
@@ -984,7 +986,7 @@ class CopyForwardingPass : public SILFunctionTransform
|
||||
// Perform NRVO
|
||||
for (auto Copy : NRVOCopies) {
|
||||
performNRVO(Copy);
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
// Perform Copy Forwarding.
|
||||
@@ -1008,9 +1010,11 @@ class CopyForwardingPass : public SILFunctionTransform
|
||||
} while (Forwarding.hasForwardedToCopy());
|
||||
}
|
||||
if (Forwarding.hasChangedCFG())
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CFG);
|
||||
// We've split critical edges so we can't preserve CFG, but we did not
|
||||
// change calls so we can preserve them.
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Calls);
|
||||
else
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "Copy Forwarding"; }
|
||||
|
||||
Reference in New Issue
Block a user