SIL: Don't serialize imported conformances nested in non-public types

Apparently you can use a swift_name attribute in Clang to import types
as members of Swift types. If the Swift type is not public, we would
still try to serialize the witness thunks, which tripped SIL verifier
checks since the witnesses themselves were not serialized.

Note that the fix here is to just delete the special case of an
imported conformance; the regular "type is public and protocol is
public" condition suffices here.

Fixes <rdar://problem/48218483>.
This commit is contained in:
Slava Pestov
2019-02-22 02:21:36 -05:00
parent a5e4fd555b
commit 72c8e787ad
4 changed files with 57 additions and 12 deletions

View File

@@ -12,10 +12,11 @@
//
// This file defines the SILWitnessTable class, which is used to map a protocol
// conformance for a type to its implementing SILFunctions. This information is
// (FIXME will be) used by IRGen to create witness tables for protocol dispatch.
// used by IRGen to create witness tables for protocol dispatch.
//
// It can also be used by generic specialization and existential
// devirtualization passes to promote witness_method and protocol_method
// instructions to static function_refs.
// devirtualization passes to promote witness_method instructions to static
// function_refs.
//
//===----------------------------------------------------------------------===//
@@ -24,7 +25,6 @@
#include "swift/AST/ASTMangler.h"
#include "swift/AST/Module.h"
#include "swift/AST/ProtocolConformance.h"
#include "swift/ClangImporter/ClangModule.h"
#include "swift/SIL/SILModule.h"
#include "llvm/ADT/SmallString.h"
@@ -172,11 +172,6 @@ bool SILWitnessTable::conformanceIsSerialized(
if (normalConformance && normalConformance->isResilient())
return false;
// Serialize witness tables for conformances synthesized by
// the ClangImporter.
if (isa<ClangModuleUnit>(conformance->getDeclContext()->getModuleScopeContext()))
return true;
if (conformance->getProtocol()->getEffectiveAccess() < AccessLevel::Public)
return false;