Add APIs to check if a function with a given name exists and to invalidate a SIL linker entry for a function.

These APIs are useful e.g. for quickly finding pre-specialisations by their names.
The existence check is very light-weight and does not try to deserialize bodies of SIL functions.
This commit is contained in:
Roman Levenstein
2016-02-26 22:01:02 -08:00
parent dd29bace34
commit 94c3ae4c3c
8 changed files with 91 additions and 7 deletions

View File

@@ -468,6 +468,15 @@ bool SILModule::linkFunction(StringRef Name, SILModule::LinkingMode Mode) {
return SILLinkerVisitor(*this, getSILLoader(), Mode).processFunction(Name);
}
SILFunction *SILModule::hasFunction(StringRef Name, SILLinkage Linkage) {
assert(!lookUpFunction(Name) && "hasFunction should be only called for "
"functions that are not contained in the "
"SILModule yet");
return SILLinkerVisitor(*this, getSILLoader(),
SILModule::LinkingMode::LinkNormal)
.lookupFunction(Name, Linkage);
}
void SILModule::linkAllWitnessTables() {
getSILLoader()->getAllWitnessTables();
}
@@ -516,6 +525,10 @@ void SILModule::eraseFunction(SILFunction *F) {
}
}
void SILModule::invalidateFunctionInSILCache(SILFunction *F) {
getSILLoader()->invalidateFunction(F);
}
/// Erase a global SIL variable from the module.
void SILModule::eraseGlobalVariable(SILGlobalVariable *G) {
GlobalVariableMap.erase(G->getName());