mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[sil-deserialization] Implement cache invalidation for all serialized SIL entities and use it to properly invalidate global variables/witness tables when we delete them.
Otherwise, one runs into memory corruption. I ran into this while enabling ossa on the stdlib for non-Darwin platforms. Hopefully we do not regress on this again when someone adds more optzns that eliminate these since I added a big NOTE to warn people to do it and implemented support even for the entities we do not support deleting at the SIL level... yet.
This commit is contained in:
@@ -144,14 +144,58 @@ SerializedSILLoader::lookupDifferentiabilityWitness(
|
||||
return dw;
|
||||
}
|
||||
|
||||
void SerializedSILLoader::invalidateCaches() {
|
||||
for (auto &Des : LoadedSILSections)
|
||||
Des->invalidateFunctionCache();
|
||||
void SerializedSILLoader::invalidateAllCaches() {
|
||||
for (auto &des : LoadedSILSections)
|
||||
des->invalidateAllCaches();
|
||||
}
|
||||
|
||||
bool SerializedSILLoader::invalidateFunction(SILFunction *F) {
|
||||
for (auto &Des : LoadedSILSections)
|
||||
if (Des->invalidateFunction(F))
|
||||
bool SerializedSILLoader::invalidateFunction(SILFunction *fn) {
|
||||
for (auto &des : LoadedSILSections)
|
||||
if (des->invalidateFunction(fn))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SerializedSILLoader::invalidateGlobalVariable(SILGlobalVariable *gv) {
|
||||
for (auto &des : LoadedSILSections)
|
||||
if (des->invalidateGlobalVariable(gv))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SerializedSILLoader::invalidateVTable(SILVTable *vt) {
|
||||
for (auto &des : LoadedSILSections)
|
||||
if (des->invalidateVTable(vt))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SerializedSILLoader::invalidateWitnessTable(SILWitnessTable *wt) {
|
||||
for (auto &des : LoadedSILSections)
|
||||
if (des->invalidateWitnessTable(wt))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SerializedSILLoader::invalidateDefaultWitnessTable(
|
||||
SILDefaultWitnessTable *wt) {
|
||||
for (auto &des : LoadedSILSections)
|
||||
if (des->invalidateDefaultWitnessTable(wt))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SerializedSILLoader::invalidateProperty(SILProperty *p) {
|
||||
for (auto &des : LoadedSILSections)
|
||||
if (des->invalidateProperty(p))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SerializedSILLoader::invalidateDifferentiabilityWitness(
|
||||
SILDifferentiabilityWitness *w) {
|
||||
for (auto &des : LoadedSILSections)
|
||||
if (des->invalidateDifferentiabilityWitness(w))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user