Make sure that we do not try to create shared versions of stdlib_binary_only functions when specializing.

This can only happen in the closure specializer and the generic
specializer since all other specializations either copy the linkage of
the original function (function signature opts) or clone closures/thunks
which have shared linkage.

I put in a verifier check that makes sure we do not create shared
versions of these functions. The real problem has to do with serializing
these sorts of functions, but since we always serialize shared
functions, it makes sense to just ban it.

rdar://20082696

Swift SVN r26001
This commit is contained in:
Michael Gottesman
2015-03-11 23:18:56 +00:00
parent 718d82f5c9
commit d88f3767c3
5 changed files with 34 additions and 6 deletions

View File

@@ -448,3 +448,21 @@ ArrayRef<Substitution> SILFunction::getForwardingSubstitutions() {
return {};
return params->getForwardingSubstitutions(getASTContext());
}
bool SILFunction::canHaveSharedLinkage() const {
// If this function is an external declaration, it can not have shared
// linkage.
if (isExternalDeclaration())
return false;
// If this function has the stdlib_binary_only semantics tag, it can not be
// shared.
//
// Technically, we just want to make sure that we do not serialize these. For
// now this is a good enough wya to check for this.
if (hasSemanticsString("stdlib_binary_only"))
return false;
// Otherwise, it is legal to have shared linkage.
return true;
}