Add linkage SILLinkage::SharedExternal for deserialized functions with shared linkage.

*NOTE* This linkage is different from {Public,Hidden}External in that it has no
extra semantic meaning beyond shared.

The use of this linkage is to ensure that we do not serialize deserialized
shared functions. Those shared functions can always be re-deserialized from the
original module. This prevents a whole class of bugs related to the
creation of module cross references since all references to the shared
item go straight to the original module.

<rdar://problem/17772847>

Swift SVN r20375
This commit is contained in:
Michael Gottesman
2014-07-23 05:04:48 +00:00
parent 5279e948d9
commit 4ec0a81e5f
18 changed files with 95 additions and 12 deletions

View File

@@ -77,11 +77,12 @@ class SILModule::SerializationCallback : public SerializedSILLoader::Callback {
decl->setLinkage(SILLinkage::HiddenExternal);
return;
case SILLinkage::Shared:
decl->setLinkage(SILLinkage::Shared);
decl->setLinkage(SILLinkage::SharedExternal);
return;
case SILLinkage::Private: // ?
case SILLinkage::PublicExternal:
case SILLinkage::HiddenExternal:
case SILLinkage::SharedExternal:
return;
}
}
@@ -439,7 +440,7 @@ public:
// If the linking mode is not link all, AI is not transparent, and the
// callee is not shared, we don't want to perform any linking.
if (!isLinkAll() && !AI->isTransparent() &&
Callee->getLinkage() != SILLinkage::Shared)
!hasSharedVisibility(Callee->getLinkage()))
return false;
// Otherwise we want to try and link in the callee... Add it to the callee
@@ -455,7 +456,7 @@ public:
SILFunction *Callee = FRI->getReferencedFunction();
if (!isLinkAll() && !Callee->isTransparent() &&
Callee->getLinkage() != SILLinkage::Shared)
!hasSharedVisibility(Callee->getLinkage()))
return false;
addFunctionToWorklist(Callee);
@@ -468,7 +469,7 @@ public:
// an inconsistent state.
SILFunction *Callee = FRI->getReferencedFunction();
if (!isLinkAll() && !Callee->isTransparent() &&
Callee->getLinkage() != SILLinkage::Shared)
!hasSharedVisibility(Callee->getLinkage()))
return false;
addFunctionToWorklist(FRI->getReferencedFunction());