Skip to content

Sil verify all verify functions when added to worklist #5221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions lib/SILOptimizer/PassManager/PassManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ bool SILPassManager::continueTransforming() {
}

bool SILPassManager::analysesUnlocked() {
for (auto A : Analysis)
for (auto *A : Analysis)
if (A->isLocked())
return false;

Expand Down Expand Up @@ -481,7 +481,7 @@ void SILPassManager::runOneIteration() {
}
NumOptzIterations++;
NumOptimizationIterations++;
SmallVector<SILFunctionTransform*, 16> PendingFuncTransforms;
SmallVector<SILFunctionTransform *, 16> PendingFuncTransforms;

// Run the transforms by alternating between function transforms and
// module transforms. We'll queue up all the function transforms
Expand Down Expand Up @@ -542,11 +542,11 @@ void SILPassManager::run() {
/// D'tor.
SILPassManager::~SILPassManager() {
// Free all transformations.
for (auto T : Transformations)
for (auto *T : Transformations)
delete T;

// delete the analysis.
for (auto A : Analysis) {
for (auto *A : Analysis) {
Mod->removeDeleteNotificationHandler(A);
assert(!A->isLocked() &&
"Deleting a locked analysis. Did we forget to unlock ?");
Expand All @@ -559,10 +559,29 @@ void SILPassManager::addFunctionToWorklist(SILFunction *F,
assert(F && F->isDefinition() && F->shouldOptimize() &&
"Expected optimizable function definition!");

const int MaxDeriveLevels = 10;
constexpr int MaxDeriveLevels = 10;

int NewLevel = 1;
if (DerivedFrom) {
// When SILVerifyAll is enabled, individual functions are verified after
// function passes are run upon them. This means that any functions created
// by a function pass will not be verified after the pass runs. Thus
// specialization errors that cause the verifier to trip will be
// misattributed to the first pass that makes a change to the specialized
// function. This is very misleading and increases triage time.
//
// As a result, when SILVerifyAll is enabled, we always verify newly
// specialized functions as they are added to the worklist.
//
// TODO: Currently, all specialized functions are added to the function
// worklist in this manner. This is all well and good, but we should really
// add support for verifying that all specialized functions are added via
// this function to the pass manager to ensure that we perform this
// verification.
if (getOptions().VerifyAll) {
F->verify();
}

NewLevel = DerivationLevels[DerivedFrom] + 1;
// Limit the number of derivations, i.e. don't allow that a pass specializes
// a specialized function which is itself a specialized function, and so on.
Expand Down Expand Up @@ -590,7 +609,7 @@ void SILPassManager::restartWithCurrentFunction(SILTransform *T) {
/// \brief Reset the state of the pass manager and remove all transformation
/// owned by the pass manager. Analysis passes will be kept.
void SILPassManager::resetAndRemoveTransformations() {
for (auto T : Transformations)
for (auto *T : Transformations)
delete T;

Transformations.clear();
Expand Down