SIL: add an API to replace all entries of a VTable

* add `ModulePassContext.replaceVTableEntries()`
* add `ModulePassContext.notifyFunctionTablesChanged()`
This commit is contained in:
Erik Eckstein
2024-10-14 11:11:36 +02:00
parent a9d59034b3
commit e0533e6125
8 changed files with 61 additions and 4 deletions

View File

@@ -1516,6 +1516,7 @@ void SwiftPassInvocation::finishedModulePassRun() {
endPass();
assert(!function && transform && "not running a pass");
assert(changeNotifications == SILAnalysis::InvalidationKind::Nothing
&& !functionTablesChanged
&& "unhandled change notifications at end of module pass");
transform = nullptr;
}
@@ -1551,6 +1552,7 @@ void SwiftPassInvocation::endPass() {
void SwiftPassInvocation::beginTransformFunction(SILFunction *function) {
assert(!this->function && transform && "not running a pass");
assert(changeNotifications == SILAnalysis::InvalidationKind::Nothing
&& !functionTablesChanged
&& "change notifications not cleared");
this->function = function;
}
@@ -1561,6 +1563,10 @@ void SwiftPassInvocation::endTransformFunction() {
passManager->invalidateAnalysis(function, changeNotifications);
changeNotifications = SILAnalysis::InvalidationKind::Nothing;
}
if (functionTablesChanged) {
passManager->invalidateFunctionTables();
functionTablesChanged = false;
}
function = nullptr;
assert(numBlockSetsAllocated == 0 && "Not all BasicBlockSets deallocated");
assert(numNodeSetsAllocated == 0 && "Not all NodeSets deallocated");
@@ -1580,6 +1586,7 @@ void SwiftPassInvocation::endVerifyFunction() {
assert(function);
if (!transform) {
assert(changeNotifications == SILAnalysis::InvalidationKind::Nothing &&
!functionTablesChanged &&
"verifyication must not change the SIL of a function");
assert(numBlockSetsAllocated == 0 && "Not all BasicBlockSets deallocated");
assert(numNodeSetsAllocated == 0 && "Not all NodeSets deallocated");
@@ -1634,6 +1641,9 @@ void BridgedChangeNotificationHandler::notifyChanges(Kind changeKind) const {
case Kind::effectsChanged:
invocation->notifyChanges(SILAnalysis::InvalidationKind::Effects);
break;
case Kind::functionTablesChanged:
invocation->notifyFunctionTablesChanged();
break;
}
}