SIL: add a table in SILModule to mark method declarations as externally visible.

This is needed for cross-module-optimization: CMO marks functions as inlinable. If a private or internal method is referenced from such an inlinable function, it must not be eliminated by dead function elimination after serialization (a method is basically an AbstractFunctionDecl).
For SILFunctions we can do this by simply setting the linkage, but for methods we need another mechanism.
This commit is contained in:
Erik Eckstein
2019-11-22 18:46:48 +01:00
parent db815521d3
commit 402e228b39
5 changed files with 71 additions and 33 deletions

View File

@@ -194,6 +194,15 @@ private:
/// The list of SILDefaultWitnessTables in the module.
DefaultWitnessTableListType defaultWitnessTables;
/// Declarations which are externally visible.
///
/// These are method declarations which are referenced from inlinable
/// functions due to cross-module-optimzation. Those declarations don't have
/// any attributes or linkage which mark them as externally visible by
/// default.
/// Currently this table is not serialized.
llvm::SetVector<ValueDecl *> externallyVisible;
/// Lookup table for SIL Global Variables.
llvm::StringMap<SILGlobalVariable *> GlobalVariableMap;
@@ -446,6 +455,13 @@ public:
return {defaultWitnessTables.begin(), defaultWitnessTables.end()};
}
void addExternallyVisibleDecl(ValueDecl *decl) {
externallyVisible.insert(decl);
}
bool isExternallyVisibleDecl(ValueDecl *decl) {
return externallyVisible.count(decl) != 0;
}
using sil_global_iterator = GlobalListType::iterator;
using sil_global_const_iterator = GlobalListType::const_iterator;
GlobalListType &getSILGlobalList() { return silGlobals; }