Skip to content

Commit 7c82bd5

Browse files
authored
Merge pull request #5221 from gottesmm/sil_verify_all_verify_functions_when_added_to_worklist
Sil verify all verify functions when added to worklist
2 parents 2656c1b + 1ba8182 commit 7c82bd5

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

lib/SILOptimizer/PassManager/PassManager.cpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ bool SILPassManager::continueTransforming() {
247247
}
248248

249249
bool SILPassManager::analysesUnlocked() {
250-
for (auto A : Analysis)
250+
for (auto *A : Analysis)
251251
if (A->isLocked())
252252
return false;
253253

@@ -481,7 +481,7 @@ void SILPassManager::runOneIteration() {
481481
}
482482
NumOptzIterations++;
483483
NumOptimizationIterations++;
484-
SmallVector<SILFunctionTransform*, 16> PendingFuncTransforms;
484+
SmallVector<SILFunctionTransform *, 16> PendingFuncTransforms;
485485

486486
// Run the transforms by alternating between function transforms and
487487
// module transforms. We'll queue up all the function transforms
@@ -542,11 +542,11 @@ void SILPassManager::run() {
542542
/// D'tor.
543543
SILPassManager::~SILPassManager() {
544544
// Free all transformations.
545-
for (auto T : Transformations)
545+
for (auto *T : Transformations)
546546
delete T;
547547

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

562-
const int MaxDeriveLevels = 10;
562+
constexpr int MaxDeriveLevels = 10;
563563

564564
int NewLevel = 1;
565565
if (DerivedFrom) {
566+
// When SILVerifyAll is enabled, individual functions are verified after
567+
// function passes are run upon them. This means that any functions created
568+
// by a function pass will not be verified after the pass runs. Thus
569+
// specialization errors that cause the verifier to trip will be
570+
// misattributed to the first pass that makes a change to the specialized
571+
// function. This is very misleading and increases triage time.
572+
//
573+
// As a result, when SILVerifyAll is enabled, we always verify newly
574+
// specialized functions as they are added to the worklist.
575+
//
576+
// TODO: Currently, all specialized functions are added to the function
577+
// worklist in this manner. This is all well and good, but we should really
578+
// add support for verifying that all specialized functions are added via
579+
// this function to the pass manager to ensure that we perform this
580+
// verification.
581+
if (getOptions().VerifyAll) {
582+
F->verify();
583+
}
584+
566585
NewLevel = DerivationLevels[DerivedFrom] + 1;
567586
// Limit the number of derivations, i.e. don't allow that a pass specializes
568587
// a specialized function which is itself a specialized function, and so on.
@@ -590,7 +609,7 @@ void SILPassManager::restartWithCurrentFunction(SILTransform *T) {
590609
/// \brief Reset the state of the pass manager and remove all transformation
591610
/// owned by the pass manager. Analysis passes will be kept.
592611
void SILPassManager::resetAndRemoveTransformations() {
593-
for (auto T : Transformations)
612+
for (auto *T : Transformations)
594613
delete T;
595614

596615
Transformations.clear();

0 commit comments

Comments
 (0)