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:
@@ -127,9 +127,11 @@ public:
|
||||
return getMemoryBehavior(Inst, V) == MemoryBehavior::MayHaveSideEffects;
|
||||
}
|
||||
|
||||
virtual void invalidate(InvalidationKind K) { AliasCache.clear(); }
|
||||
virtual void invalidate(SILAnalysis::PreserveKind K) { AliasCache.clear(); }
|
||||
|
||||
virtual void invalidate(SILFunction *, InvalidationKind K) { invalidate(K); }
|
||||
virtual void invalidate(SILFunction *, SILAnalysis::PreserveKind K) {
|
||||
invalidate(K);
|
||||
}
|
||||
};
|
||||
|
||||
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
|
||||
|
||||
@@ -27,15 +27,21 @@ namespace swift {
|
||||
/// The base class for all SIL-level analysis.
|
||||
class SILAnalysis {
|
||||
public:
|
||||
/// The invalidation Lattice.
|
||||
/// This is a hierarchy of invalidation messages that are sent to analysis
|
||||
/// objects. Every invalidation kind invalidates the levels before it. For
|
||||
/// example, CFG invalidates Instructions and CFG.
|
||||
enum class InvalidationKind {
|
||||
Instructions, // Invalidate instruction-related analysis.
|
||||
CFG, // The control flow changes.
|
||||
CallGraph, // The call graph changed.
|
||||
All, // Invalidate everything.
|
||||
/// This is a list of values that allow passes to communicate to analysis
|
||||
/// which traits of the code were preserved. Based on this information
|
||||
/// the analysis can decide if it needs to be invalidated. This information
|
||||
/// may refer to a specific function or to a list of functions depending
|
||||
/// on the context in which it is used.
|
||||
enum PreserveKind : unsigned {
|
||||
Nothing = 0x0, // The pass does not preserve any analysis trait.
|
||||
Calls = 0x1, // The pass did not modify any calls.
|
||||
Branches = 0x2, // The pass did not modify any branches.
|
||||
|
||||
// This is a list of combined traits that is defined to make the use of
|
||||
/// the invalidation API more convenient.
|
||||
ProgramFlow = Calls | Branches, // The pass changed some instructions but
|
||||
// did not change the overall flow
|
||||
// of the code.
|
||||
};
|
||||
|
||||
/// A list of the known analysis.
|
||||
@@ -82,10 +88,10 @@ namespace swift {
|
||||
bool isLocked() { return invalidationLock; }
|
||||
|
||||
/// Invalidate all information in this analysis.
|
||||
virtual void invalidate(InvalidationKind K) {}
|
||||
virtual void invalidate(PreserveKind K) {}
|
||||
|
||||
/// Invalidate all of the information for a specific function.
|
||||
virtual void invalidate(SILFunction *F, InvalidationKind K) {}
|
||||
virtual void invalidate(SILFunction *F, PreserveKind K) {}
|
||||
|
||||
/// Verify the state of this analysis.
|
||||
virtual void verify() const {}
|
||||
@@ -109,12 +115,12 @@ namespace swift {
|
||||
return S->getKind() == AnalysisKind::CompleteFuncs;
|
||||
}
|
||||
|
||||
virtual void invalidate(InvalidationKind K) {
|
||||
virtual void invalidate(PreserveKind K) {
|
||||
IsModulePending = true;
|
||||
HasChanged = true;
|
||||
}
|
||||
|
||||
virtual void invalidate(SILFunction* F, InvalidationKind) {
|
||||
virtual void invalidate(SILFunction* F, PreserveKind) {
|
||||
PendingFuncs.insert(F);
|
||||
HasChanged = true;
|
||||
}
|
||||
|
||||
@@ -356,15 +356,15 @@ public:
|
||||
return *CG;
|
||||
}
|
||||
|
||||
virtual void invalidate(InvalidationKind K) {
|
||||
if (K >= InvalidationKind::CallGraph) {
|
||||
virtual void invalidate(SILAnalysis::PreserveKind K) {
|
||||
if (!(K & PreserveKind::Calls)) {
|
||||
BottomUpFunctionOrder.clear();
|
||||
delete CG;
|
||||
CG = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void invalidate(SILFunction*, InvalidationKind K) { invalidate(K); }
|
||||
virtual void invalidate(SILFunction*, SILAnalysis::PreserveKind K) { invalidate(K); }
|
||||
|
||||
virtual void verify() const;
|
||||
};
|
||||
|
||||
@@ -42,12 +42,8 @@ public:
|
||||
return S->getKind() == AnalysisKind::ClassHierarchyAnalysis;
|
||||
}
|
||||
|
||||
virtual void invalidate(InvalidationKind K) {
|
||||
if (K >= InvalidationKind::All) {
|
||||
DirectSubclassesCache.clear();
|
||||
IndirectSubclassesCache.clear();
|
||||
init();
|
||||
}
|
||||
virtual void invalidate(SILAnalysis::PreserveKind K) {
|
||||
// Nothing can invalidate the ClassHierarchyAnalysis!
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +76,7 @@ public:
|
||||
IndirectSubclassesCache[C].size() > 0;
|
||||
}
|
||||
|
||||
virtual void invalidate(SILFunction *F, InvalidationKind K) {
|
||||
virtual void invalidate(SILFunction *F, SILAnalysis::PreserveKind K) {
|
||||
invalidate(K);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,11 +60,9 @@ class SILInstruction;
|
||||
return S->getKind() == AnalysisKind::Dominance;
|
||||
}
|
||||
|
||||
virtual void invalidate(InvalidationKind K) {
|
||||
virtual void invalidate(SILAnalysis::PreserveKind K) {
|
||||
assert(!isLocked() && "invalidating a locked analysis?!");
|
||||
// FIXME: Invalidating the call graph should not invalidate the domtrees
|
||||
// of all functions.
|
||||
if (K >= InvalidationKind::CFG) {
|
||||
if (!(K & PreserveKind::Branches)) {
|
||||
// Delete Dominance Info.
|
||||
for (auto D : DomInfo)
|
||||
delete D.second;
|
||||
@@ -79,8 +77,8 @@ class SILInstruction;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void invalidate(SILFunction* F, InvalidationKind K) {
|
||||
if (K >= InvalidationKind::CFG) {
|
||||
virtual void invalidate(SILFunction* F, SILAnalysis::PreserveKind K) {
|
||||
if (!(K & PreserveKind::Branches)) {
|
||||
auto &it= DomInfo.FindAndConstruct(F);
|
||||
if (it.second) {
|
||||
delete it.second;
|
||||
|
||||
@@ -94,23 +94,19 @@ public:
|
||||
return *IVInfos[F];
|
||||
}
|
||||
|
||||
virtual void invalidate(InvalidationKind K) {
|
||||
if (K >= InvalidationKind::Instructions) {
|
||||
virtual void invalidate(SILAnalysis::PreserveKind K) {
|
||||
for (auto IVI : IVInfos)
|
||||
delete IVI.second;
|
||||
|
||||
IVInfos.clear();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void invalidate(SILFunction *F, InvalidationKind K) {
|
||||
if (K >= InvalidationKind::Instructions) {
|
||||
virtual void invalidate(SILFunction *F, SILAnalysis::PreserveKind K) {
|
||||
if (IVInfos.count(F)) {
|
||||
delete IVInfos[F];
|
||||
IVInfos.erase(F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
llvm::DenseMap<SILFunction *, IVInfo *> IVInfos;
|
||||
|
||||
@@ -46,8 +46,8 @@ public:
|
||||
return S->getKind() == AnalysisKind::LoopInfo;
|
||||
}
|
||||
|
||||
virtual void invalidate(InvalidationKind K) {
|
||||
if (K >= InvalidationKind::CFG) {
|
||||
virtual void invalidate(SILAnalysis::PreserveKind K) {
|
||||
if (!(K & PreserveKind::Branches)) {
|
||||
for (auto LI : LoopInfos)
|
||||
delete LI.second;
|
||||
|
||||
@@ -56,8 +56,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void invalidate(SILFunction* F, InvalidationKind K) {
|
||||
if (K >= InvalidationKind::CFG) {
|
||||
virtual void invalidate(SILFunction* F, SILAnalysis::PreserveKind K) {
|
||||
if (!(K & PreserveKind::Branches)) {
|
||||
if (LoopInfos.count(F)) {
|
||||
delete LoopInfos[F];
|
||||
LoopInfos.erase(F);
|
||||
|
||||
@@ -98,16 +98,14 @@ public:
|
||||
return S->getKind() == AnalysisKind::PostOrder;
|
||||
}
|
||||
|
||||
virtual void invalidate(InvalidationKind K) {
|
||||
// FIXME: Invalidating the call graph should not invalidate the domtrees
|
||||
// of all functions.
|
||||
if (K >= InvalidationKind::CFG) {
|
||||
virtual void invalidate(SILAnalysis::PreserveKind K) {
|
||||
if (!(K & PreserveKind::Branches)) {
|
||||
FunctionToPOTMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void invalidate(SILFunction* F, InvalidationKind K) {
|
||||
if (K >= InvalidationKind::CFG) {
|
||||
virtual void invalidate(SILFunction* F, SILAnalysis::PreserveKind K) {
|
||||
if (!(K & PreserveKind::Branches)) {
|
||||
// Invalidate just this one function. We will lazily recompute it.
|
||||
FunctionToPOTMap[F].IsInvalidated = true;
|
||||
}
|
||||
|
||||
@@ -52,14 +52,12 @@ public:
|
||||
return S->getKind() == AnalysisKind::RCIdentity;
|
||||
}
|
||||
|
||||
virtual void invalidate(InvalidationKind K) {
|
||||
if (K >= InvalidationKind::Instructions) {
|
||||
virtual void invalidate(SILAnalysis::PreserveKind K) {
|
||||
Cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add function specific cache to save compile time.
|
||||
virtual void invalidate(SILFunction* F, InvalidationKind K) {
|
||||
virtual void invalidate(SILFunction* F, SILAnalysis::PreserveKind K) {
|
||||
invalidate(K);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ class SILPassManager {
|
||||
void scheduleAnotherIteration() { anotherIteration = true; }
|
||||
|
||||
/// \brief Broadcast the invalidation of the module to all analysis.
|
||||
void invalidateAnalysis(SILAnalysis::InvalidationKind K) {
|
||||
void invalidateAnalysis(SILAnalysis::PreserveKind K) {
|
||||
for (auto AP : Analysis)
|
||||
if (!AP->isLocked())
|
||||
AP->invalidate(K);
|
||||
@@ -101,7 +101,7 @@ class SILPassManager {
|
||||
|
||||
/// \brief Broadcast the invalidation of the function to all analysis.
|
||||
void invalidateAnalysis(SILFunction *F,
|
||||
SILAnalysis::InvalidationKind K) {
|
||||
SILAnalysis::PreserveKind K) {
|
||||
// Invalidate the analysis (unless they are locked)
|
||||
for (auto AP : Analysis)
|
||||
if (!AP->isLocked())
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace swift {
|
||||
protected:
|
||||
SILFunction *getFunction() { return F; }
|
||||
|
||||
void invalidateAnalysis(SILAnalysis::InvalidationKind K) {
|
||||
void invalidateAnalysis(SILAnalysis::PreserveKind K) {
|
||||
PM->invalidateAnalysis(F, K);
|
||||
}
|
||||
};
|
||||
@@ -108,12 +108,12 @@ namespace swift {
|
||||
|
||||
/// Invalidate all of functions in the module, using invalidation
|
||||
/// information \p K.
|
||||
void invalidateAnalysis(SILAnalysis::InvalidationKind K) {
|
||||
void invalidateAnalysis(SILAnalysis::PreserveKind K) {
|
||||
PM->invalidateAnalysis(K);
|
||||
}
|
||||
|
||||
/// Invalidate only the function \p F, using invalidation information \p K.
|
||||
void invalidateAnalysis(SILFunction *F, SILAnalysis::InvalidationKind K) {
|
||||
void invalidateAnalysis(SILFunction *F, SILAnalysis::PreserveKind K) {
|
||||
PM->invalidateAnalysis(F, K);
|
||||
}
|
||||
|
||||
|
||||
@@ -790,7 +790,7 @@ class AllocBoxToStack : public SILFunctionTransform {
|
||||
if (!Promotable.empty()) {
|
||||
auto Count = rewritePromotedBoxes(Promotable, ElidedOperands, Returns);
|
||||
NumStackPromoted += Count;
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1135,7 +1135,7 @@ public:
|
||||
}
|
||||
|
||||
if (Changed)
|
||||
PM->invalidateAnalysis(F, SILAnalysis::InvalidationKind::Instructions);
|
||||
PM->invalidateAnalysis(F, SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -891,7 +891,7 @@ class COWArrayOptPass : public SILFunctionTransform
|
||||
HasChanged |= COWArrayOpt(RCIA, L, DA).run();
|
||||
|
||||
if (HasChanged)
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "SIL COW Array Optimization"; }
|
||||
@@ -1602,7 +1602,7 @@ void ArrayPropertiesSpecializer::specializeLoopNest() {
|
||||
|
||||
// We have potentially cloned a loop - invalidate loop info.
|
||||
LoopAnalysis->invalidate(Header->getParent(),
|
||||
SILAnalysis::InvalidationKind::CFG);
|
||||
SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
namespace {
|
||||
@@ -1658,10 +1658,10 @@ class SwiftArrayOptPass : public SILFunctionTransform {
|
||||
DEBUG(getFunction()->viewCFG());
|
||||
}
|
||||
|
||||
// We preserve the dominator tree.
|
||||
if (HasChanged) {
|
||||
// We preserve the dominator tree. Let's invalidate everything else.
|
||||
DA->lockInvalidation();
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CFG);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
DA->unlockInvalidation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,7 +608,7 @@ class SILCSE : public SILFunctionTransform {
|
||||
|
||||
CSE C;
|
||||
if (C.processFunction(*getFunction(), DA->getDomInfo(getFunction())))
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "CSE"; }
|
||||
|
||||
@@ -965,7 +965,7 @@ class CapturePromotionPass : public SILModuleTransform {
|
||||
processFunction(&F, Worklist);
|
||||
|
||||
if (!Worklist.empty())
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CallGraph);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
|
||||
while (!Worklist.empty())
|
||||
processFunction(Worklist.pop_back_val(), Worklist);
|
||||
|
||||
@@ -330,7 +330,7 @@ void CapturePropagation::run() {
|
||||
// this conservative in case someone implements interprocedural/dynamic call
|
||||
// graph analysis later.
|
||||
if (HasChanged)
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CallGraph);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
SILTransform *swift::createCapturePropagation() {
|
||||
|
||||
@@ -741,7 +741,7 @@ public:
|
||||
|
||||
// Invalidate the call graph.
|
||||
if (Changed)
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CallGraph);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
|
||||
// If for testing purposes we were asked to not eliminate dead closures,
|
||||
// return.
|
||||
|
||||
@@ -950,7 +950,7 @@ private:
|
||||
void run() override {
|
||||
if (CCPFunctionBody(*getFunction(), EnableDiagnostics,
|
||||
getOptions().AssertConfig))
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "Constant Propagation"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
|
||||
if (Changed)
|
||||
PM->invalidateAnalysis(getFunction(),
|
||||
SILAnalysis::InvalidationKind::Instructions);
|
||||
SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
/// Return True if the relationship \p Rel describes a known relation
|
||||
|
||||
@@ -105,7 +105,7 @@ class DCE : public SILFunctionTransform {
|
||||
|
||||
markLive(*F);
|
||||
if (removeDead(*F))
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CFG);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
bool precomputeControlInfo(SILFunction &F);
|
||||
|
||||
@@ -456,7 +456,7 @@ class SILDeadFuncElimination : public SILModuleTransform {
|
||||
bool changed = deadFunctionElimination.eliminateFunctions();
|
||||
|
||||
if (changed)
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CallGraph);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "Dead Function Elimination"; }
|
||||
@@ -475,7 +475,7 @@ class SILExternalFuncDefinitionsElimination : public SILModuleTransform {
|
||||
bool changed = externalFunctionDefinitionsElimination.eliminateFunctions();
|
||||
|
||||
if (changed)
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CallGraph);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
StringRef getName() override {
|
||||
|
||||
@@ -293,7 +293,7 @@ class DeadObjectElimination : public SILFunctionTransform {
|
||||
|
||||
void run() override {
|
||||
if (processFunction(*getFunction()))
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "Dead Object Elimination"; }
|
||||
|
||||
@@ -2003,13 +2003,13 @@ class DefiniteInitialization : public SILFunctionTransform {
|
||||
void run() override {
|
||||
// Walk through and promote all of the alloc_box's that we can.
|
||||
if (checkDefiniteInitialization(*getFunction()))
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::All);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
|
||||
DEBUG(getFunction()->verify());
|
||||
|
||||
// Lower raw-sil only instructions used by this pass, like "assign".
|
||||
if (lowerRawSILOperations(*getFunction()))
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::All);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "Definite Initialization"; }
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
// Invalidate the analysis of caller functions.
|
||||
for (auto *AI : DevirtualizedCalls) {
|
||||
invalidateAnalysis(AI->getFunction(),
|
||||
SILAnalysis::InvalidationKind::CallGraph);
|
||||
SILAnalysis::PreserveKind::Branches);
|
||||
}
|
||||
|
||||
if (Changed) {
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
if (Specialized) {
|
||||
// We've specialized some functions and created new ones, so invalidate
|
||||
// the world.
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CallGraph);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Branches);
|
||||
}
|
||||
|
||||
PM->scheduleAnotherIteration();
|
||||
@@ -494,7 +494,7 @@ namespace {
|
||||
Changed |= insertInlineCaches(AI, CHA);
|
||||
|
||||
if (Changed) {
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CallGraph);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -748,7 +748,7 @@ namespace {
|
||||
class NoReturnFolding : public SILModuleTransform {
|
||||
void run() override {
|
||||
performNoReturnFunctionProcessing(getModule());
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::All);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "NoReturnFolding"; }
|
||||
@@ -764,7 +764,7 @@ namespace {
|
||||
class DiagnoseUnreachable : public SILModuleTransform {
|
||||
void run() override {
|
||||
performSILDiagnoseUnreachable(getModule());
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::All);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "Diagnose Unreachable"; }
|
||||
|
||||
@@ -27,7 +27,7 @@ class ExternalDefsToDecls : public SILModuleTransform {
|
||||
if (isAvailableExternally(F.getLinkage()) && F.isDefinition())
|
||||
F.convertToDeclaration();
|
||||
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::All);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "External Defs To Decls"; }
|
||||
|
||||
@@ -838,7 +838,7 @@ public:
|
||||
|
||||
// If we changed anything, invalidate the call graph.
|
||||
if (Changed)
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CallGraph);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "Function Signature Optimization"; }
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
PM->scheduleAnotherIteration();
|
||||
|
||||
// Invalidate the call graph.
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CallGraph);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ class GlobalARCOpts : public SILFunctionTransform {
|
||||
auto *RCIA = getAnalysis<RCIdentityAnalysis>();
|
||||
if (processFunction(*getFunction(), false, AA, POTA, RCIA)) {
|
||||
processFunction(*getFunction(), true, AA, POTA, RCIA);
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -314,7 +314,7 @@ class SILGlobalOptPass : public SILModuleTransform
|
||||
void run() override {
|
||||
DominanceAnalysis *DA = PM->getAnalysis<DominanceAnalysis>();
|
||||
if (SILGlobalOpt(getModule(), DA).run())
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CallGraph);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "SIL Global Optimization"; }
|
||||
|
||||
@@ -460,9 +460,11 @@ public:
|
||||
}
|
||||
|
||||
if (Changed) {
|
||||
// TODO: Verify: We have updated the DominanceInfo and SILLoopInfo. It
|
||||
// should be safe not to invalidate the CFG.
|
||||
PM->invalidateAnalysis(F, SILAnalysis::InvalidationKind::Instructions);
|
||||
LA->lockInvalidation();
|
||||
DA->lockInvalidation();
|
||||
PM->invalidateAnalysis(F, SILAnalysis::PreserveKind::Nothing);
|
||||
LA->unlockInvalidation();
|
||||
DA->unlockInvalidation();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ class SILLinker : public SILModuleTransform {
|
||||
Changed |= M.linkFunction(&Fn, SILModule::LinkingMode::LinkAll);
|
||||
|
||||
if (Changed)
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::All);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "SIL Linker"; }
|
||||
|
||||
@@ -1417,7 +1417,7 @@ class GlobalLoadStoreOpts : public SILFunctionTransform {
|
||||
Changed = true;
|
||||
|
||||
if (Changed)
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "SIL Load Store Opts"; }
|
||||
|
||||
@@ -576,7 +576,7 @@ class LoopRotation : public SILFunctionTransform {
|
||||
// We preserve loop info and the dominator tree.
|
||||
DA->lockInvalidation();
|
||||
LA->lockInvalidation();
|
||||
PM->invalidateAnalysis(F, SILAnalysis::InvalidationKind::All);
|
||||
PM->invalidateAnalysis(F, SILAnalysis::PreserveKind::Nothing);
|
||||
DA->unlockInvalidation();
|
||||
LA->unlockInvalidation();
|
||||
}
|
||||
|
||||
@@ -515,7 +515,7 @@ class MandatoryInlining : public SILModuleTransform {
|
||||
M->eraseFunction(&F);
|
||||
}
|
||||
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::All);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "Mandatory Inlining"; }
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
}
|
||||
if (Changed)
|
||||
PM->invalidateAnalysis(getFunction(),
|
||||
SILAnalysis::InvalidationKind::Instructions);
|
||||
SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
/// \brief Try to merge the cond_fail instructions. Returns true if any could
|
||||
|
||||
@@ -834,8 +834,8 @@ bool SILPerformanceInliner::inlineCallsIntoFunction(SILFunction *Caller,
|
||||
// we expect it to have happened.
|
||||
assert(Success && "Expected inliner to inline this function!");
|
||||
AI->eraseFromParent();
|
||||
DA->invalidate(Caller, SILAnalysis::InvalidationKind::CFG);
|
||||
LA->invalidate(Caller, SILAnalysis::InvalidationKind::CFG);
|
||||
DA->invalidate(Caller, SILAnalysis::PreserveKind::Nothing);
|
||||
LA->invalidate(Caller, SILAnalysis::PreserveKind::Nothing);
|
||||
NumFunctionsInlined++;
|
||||
Changed = true;
|
||||
}
|
||||
@@ -910,7 +910,7 @@ public:
|
||||
|
||||
// Invalidate the call graph.
|
||||
if (Changed)
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CallGraph);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
StringRef getName() override { return PassName; }
|
||||
|
||||
@@ -1000,7 +1000,7 @@ class PredictableMemoryOptimizations : public SILFunctionTransform {
|
||||
/// The entry point to the transformation.
|
||||
void run() override {
|
||||
if (optimizeMemoryAllocations(*getFunction()))
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::All);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "Predictable Memory Opts"; }
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
|
||||
if (Changed)
|
||||
PM->invalidateAnalysis(getFunction(),
|
||||
SILAnalysis::InvalidationKind::Instructions);
|
||||
SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
/// Pin uses are safe if they either mark a dependence or if it is the unpin we
|
||||
|
||||
@@ -62,7 +62,7 @@ class SILCleanup : public swift::SILFunctionTransform {
|
||||
/// The entry point to the transformation.
|
||||
void run() override {
|
||||
cleanFunction(*getFunction());
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::All);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "SIL Cleanup"; }
|
||||
|
||||
@@ -1398,7 +1398,7 @@ public:
|
||||
" *****\n");
|
||||
|
||||
if (processFunction(F, AA, POTA, RCIA, HoistReleases))
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "SIL Code Motion"; }
|
||||
|
||||
@@ -327,7 +327,7 @@ class SILCombine : public SILFunctionTransform {
|
||||
SILCombiner Combiner(AA, getOptions().RemoveRuntimeAsserts);
|
||||
bool Changed = Combiner.runOnFunction(*getFunction());
|
||||
if (Changed)
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "SIL Combine"; }
|
||||
|
||||
@@ -260,7 +260,7 @@ class SILLowerAggregate : public SILFunctionTransform {
|
||||
F->getName() << " *****\n");
|
||||
bool Changed = processFunction(*F);
|
||||
if (Changed)
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "Lower Aggregate Instructions"; }
|
||||
|
||||
@@ -845,7 +845,7 @@ class SILMem2Reg : public SILFunctionTransform {
|
||||
bool Changed = MemoryToRegisters(*F, DA->getDomInfo(F)).run();
|
||||
|
||||
if (Changed)
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "SIL Mem2Reg"; }
|
||||
|
||||
@@ -311,7 +311,7 @@ class SILSROA : public SILFunctionTransform {
|
||||
" *****\n");
|
||||
|
||||
if (runSROAOnFunction(*F))
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "SROA"; }
|
||||
|
||||
@@ -2326,7 +2326,7 @@ bool SimplifyCFG::run() {
|
||||
RU.run();
|
||||
|
||||
// Force dominator recomputation below.
|
||||
PM->invalidateAnalysis(&Fn, SILAnalysis::InvalidationKind::CFG);
|
||||
PM->invalidateAnalysis(&Fn, SILAnalysis::PreserveKind::Nothing);
|
||||
Changed = true;
|
||||
}
|
||||
|
||||
@@ -3074,7 +3074,7 @@ class SimplifyCFGPass : public SILFunctionTransform {
|
||||
/// The entry point to the transformation.
|
||||
void run() override {
|
||||
if (SimplifyCFG(*getFunction(), PM).run())
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CFG);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "Simplify CFG"; }
|
||||
@@ -3108,7 +3108,7 @@ public:
|
||||
splitAllCriticalEdges(Fn, OnlyNonCondBrEdges, nullptr, nullptr);
|
||||
|
||||
if (Changed)
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CFG);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Calls);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "Split Critical Edges"; }
|
||||
@@ -3122,7 +3122,7 @@ public:
|
||||
/// The entry point to the transformation.
|
||||
void run() override {
|
||||
if (SimplifyCFG(*getFunction(), PM).simplifyBlockArgs())
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::CFG);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "Simplify Block Args"; }
|
||||
|
||||
@@ -40,7 +40,7 @@ class StripDebugInfo : public swift::SILFunctionTransform {
|
||||
/// The entry point to the transformation.
|
||||
void run() override {
|
||||
stripFunction(getFunction());
|
||||
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
|
||||
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
|
||||
}
|
||||
|
||||
StringRef getName() override { return "Strip Debug Info"; }
|
||||
|
||||
Reference in New Issue
Block a user