SIL: Introduce SILLinkage::PublicNonABI

This is going to be used for "always emit into client" functions,
such as default argument generators and stored property
initializers.

- In dead function elimination, these functions behave identically to
  public functions, serving as "anchors" for the mark-and-sweep
  analysis.

- There is no external variant of this linkage, because external
  declarations can use HiddenExternal linkage -- the definition should
  always be emitted by another translation unit in the same Swift
  module.

- When deserialized, they receive shared linkage, because we want the
  linker to coalesce multiple copies of the same deserialized
  definition if it was deserialized from multiple translation units
  in the same Swift module.

- When IRGen emits a definition with this linkage, it receives the
  same LLVM-level linkage as a hidden definition, ensuring it does not
  have a public entry point.
This commit is contained in:
Slava Pestov
2018-01-13 19:19:52 -08:00
parent 241c5e89bd
commit c857a480e1
16 changed files with 165 additions and 40 deletions

View File

@@ -60,6 +60,12 @@ class SILModule::SerializationCallback : public SerializedSILLoader::Callback {
case SILLinkage::Public:
decl->setLinkage(SILLinkage::PublicExternal);
return;
case SILLinkage::PublicNonABI:
// PublicNonABI functions receive SharedExternal linkage, so that
// they have "link once" semantics when deserialized by multiple
// translation units in the same Swift module.
decl->setLinkage(SILLinkage::SharedExternal);
return;
case SILLinkage::Hidden:
decl->setLinkage(SILLinkage::HiddenExternal);
return;
@@ -67,8 +73,8 @@ class SILModule::SerializationCallback : public SerializedSILLoader::Callback {
decl->setLinkage(SILLinkage::SharedExternal);
return;
case SILLinkage::Private:
decl->setLinkage(SILLinkage::PrivateExternal);
return;
decl->setLinkage(SILLinkage::PrivateExternal);
return;
case SILLinkage::PublicExternal:
case SILLinkage::HiddenExternal:
case SILLinkage::SharedExternal: