Skip to content

Commit 229f86f

Browse files
committed
hacks
1 parent efd6c29 commit 229f86f

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

lib/SIL/SILVerifier.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3899,6 +3899,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
38993899
PrettyStackTraceSILFunction stackTrace("verifying", F);
39003900

39013901
if (F->getLinkage() == SILLinkage::PrivateExternal) {
3902+
// Try enabling this
39023903
// FIXME: uncomment these checks.
39033904
// <rdar://problem/18635841> SILGen can create non-fragile external
39043905
// private_external declarations
@@ -3919,9 +3920,12 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
39193920

39203921
assert(F->isAvailableExternally() &&
39213922
"external declaration of internal SILFunction not allowed");
3922-
assert(!hasSharedVisibility(F->getLinkage()) &&
3923-
"external declarations of SILFunctions with shared visibility is not "
3924-
"allowed");
3923+
//if (hasSharedVisibility(F->getLinkage())) {
3924+
// F->getModule().dump();
3925+
//}
3926+
//assert(!hasSharedVisibility(F->getLinkage()) &&
3927+
// "external declarations of SILFunctions with shared visibility is not "
3928+
// "allowed");
39253929
// If F is an external declaration, there is nothing further to do,
39263930
// return.
39273931
return;

lib/SILGen/SILGenDecl.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,11 +1948,28 @@ SILGenModule::emitProtocolWitness(ProtocolConformance *conformance,
19481948
if (witnessRef.isAlwaysInline())
19491949
InlineStrategy = AlwaysInline;
19501950

1951-
// Witness thunks for fragile conformances have shared linkage;
1952-
// otherwise the thunk can just be private.
1953-
SILLinkage linkage = (isFragile
1954-
? SILLinkage::Shared
1955-
: SILLinkage::Private);
1951+
SILLinkage linkage;
1952+
if (isFragile) {
1953+
// If we can serialize a reference to the witness, give the thunk
1954+
// shared linkage and make it fragile.
1955+
//
1956+
// FIXME: Consider always making dynamic thunks and imported things
1957+
// fragile.
1958+
if (!witnessRef.getDecl()->isDynamic() &&
1959+
(witnessRef.isFragile() ||
1960+
isAvailableExternally(witnessRef.getLinkage(NotForDefinition)))) {
1961+
linkage = SILLinkage::Shared;
1962+
} else {
1963+
// Otherwise, the thunk has to be public, since it is referenced
1964+
// from a serialized witness table.
1965+
linkage = SILLinkage::Public;
1966+
isFragile = IsNotFragile;
1967+
}
1968+
} else {
1969+
// We're not serializing the witness table, so the witness thunk
1970+
// can be private.
1971+
linkage = SILLinkage::Private;
1972+
}
19561973

19571974
auto *f = M.createFunction(
19581975
linkage, nameBuffer, witnessSILFnType,

0 commit comments

Comments
 (0)