Skip to content

Commit 484a4da

Browse files
authored
Merge pull request swiftlang#79388 from eeckstein/fix-analysis-invalidation
PassManager: invalidate analysis if a pass forgot to do so.
2 parents 2989770 + 9b143d8 commit 484a4da

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

include/swift/SIL/SILModule.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,10 @@ class SILModule {
10561056
/// See scheduledForDeletion for details.
10571057
void flushDeletedInsts();
10581058

1059+
bool hasInstructionsScheduledForDeletion() const {
1060+
return !scheduledForDeletion.empty();
1061+
}
1062+
10591063
/// Looks up the llvm intrinsic ID and type for the builtin function.
10601064
///
10611065
/// \returns Returns llvm::Intrinsic::not_intrinsic if the function is not an

lib/SILOptimizer/PassManager/PassManager.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,11 @@ void SILPassManager::runPassOnFunction(unsigned TransIdx, SILFunction *F) {
743743

744744
// Continue time measurement (including flushing deleted instructions).
745745
startTime = std::chrono::system_clock::now();
746+
} else {
747+
if (Mod->hasInstructionsScheduledForDeletion()) {
748+
// Last chance for invalidating analysis if the pass forgot to call invalidateAnalysis.
749+
invalidateAnalysis(F, SILAnalysis::InvalidationKind::FunctionBody);
750+
}
746751
}
747752
Mod->flushDeletedInsts();
748753
}
@@ -915,6 +920,12 @@ void SILPassManager::runModulePass(unsigned TransIdx) {
915920
assert(analysesUnlocked() && "Expected all analyses to be unlocked!");
916921
SMT->run();
917922
assert(analysesUnlocked() && "Expected all analyses to be unlocked!");
923+
924+
if (!CurrentPassHasInvalidated && Mod->hasInstructionsScheduledForDeletion()) {
925+
// Last chance for invalidating analysis if the pass forgot to call invalidateAnalysis.
926+
invalidateAllAnalysis();
927+
}
928+
918929
Mod->flushDeletedInsts();
919930
swiftPassInvocation.finishedModulePassRun();
920931

0 commit comments

Comments
 (0)