Skip to content

Commit

Permalink
Invalidate the call graph at the end of several passes.
Browse files Browse the repository at this point in the history
Without further changes to maintain the call graph, these passes all
break the call graph once it tracks potential calls to
deinits (e.g. from strong_release, etc.).

I measure approximately 1.3% increase in stdlib build time with this
change.

The compile-time cost of this change will be reduced with forthcoming
changes to allow invalidating only the portion of the call graph for a
single function.
  • Loading branch information
rudkx committed Nov 10, 2015
1 parent b789919 commit 7fdf92a
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lib/SILPasses/ARC/ARCSequenceOpts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class ARCSequenceOpts : public SILFunctionTransform {

if (processFunction(*getFunction(), false, AA, POTA, LRFI, LI, RCFI)) {
processFunction(*getFunction(), true, AA, POTA, LRFI, LI, RCFI);
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
invalidateAnalysis(SILAnalysis::PreserveKind::Branches);
}
}

Expand Down
2 changes: 0 additions & 2 deletions lib/SILPasses/COWArrayOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2352,9 +2352,7 @@ class SwiftArrayOptPass : public SILFunctionTransform {
// We preserve the dominator tree and call graph. Let's
// invalidate everything else.
DA->lockInvalidation();
CGA->lockInvalidation();
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
CGA->unlockInvalidation();
DA->unlockInvalidation();
}
}
Expand Down
2 changes: 0 additions & 2 deletions lib/SILPasses/ClosureSpecializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,9 +877,7 @@ class SILClosureSpecializerTransform : public SILModuleTransform {
// We maintain the call graph, but delete calls, and introduce new
// calls and branches in the cloned functions.
if (Changed) {
CGA->lockInvalidation();
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
CGA->unlockInvalidation();
}

// If for testing purposes we were asked to not eliminate dead closures,
Expand Down
9 changes: 4 additions & 5 deletions lib/SILPasses/CopyForwarding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ class CopyForwardingPass : public SILFunctionTransform
// Perform NRVO
for (auto Copy : NRVOCopies) {
performNRVO(Copy);
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
invalidateAnalysis(SILAnalysis::PreserveKind::Branches);
}

// Perform Copy Forwarding.
Expand All @@ -1088,11 +1088,10 @@ class CopyForwardingPass : public SILFunctionTransform
} while (Forwarding.hasForwardedToCopy());
}
if (Forwarding.hasChangedCFG())
// 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);
// We've split critical edges so we can't preserve CFG.
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
else
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
invalidateAnalysis(SILAnalysis::PreserveKind::Branches);
}

StringRef getName() override { return "Copy Forwarding"; }
Expand Down
2 changes: 1 addition & 1 deletion lib/SILPasses/DeadObjectElimination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ class DeadObjectElimination : public SILFunctionTransform {
CG = CGA->getCallGraphOrNull();

if (processFunction(*getFunction()))
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
invalidateAnalysis(SILAnalysis::PreserveKind::Branches);
}

StringRef getName() override { return "Dead Object Elimination"; }
Expand Down
4 changes: 0 additions & 4 deletions lib/SILPasses/GlobalOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,11 +914,7 @@ class SILGlobalOptPass : public SILModuleTransform
auto *CGA = PM->getAnalysis<CallGraphAnalysis>();
if (SILGlobalOpt(getModule(), DA, CGA->getCallGraphOrNull()).run()) {
// Preserve the CallGraph analysis.
if (CGA)
CGA->lockInvalidation();
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);
if (CGA)
CGA->unlockInvalidation();
}
}

Expand Down
9 changes: 1 addition & 8 deletions lib/SILPasses/SILCombiner/SILCombine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,8 @@ class SILCombine : public SILFunctionTransform {
bool Changed = Combiner.runOnFunction(*getFunction());

if (Changed) {
// Ignore invalidation messages for all analyses that we keep up to date
// manually.
CGA->lockInvalidation();

// Invalidate everything else.
// Invalidate everything.
invalidateAnalysis(SILAnalysis::PreserveKind::Nothing);

// Unlock all of the analyses that we locked.
CGA->unlockInvalidation();
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/SILPasses/SILLowerAggregateInstrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class SILLowerAggregate : public SILFunctionTransform {
F->getName() << " *****\n");
bool Changed = processFunction(*F);
if (Changed)
invalidateAnalysis(SILAnalysis::PreserveKind::ProgramFlow);
invalidateAnalysis(SILAnalysis::PreserveKind::Branches);
}

StringRef getName() override { return "Lower Aggregate Instructions"; }
Expand Down

0 comments on commit 7fdf92a

Please sign in to comment.