Merge pull request #21897 from shajrawi/excl_inline

[PerformanceInliner] Reduce the code size impact of the exclusivity heuristic
diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake
index 91c707f..8e51106 100644
--- a/cmake/modules/AddSwift.cmake
+++ b/cmake/modules/AddSwift.cmake
@@ -1189,7 +1189,7 @@
     DEPLOYMENT_VERSION_IOS "${SWIFTLIB_DEPLOYMENT_VERSION_IOS}"
     DEPLOYMENT_VERSION_TVOS "${SWIFTLIB_DEPLOYMENT_VERSION_TVOS}"
     DEPLOYMENT_VERSION_WATCHOS "${SWIFTLIB_DEPLOYMENT_VERSION_WATCHOS}"
-    "${SWIFTLIB_FORCE_BUILD_OPTIMIZED_keyword}"
+    "${SWIFTLIB_SINGLE_FORCE_BUILD_OPTIMIZED_keyword}"
     RESULT_VAR_NAME c_compile_flags
     )
   _add_variant_link_flags(
@@ -1399,6 +1399,7 @@
     ${ASHL_SHARED_keyword}
     ${ASHL_STATIC_keyword}
     ${ASHL_SOURCES}
+    ${ASHL_FORCE_BUILD_OPTIMIZED_keyword}
     SDK ${SWIFT_HOST_VARIANT_SDK}
     ARCHITECTURE ${SWIFT_HOST_VARIANT_ARCH}
     DEPENDS ${ASHL_DEPENDS}
diff --git a/include/swift/Remote/MetadataReader.h b/include/swift/Remote/MetadataReader.h
index c8d9eb2..ffbe6cd 100644
--- a/include/swift/Remote/MetadataReader.h
+++ b/include/swift/Remote/MetadataReader.h
@@ -1113,7 +1113,7 @@
       case MetadataKind::Tuple: {
         auto numElementsAddress = address +
           TargetTupleTypeMetadata<Runtime>::getOffsetToNumElements();
-        uint32_t numElements;
+        StoredSize numElements;
         if (!Reader->readInteger(RemoteAddress(numElementsAddress),
                                  &numElements))
           return nullptr;
diff --git a/include/swift/SIL/SILBuilder.h b/include/swift/SIL/SILBuilder.h
index 298f835..216d45e 100644
--- a/include/swift/SIL/SILBuilder.h
+++ b/include/swift/SIL/SILBuilder.h
@@ -1370,41 +1370,30 @@
         getModule(), getSILDebugLocation(Loc), Operand));
   }
 
-  MultipleValueInstruction *emitDestructureValueOperation(SILLocation Loc,
-                                                          SILValue Operand) {
-    SILType OpTy = Operand->getType();
-    if (OpTy.is<TupleType>())
-      return createDestructureTuple(Loc, Operand);
-    if (OpTy.getStructOrBoundGenericStruct())
-      return createDestructureStruct(Loc, Operand);
+  MultipleValueInstruction *emitDestructureValueOperation(SILLocation loc,
+                                                          SILValue operand) {
+    // If you hit this assert, you are using the wrong method. Use instead:
+    //
+    // emitDestructureValueOperation(SILLocation, SILValue,
+    //                               SmallVectorImpl<SILValue> &);
+    assert(hasOwnership() && "Expected to be called in ownership code only.");
+    SILType opTy = operand->getType();
+    if (opTy.is<TupleType>())
+      return createDestructureTuple(loc, operand);
+    if (opTy.getStructOrBoundGenericStruct())
+      return createDestructureStruct(loc, operand);
     llvm_unreachable("Can not emit a destructure for this type of operand.");
   }
 
   void
-  emitDestructureValueOperation(SILLocation Loc, SILValue Operand,
-                                function_ref<void(unsigned, SILValue)> Func) {
-    // Do a quick check to see if we have a tuple without elements. In that
-    // case, bail early since we are not going to ever invoke Func.
-    if (auto TTy = Operand->getType().castTo<TupleType>())
-      if (0 == TTy->getNumElements())
-        return;
+  emitDestructureValueOperation(SILLocation loc, SILValue operand,
+                                function_ref<void(unsigned, SILValue)> func);
 
-    auto *Destructure = emitDestructureValueOperation(Loc, Operand);
-    auto Results = Destructure->getResults();
-    // TODO: For some reason, llvm::enumerate(Results) does not
-    // compile.
-    for (unsigned i : indices(Results)) {
-      Func(i, Results[i]);
-    }
-  }
+  void emitDestructureValueOperation(SILLocation loc, SILValue operand,
+                                     SmallVectorImpl<SILValue> &result);
 
-  void
-  emitShallowDestructureValueOperation(SILLocation Loc, SILValue Operand,
-                                       llvm::SmallVectorImpl<SILValue> &Result);
-
-  void emitShallowDestructureAddressOperation(
-      SILLocation Loc, SILValue Operand,
-      llvm::SmallVectorImpl<SILValue> &Result);
+  void emitDestructureAddressOperation(SILLocation loc, SILValue operand,
+                                       SmallVectorImpl<SILValue> &result);
 
   ClassMethodInst *createClassMethod(SILLocation Loc, SILValue Operand,
                                      SILDeclRef Member, SILType MethodTy) {
diff --git a/include/swift/SILOptimizer/Analysis/ProtocolConformanceAnalysis.h b/include/swift/SILOptimizer/Analysis/ProtocolConformanceAnalysis.h
index ada341e..d6ab10d 100644
--- a/include/swift/SILOptimizer/Analysis/ProtocolConformanceAnalysis.h
+++ b/include/swift/SILOptimizer/Analysis/ProtocolConformanceAnalysis.h
@@ -19,6 +19,7 @@
 #include "swift/SIL/SILArgument.h"
 #include "swift/SIL/SILValue.h"
 #include "swift/SILOptimizer/Analysis/Analysis.h"
+#include "swift/SILOptimizer/Analysis/ClassHierarchyAnalysis.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
@@ -78,6 +79,10 @@
   /// conforming concrete type. 
   NominalTypeDecl *findSoleConformingType(ProtocolDecl *Protocol);
 
+  // Wrapper function to findSoleConformingType that checks for additional
+  // constraints for classes using ClassHierarchyAnalysis.
+  bool getSoleConformingType(ProtocolDecl *Protocol, ClassHierarchyAnalysis *CHA, CanType &ConcreteType);
+
 private:
   /// Compute inheritance properties.
   void init();
diff --git a/lib/AST/ASTVerifier.cpp b/lib/AST/ASTVerifier.cpp
index f7d7e06..1b84fd6 100644
--- a/lib/AST/ASTVerifier.cpp
+++ b/lib/AST/ASTVerifier.cpp
@@ -869,7 +869,8 @@
 
       if (D->hasAccess()) {
         PrettyStackTraceDecl debugStack("verifying access", D);
-        if (D->getFormalAccessScope().isPublic() &&
+        if (!D->getASTContext().isAccessControlDisabled() &&
+            D->getFormalAccessScope().isPublic() &&
             D->getFormalAccess() < AccessLevel::Public) {
           Out << "non-public decl has no formal access scope\n";
           D->dump(Out);
diff --git a/lib/AST/Attr.cpp b/lib/AST/Attr.cpp
index 138b5dd..848f456 100644
--- a/lib/AST/Attr.cpp
+++ b/lib/AST/Attr.cpp
@@ -552,10 +552,10 @@
   }
 
   case DAK_ObjCRuntimeName: {
-    Printer.printAttrName("@objc");
+    Printer.printAttrName("@_objcRuntimeName");
     Printer << "(";
     auto *attr = cast<ObjCRuntimeNameAttr>(this);
-    Printer << "\"" << attr->Name << "\"";
+    Printer << attr->Name;
     Printer << ")";
     break;
   }
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index a2b42bd..8a30842 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -2578,9 +2578,9 @@
   return false;
 }
 
-/// Return the access level of an internal or public declaration
-/// that's been testably imported.
-static AccessLevel getTestableOrPrivateImportsAccess(const ValueDecl *decl) {
+/// Return maximally open access level which could be associated with the
+/// given declaration accounting for @testable importers.
+static AccessLevel getMaximallyOpenAccessFor(const ValueDecl *decl) {
   // Non-final classes are considered open to @testable importers.
   if (auto cls = dyn_cast<ClassDecl>(decl)) {
     if (!cls->isFinal())
@@ -2606,6 +2606,11 @@
                                            AccessLevel access,
                                            const DeclContext *useDC,
                                            bool treatUsableFromInlineAsPublic) {
+  // If access control is disabled in the current context, adjust
+  // access level of the current declaration to be as open as possible.
+  if (useDC && VD->getASTContext().isAccessControlDisabled())
+    return getMaximallyOpenAccessFor(VD);
+
   if (treatUsableFromInlineAsPublic &&
       access == AccessLevel::Internal &&
       VD->isUsableFromInline()) {
@@ -2618,7 +2623,7 @@
     auto *useSF = dyn_cast<SourceFile>(useDC->getModuleScopeContext());
     if (!useSF) return access;
     if (useSF->hasTestableOrPrivateImport(access, VD))
-      return getTestableOrPrivateImportsAccess(VD);
+      return getMaximallyOpenAccessFor(VD);
   }
 
   return access;
@@ -2646,16 +2651,16 @@
   case AccessLevel::Internal:
     if (getModuleContext()->isTestingEnabled() ||
         getModuleContext()->arePrivateImportsEnabled())
-      effectiveAccess = getTestableOrPrivateImportsAccess(this);
+      effectiveAccess = getMaximallyOpenAccessFor(this);
     break;
   case AccessLevel::FilePrivate:
     if (getModuleContext()->arePrivateImportsEnabled())
-      effectiveAccess = getTestableOrPrivateImportsAccess(this);
+      effectiveAccess = getMaximallyOpenAccessFor(this);
     break;
   case AccessLevel::Private:
     effectiveAccess = AccessLevel::FilePrivate;
     if (getModuleContext()->arePrivateImportsEnabled())
-      effectiveAccess = getTestableOrPrivateImportsAccess(this);
+      effectiveAccess = getMaximallyOpenAccessFor(this);
     break;
   }
 
@@ -2851,9 +2856,7 @@
   case AccessLevel::FilePrivate:
     if (useDC->getModuleScopeContext() != sourceDC->getModuleScopeContext()) {
       auto *useSF = dyn_cast<SourceFile>(useDC->getModuleScopeContext());
-      if (useSF && useSF->hasTestableOrPrivateImport(access, VD))
-        return true;
-      return false;
+      return useSF && useSF->hasTestableOrPrivateImport(access, VD);
     }
     return true;
   case AccessLevel::Internal: {
@@ -2862,10 +2865,7 @@
     if (useFile->getParentModule() == sourceModule)
       return true;
     auto *useSF = dyn_cast<SourceFile>(useFile);
-    if (!useSF) return false;
-    if (useSF->hasTestableOrPrivateImport(access, sourceModule))
-      return true;
-    return false;
+    return useSF && useSF->hasTestableOrPrivateImport(access, sourceModule);
   }
   case AccessLevel::Public:
   case AccessLevel::Open:
diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp
index 2b80732..6d5ac35 100644
--- a/lib/ClangImporter/ImportDecl.cpp
+++ b/lib/ClangImporter/ImportDecl.cpp
@@ -322,9 +322,19 @@
     break;
 
   case MappedCTypeKind::VaList:
-   if (ClangTypeSize != ClangCtx.getTypeSize(ClangCtx.VoidPtrTy)) {
-      if (ClangCtx.getTargetInfo().getBuiltinVaListKind() !=
-          clang::TargetInfo::AArch64ABIBuiltinVaList)
+    switch (ClangCtx.getTargetInfo().getBuiltinVaListKind()) {
+      case clang::TargetInfo::CharPtrBuiltinVaList:
+      case clang::TargetInfo::VoidPtrBuiltinVaList:
+      case clang::TargetInfo::PowerABIBuiltinVaList:
+      case clang::TargetInfo::AAPCSABIBuiltinVaList:
+        assert(ClangCtx.getTypeSize(ClangCtx.VoidPtrTy) == ClangTypeSize &&
+               "expected va_list type to be sizeof(void *)");
+        break;
+      case clang::TargetInfo::AArch64ABIBuiltinVaList:
+        break;
+      case clang::TargetInfo::PNaClABIBuiltinVaList:
+      case clang::TargetInfo::SystemZBuiltinVaList:
+      case clang::TargetInfo::X86_64ABIBuiltinVaList:
         return std::make_pair(Type(), "");
     }
     break;
diff --git a/lib/Migrator/APIDiffMigratorPass.cpp b/lib/Migrator/APIDiffMigratorPass.cpp
index ce4af62..be4cf05 100644
--- a/lib/Migrator/APIDiffMigratorPass.cpp
+++ b/lib/Migrator/APIDiffMigratorPass.cpp
@@ -1077,6 +1077,31 @@
     return false;
   }
 
+  void handleResultTypeChange(ValueDecl *FD, Expr *Call) {
+    Optional<NodeAnnotation> ChangeKind;
+
+    // look for related change item for the function decl.
+    for (auto Item: getRelatedDiffItems(FD)) {
+      if (auto *CI = dyn_cast<CommonDiffItem>(Item)) {
+        // check if the function's return type has been changed from nonnull
+        // to nullable.
+        if (CI->DiffKind == NodeAnnotation::WrapOptional &&
+            CI->getChildIndices().size() == 1 &&
+            CI->getChildIndices().front() == 0) {
+          ChangeKind = NodeAnnotation::WrapOptional;
+          break;
+        }
+      }
+    }
+    if (!ChangeKind.hasValue())
+      return;
+    // If a function's return type has been changed from nonnull to nullable,
+    // append ! to the original call expression.
+    if (*ChangeKind == NodeAnnotation::WrapOptional) {
+      Editor.insertAfterToken(Call->getSourceRange().End, "!");
+    }
+  }
+
   bool walkToExprPre(Expr *E) override {
     if (E->getSourceRange().isInvalid())
       return false;
@@ -1100,6 +1125,7 @@
           handleTypeHoist(FD, CE, Args);
           handleSpecialCases(FD, CE, Args);
           handleStringRepresentableArg(FD, Args, CE);
+          handleResultTypeChange(FD, CE);
         }
         break;
       }
@@ -1110,15 +1136,16 @@
           handleFunctionCallToPropertyChange(FD, DSC->getFn(), Args);
           handleSpecialCases(FD, CE, Args);
           handleStringRepresentableArg(FD, Args, CE);
+          handleResultTypeChange(FD, CE);
         }
         break;
       }
       case ExprKind::ConstructorRefCall: {
         auto CCE = cast<ConstructorRefCallExpr>(Fn);
         if (auto FD = CCE->getFn()->getReferencedDecl().getDecl()) {
-          auto *CE = CCE->getFn();
           handleFuncRename(FD, CE, Args);
           handleStringRepresentableArg(FD, Args, CE);
+          handleResultTypeChange(FD, CE);
         }
         break;
       }
diff --git a/lib/Migrator/overlay4.json b/lib/Migrator/overlay4.json
index d5fb336..6c2e805 100644
--- a/lib/Migrator/overlay4.json
+++ b/lib/Migrator/overlay4.json
@@ -1332,4 +1332,15 @@
     "RightComment": "firstIndex",
     "ModuleName": "Swift"
   },
+  {
+    "DiffItemKind": "CommonDiffItem",
+    "NodeKind": "Function",
+    "NodeAnnotation": "Rename",
+    "ChildIndex": "0",
+    "LeftUsr": "s:SlsE5index5where5IndexQzSgSb7ElementQzKXE_tKF",
+    "LeftComment": "index",
+    "RightUsr": "",
+    "RightComment": "firstIndex",
+    "ModuleName": "Swift"
+  },
 ]
diff --git a/lib/Migrator/overlay42.json b/lib/Migrator/overlay42.json
index cc6d339..7498140 100644
--- a/lib/Migrator/overlay42.json
+++ b/lib/Migrator/overlay42.json
@@ -10,4 +10,15 @@
     "RightComment": "firstIndex",
     "ModuleName": "Swift"
   },
+  {
+    "DiffItemKind": "CommonDiffItem",
+    "NodeKind": "Function",
+    "NodeAnnotation": "Rename",
+    "ChildIndex": "0",
+    "LeftUsr": "s:SlsE5index5where5IndexQzSgSb7ElementQzKXE_tKF",
+    "LeftComment": "index",
+    "RightUsr": "",
+    "RightComment": "firstIndex",
+    "ModuleName": "Swift"
+  },
 ]
diff --git a/lib/Parse/PersistentParserState.cpp b/lib/Parse/PersistentParserState.cpp
index 384d058..e88b13f 100644
--- a/lib/Parse/PersistentParserState.cpp
+++ b/lib/Parse/PersistentParserState.cpp
@@ -83,6 +83,7 @@
 
 void PersistentParserState::parseAllDelayedDeclLists() {
   std::vector<IterableDeclContext*> AllDelayed;
+  AllDelayed.reserve(DelayedDeclListStates.size());
   for (auto &P: DelayedDeclListStates) {
     AllDelayed.push_back(P.first);
   }
diff --git a/lib/SIL/SILBuilder.cpp b/lib/SIL/SILBuilder.cpp
index b0db398..a84f732 100644
--- a/lib/SIL/SILBuilder.cpp
+++ b/lib/SIL/SILBuilder.cpp
@@ -502,54 +502,71 @@
 }
 
 // TODO: This should really be an operation on type lowering.
-void SILBuilder::emitShallowDestructureValueOperation(
-    SILLocation Loc, SILValue V, llvm::SmallVectorImpl<SILValue> &Results) {
+void SILBuilder::emitDestructureValueOperation(
+    SILLocation loc, SILValue v, SmallVectorImpl<SILValue> &results) {
   // Once destructure is allowed everywhere, remove the projection code.
 
   // If we do not have a tuple or a struct, add to our results list and return.
-  SILType Ty = V->getType();
-  if (!(Ty.is<TupleType>() || Ty.getStructOrBoundGenericStruct())) {
-    Results.emplace_back(V);
+  SILType type = v->getType();
+  if (!(type.is<TupleType>() || type.getStructOrBoundGenericStruct())) {
+    results.emplace_back(v);
     return;
   }
 
   // Otherwise, we want to destructure add the destructure and return.
   if (getFunction().hasOwnership()) {
-    auto *DI = emitDestructureValueOperation(Loc, V);
-    copy(DI->getResults(), std::back_inserter(Results));
+    auto *i = emitDestructureValueOperation(loc, v);
+    copy(i->getResults(), std::back_inserter(results));
     return;
   }
 
   // In non qualified ownership SIL, drop back to using projection code.
-  llvm::SmallVector<Projection, 16> Projections;
-  Projection::getFirstLevelProjections(V->getType(), getModule(), Projections);
-  transform(Projections, std::back_inserter(Results),
-            [&](const Projection &P) -> SILValue {
-              return P.createObjectProjection(*this, Loc, V).get();
+  SmallVector<Projection, 16> projections;
+  Projection::getFirstLevelProjections(v->getType(), getModule(), projections);
+  transform(projections, std::back_inserter(results),
+            [&](const Projection &p) -> SILValue {
+              return p.createObjectProjection(*this, loc, v).get();
             });
 }
 
 // TODO: Can we put this on type lowering? It would take a little bit of work
 // since we would need to be able to handle aggregate trivial types which is not
 // represented today in TypeLowering.
-void SILBuilder::emitShallowDestructureAddressOperation(
-    SILLocation Loc, SILValue V, llvm::SmallVectorImpl<SILValue> &Results) {
+void SILBuilder::emitDestructureAddressOperation(
+    SILLocation loc, SILValue v, SmallVectorImpl<SILValue> &results) {
 
   // If we do not have a tuple or a struct, add to our results list.
-  SILType Ty = V->getType();
-  if (!(Ty.is<TupleType>() || Ty.getStructOrBoundGenericStruct())) {
-    Results.emplace_back(V);
+  SILType type = v->getType();
+  if (!(type.is<TupleType>() || type.getStructOrBoundGenericStruct())) {
+    results.emplace_back(v);
     return;
   }
 
-  llvm::SmallVector<Projection, 16> Projections;
-  Projection::getFirstLevelProjections(V->getType(), getModule(), Projections);
-  transform(Projections, std::back_inserter(Results),
-            [&](const Projection &P) -> SILValue {
-              return P.createAddressProjection(*this, Loc, V).get();
+  SmallVector<Projection, 16> projections;
+  Projection::getFirstLevelProjections(v->getType(), getModule(), projections);
+  transform(projections, std::back_inserter(results),
+            [&](const Projection &p) -> SILValue {
+              return p.createAddressProjection(*this, loc, v).get();
             });
 }
 
+void SILBuilder::emitDestructureValueOperation(
+    SILLocation loc, SILValue operand,
+    function_ref<void(unsigned, SILValue)> func) {
+  // Do a quick check to see if we have a tuple without elements. In that
+  // case, bail early since we are not going to ever invoke Func.
+  if (auto tupleType = operand->getType().castTo<TupleType>())
+    if (0 == tupleType->getNumElements())
+      return;
+
+  SmallVector<SILValue, 8> results;
+  emitDestructureValueOperation(loc, operand, results);
+
+  for (auto p : llvm::enumerate(results)) {
+    func(p.index(), p.value());
+  }
+}
+
 DebugValueInst *SILBuilder::createDebugValue(SILLocation Loc, SILValue src,
                                              SILDebugVariable Var) {
   assert(isLoadableOrOpaque(src->getType()));
diff --git a/lib/SIL/SILProfiler.cpp b/lib/SIL/SILProfiler.cpp
index 1a13208..64a2d41 100644
--- a/lib/SIL/SILProfiler.cpp
+++ b/lib/SIL/SILProfiler.cpp
@@ -42,6 +42,10 @@
 
 /// Check whether a root AST node is unmapped, i.e not profiled.
 static bool isUnmapped(ASTNode N) {
+  // Do not map AST nodes with invalid source locations.
+  if (N.getStartLoc().isInvalid() || N.getEndLoc().isInvalid())
+    return true;
+
   if (auto *E = N.dyn_cast<Expr *>()) {
     auto *CE = dyn_cast<AbstractClosureExpr>(E);
 
@@ -396,7 +400,12 @@
 public:
   SourceMappingRegion(ASTNode Node, CounterExpr &Count,
                       Optional<SourceLoc> StartLoc, Optional<SourceLoc> EndLoc)
-      : Node(Node), Count(&Count), StartLoc(StartLoc), EndLoc(EndLoc) {}
+      : Node(Node), Count(&Count), StartLoc(StartLoc), EndLoc(EndLoc) {
+    assert((!StartLoc || StartLoc->isValid()) &&
+           "Expected start location to be valid");
+    assert((!EndLoc || EndLoc->isValid()) &&
+           "Expected start location to be valid");
+  }
 
   SourceMappingRegion(SourceMappingRegion &&Region) = default;
   SourceMappingRegion &operator=(SourceMappingRegion &&RHS) = default;
diff --git a/lib/SILGen/SILGenPoly.cpp b/lib/SILGen/SILGenPoly.cpp
index d545fe2..9d13115 100644
--- a/lib/SILGen/SILGenPoly.cpp
+++ b/lib/SILGen/SILGenPoly.cpp
@@ -673,11 +673,11 @@
   bool isPlusOne = managedTuple.hasCleanup();
 
   if (managedTuple.getType().isAddress()) {
-    SGF.B.emitShallowDestructureAddressOperation(loc, managedTuple.forward(SGF),
-                                                 elements);
+    SGF.B.emitDestructureAddressOperation(loc, managedTuple.forward(SGF),
+                                          elements);
   } else {
-    SGF.B.emitShallowDestructureValueOperation(loc, managedTuple.forward(SGF),
-                                               elements);
+    SGF.B.emitDestructureValueOperation(loc, managedTuple.forward(SGF),
+                                        elements);
   }
 
   for (auto element : elements) {
diff --git a/lib/SILOptimizer/Analysis/ProtocolConformanceAnalysis.cpp b/lib/SILOptimizer/Analysis/ProtocolConformanceAnalysis.cpp
index 859e5af..f93b309 100644
--- a/lib/SILOptimizer/Analysis/ProtocolConformanceAnalysis.cpp
+++ b/lib/SILOptimizer/Analysis/ProtocolConformanceAnalysis.cpp
@@ -139,4 +139,26 @@
   return SoleConformingNTD;
 }
 
+// Wrapper function to findSoleConformingType that checks for additional
+// constraints for classes using ClassHierarchyAnalysis.
+bool ProtocolConformanceAnalysis::getSoleConformingType(
+    ProtocolDecl *Protocol, ClassHierarchyAnalysis *CHA, CanType &ConcreteType) {
+  // Determine the sole conforming type.
+  auto *NTD = findSoleConformingType(Protocol);
+  if (!NTD)
+    return false;
+
+  // Sole conforming class should not be open access or have any derived class.
+  ClassDecl *CD;
+  if ((CD = dyn_cast<ClassDecl>(NTD)) &&
+      (CD->getEffectiveAccess() == AccessLevel::Open ||
+       CHA->hasKnownDirectSubclasses(CD))) {
+    return false;
+  }
+
+  // Save the concrete type.
+  ConcreteType = NTD->getDeclaredType()->getCanonicalType();
+  return true;
+}
+
 ProtocolConformanceAnalysis::~ProtocolConformanceAnalysis() {}
diff --git a/lib/SILOptimizer/FunctionSignatureTransforms/ExistentialSpecializer.cpp b/lib/SILOptimizer/FunctionSignatureTransforms/ExistentialSpecializer.cpp
index d587871..16de16a 100644
--- a/lib/SILOptimizer/FunctionSignatureTransforms/ExistentialSpecializer.cpp
+++ b/lib/SILOptimizer/FunctionSignatureTransforms/ExistentialSpecializer.cpp
@@ -19,6 +19,7 @@
 #include "ExistentialTransform.h"
 #include "swift/SIL/SILFunction.h"
 #include "swift/SIL/SILInstruction.h"
+#include "swift/SILOptimizer/Analysis/ProtocolConformanceAnalysis.h"
 #include "swift/SILOptimizer/PassManager/Transforms.h"
 #include "swift/SILOptimizer/Utils/Existential.h"
 #include "swift/SILOptimizer/Utils/Local.h"
@@ -48,9 +49,18 @@
   /// Specialize existential args in function F.
   void specializeExistentialArgsInAppliesWithinFunction(SILFunction &F);
 
+  /// Find concrete type using protocolconformance analysis.
+  bool findConcreteTypeFromSoleConformingType(
+    SILFunctionArgument *Arg, CanType &ConcreteType);
+
   /// CallerAnalysis information.
   CallerAnalysis *CA;
 
+  // Determine the set of types a protocol conforms to in whole-module
+  // compilation mode.
+  ProtocolConformanceAnalysis *PCA;
+
+  ClassHierarchyAnalysis *CHA;
 public:
   void run() override {
 
@@ -64,12 +74,39 @@
     /// Get CallerAnalysis information handy.
     CA = PM->getAnalysis<CallerAnalysis>();
 
+    /// Get ProtocolConformanceAnalysis.
+    PCA = PM->getAnalysis<ProtocolConformanceAnalysis>();
+
+    /// Get ClassHierarchyAnalysis.
+    CHA = PM->getAnalysis<ClassHierarchyAnalysis>();
     /// Perform specialization.
     specializeExistentialArgsInAppliesWithinFunction(*F);
   }
 };
 } // namespace
 
+/// Find concrete type from Sole Conforming Type.
+bool ExistentialSpecializer::findConcreteTypeFromSoleConformingType(
+    SILFunctionArgument *Arg, CanType &ConcreteType) {
+  auto ArgType = Arg->getType();
+  auto SwiftArgType = ArgType.getASTType();
+
+  /// Do not handle composition types yet.
+  if (isa<ProtocolCompositionType>(SwiftArgType))
+    return false;
+  assert(ArgType.isExistentialType());
+  /// Find the protocol decl.
+  auto *PD = dyn_cast<ProtocolDecl>(SwiftArgType->getAnyNominal());
+  if (!PD)
+    return false;
+
+  // Get SoleConformingType in ConcreteType using ProtocolConformanceAnalysis
+  // and ClassHierarchyAnalysis.
+  if (!PCA->getSoleConformingType(PD, CHA, ConcreteType))
+    return false;
+  return true;
+}
+
 /// Check if the argument Arg is used in a destroy_use instruction.
 static void
 findIfCalleeUsesArgInDestroyUse(SILValue Arg,
@@ -83,6 +120,14 @@
   }
 }
 
+/// Helper function to ensure that the argument is not InOut or InOut_Aliasable
+static bool isNonInoutIndirectArgument(SILValue Arg,
+                                       SILArgumentConvention ArgConvention) {
+  return !Arg->getType().isObject() && ArgConvention.isIndirectConvention() &&
+         ArgConvention != SILArgumentConvention::Indirect_Inout &&
+         ArgConvention != SILArgumentConvention::Indirect_InoutAliasable;
+}
+
 /// Check if any apply argument meets the criteria for existential
 /// specialization.
 bool ExistentialSpecializer::canSpecializeExistentialArgsInFunction(
@@ -122,7 +167,14 @@
     Operand &ArgOper = Apply.getArgumentRef(Idx);
     CanType ConcreteType =
         ConcreteExistentialInfo(ArgOper.get(), ArgOper.getUser()).ConcreteType;
-    if (!ConcreteType) {
+    auto ArgConvention = F->getConventions().getSILArgumentConvention(Idx);
+    /// Find the concrete type, either via sole type or via
+    /// findInitExistential..
+    CanType SoleConcreteType;
+    if (!((F->getModule().isWholeModule() &&
+           isNonInoutIndirectArgument(CalleeArg, ArgConvention) &&
+           findConcreteTypeFromSoleConformingType(CalleeArg, SoleConcreteType)) ||
+          ConcreteType)) {
       LLVM_DEBUG(
           llvm::dbgs()
               << "ExistentialSpecializer Pass: Bail! cannot find ConcreteType "
diff --git a/lib/SILOptimizer/FunctionSignatureTransforms/ExistentialTransform.cpp b/lib/SILOptimizer/FunctionSignatureTransforms/ExistentialTransform.cpp
index 2ac1c14..a608b82 100644
--- a/lib/SILOptimizer/FunctionSignatureTransforms/ExistentialTransform.cpp
+++ b/lib/SILOptimizer/FunctionSignatureTransforms/ExistentialTransform.cpp
@@ -401,6 +401,8 @@
         break;
       }
       case ExistentialRepresentation::Class: {
+        /// If the operand is not object type, we would need an explicit load.
+        assert(OrigOperand->getType().isObject());
         archetypeValue =
             Builder.createOpenExistentialRef(Loc, OrigOperand, OpenedSILType);
         ApplyArgs.push_back(archetypeValue);
diff --git a/lib/SILOptimizer/Mandatory/PMOMemoryUseCollector.cpp b/lib/SILOptimizer/Mandatory/PMOMemoryUseCollector.cpp
index 8677c8f..bfed58f 100644
--- a/lib/SILOptimizer/Mandatory/PMOMemoryUseCollector.cpp
+++ b/lib/SILOptimizer/Mandatory/PMOMemoryUseCollector.cpp
@@ -59,17 +59,6 @@
   }
 }
 
-/// Given an RValue of aggregate type, compute the values of the elements by
-/// emitting a series of tuple_element instructions.
-static void getScalarizedElements(SILValue V,
-                                  SmallVectorImpl<SILValue> &ElementVals,
-                                  SILLocation Loc, SILBuilder &B) {
-  TupleType *TT = V->getType().castTo<TupleType>();
-  for (auto Index : indices(TT->getElements())) {
-    ElementVals.push_back(B.emitTupleExtract(Loc, V, Index));
-  }
-}
-
 /// Scalarize a load down to its subelements.  If NewLoads is specified, this
 /// can return the newly generated sub-element loads.
 static SILValue scalarizeLoad(LoadInst *LI,
@@ -78,8 +67,9 @@
   SmallVector<SILValue, 4> ElementTmps;
 
   for (unsigned i = 0, e = ElementAddrs.size(); i != e; ++i) {
-    auto *SubLI = B.createLoad(LI->getLoc(), ElementAddrs[i],
-                               LoadOwnershipQualifier::Unqualified);
+    auto *SubLI = B.createTrivialLoadOr(LI->getLoc(), ElementAddrs[i],
+                                        LI->getOwnershipQualifier(),
+                                        true /*supports unqualified*/);
     ElementTmps.push_back(SubLI);
   }
 
@@ -118,7 +108,7 @@
 
 private:
   LLVM_NODISCARD bool collectUses(SILValue Pointer);
-  LLVM_NODISCARD bool collectContainerUses(AllocBoxInst *ABI);
+  LLVM_NODISCARD bool collectContainerUses(SILValue boxValue);
 };
 } // end anonymous namespace
 
@@ -130,8 +120,10 @@
   return collectUses(TheMemory.getAddress());
 }
 
-bool ElementUseCollector::collectContainerUses(AllocBoxInst *abi) {
-  for (auto *ui : abi->getUses()) {
+bool ElementUseCollector::collectContainerUses(SILValue boxValue) {
+  assert(isa<AllocBoxInst>(boxValue) || isa<CopyValueInst>(boxValue));
+
+  for (auto *ui : boxValue->getUses()) {
     auto *user = ui->getUser();
 
     // dealloc_box deallocated a box containing uninitialized memory. This can
@@ -143,6 +135,14 @@
     if (isa<StrongRetainInst>(user) || isa<RetainValueInst>(user))
       continue;
 
+    // Like retaining, copies do not effect the underlying value. We do need to
+    // recursively visit the copies users though.
+    if (auto *cvi = dyn_cast<CopyValueInst>(user)) {
+      if (!collectContainerUses(cvi))
+        return false;
+      continue;
+    }
+
     // Since we are trying to promote loads/stores, any releases of the box are
     // not considered uses of the underlying value due to:
     //
@@ -162,7 +162,8 @@
     // FIXME: Since we do not support promoting strong_release or release_value
     // today this will cause the underlying allocation to never be
     // eliminated. That should be implemented and fixed.
-    if (isa<StrongReleaseInst>(user) || isa<ReleaseValueInst>(user)) {
+    if (isa<StrongReleaseInst>(user) || isa<ReleaseValueInst>(user) ||
+        isa<DestroyValueInst>(user)) {
       Releases.push_back(user);
       continue;
     }
@@ -430,11 +431,13 @@
       // Scalarize StoreInst
       if (auto *SI = dyn_cast<StoreInst>(User)) {
         SILBuilderWithScope B(User, SI);
-        getScalarizedElements(SI->getOperand(0), ElementTmps, SI->getLoc(), B);
-
+        B.emitDestructureValueOperation(
+            SI->getLoc(), SI->getSrc(),
+            [&](unsigned index, SILValue v) { ElementTmps.push_back(v); });
         for (unsigned i = 0, e = ElementAddrs.size(); i != e; ++i)
-          B.createStore(SI->getLoc(), ElementTmps[i], ElementAddrs[i],
-                        StoreOwnershipQualifier::Unqualified);
+          B.createTrivialStoreOr(SI->getLoc(), ElementTmps[i], ElementAddrs[i],
+                                 SI->getOwnershipQualifier(),
+                                 true /*supports unqualified*/);
         SI->eraseFromParent();
         continue;
       }
diff --git a/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp b/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp
index fb294b9..0fdfd4b 100644
--- a/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp
+++ b/lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp
@@ -667,22 +667,10 @@
     return None;
 
   // Determine the sole conforming type.
-  auto *NTD = PCA->findSoleConformingType(PD);
-  if (!NTD)
+  CanType ConcreteType;
+  if (!PCA->getSoleConformingType(PD, CHA, ConcreteType))
     return None;
 
-  // Sole conforming class should not be open access or have any derived class.
-  ClassDecl *CD;
-  if ((CD = dyn_cast<ClassDecl>(NTD)) &&
-      (CD->getEffectiveAccess() == AccessLevel::Open ||
-       CHA->hasKnownDirectSubclasses(CD))) {
-    return None;
-  }
-
-  // Create SIL type for the concrete type.
-  auto ElementType = NTD->getDeclaredType();
-  auto ConcreteType = ElementType->getCanonicalType();
-
   // Determine OpenedArchetypeDef and SubstituionMap.
   ConcreteOpenedExistentialInfo COAI(ArgOperand, ConcreteType, PD);
   if (!COAI.CEI)
diff --git a/lib/Sema/CSDiag.cpp b/lib/Sema/CSDiag.cpp
index fd2cb39..a0b342d 100644
--- a/lib/Sema/CSDiag.cpp
+++ b/lib/Sema/CSDiag.cpp
@@ -1298,7 +1298,7 @@
                 rhs);
     return true;
 
-  case ConstraintKind::Equal: { // same type
+  case ConstraintKind::Bind: { // same type
     TC.diagnose(anchor->getLoc(), diag::types_not_equal, ownerType, lhs, rhs);
     return true;
   }
diff --git a/lib/Sema/CSGen.cpp b/lib/Sema/CSGen.cpp
index b3f972e..a032128 100644
--- a/lib/Sema/CSGen.cpp
+++ b/lib/Sema/CSGen.cpp
@@ -1679,7 +1679,7 @@
                                 options))
               return Type();
 
-            CS.addConstraint(ConstraintKind::Equal,
+            CS.addConstraint(ConstraintKind::Bind,
                              typeVars[i], specializations[i].getType(),
                              locator);
           }
@@ -3737,7 +3737,7 @@
 }
 
 bool swift::canPossiblyEqual(Type T1, Type T2, DeclContext &DC) {
-  return canSatisfy(T1, T2, true, ConstraintKind::Equal, &DC);
+  return canSatisfy(T1, T2, true, ConstraintKind::Bind, &DC);
 }
 
 bool swift::canPossiblyConvertTo(Type T1, Type T2, DeclContext &DC) {
diff --git a/lib/Sema/CSRanking.cpp b/lib/Sema/CSRanking.cpp
index 1bf2045..841b971 100644
--- a/lib/Sema/CSRanking.cpp
+++ b/lib/Sema/CSRanking.cpp
@@ -592,7 +592,7 @@
         break;
 
       case SelfTypeRelationship::Equivalent:
-        cs.addConstraint(ConstraintKind::Equal, selfTy1, selfTy2, locator);
+        cs.addConstraint(ConstraintKind::Bind, selfTy1, selfTy2, locator);
         break;
 
       case SelfTypeRelationship::Subclass:
diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp
index 330840e..6e6002f 100644
--- a/lib/Sema/CSSimplify.cpp
+++ b/lib/Sema/CSSimplify.cpp
@@ -1278,7 +1278,7 @@
     if (super1->getClassOrBoundGenericClass() != classDecl2)
       continue;
 
-    return matchTypes(super1, type2, ConstraintKind::Equal,
+    return matchTypes(super1, type2, ConstraintKind::Bind,
                       subflags, locator);
   }
 
@@ -1302,7 +1302,7 @@
 
     // Match up the parents, exactly.
     return matchTypes(nominal1->getParent(), nominal2->getParent(),
-                      ConstraintKind::Equal, subflags,
+                      ConstraintKind::Bind, subflags,
                       locator.withPathElement(ConstraintLocator::ParentType));
   }
 
@@ -1314,7 +1314,7 @@
          "Mismatched parents of bound generics");
   if (bound1->getParent()) {
     auto result = matchTypes(bound1->getParent(), bound2->getParent(),
-                             ConstraintKind::Equal, subflags,
+                             ConstraintKind::Bind, subflags,
                              locator.withPathElement(
                                                 ConstraintLocator::ParentType));
     if (result.isFailure())
@@ -1328,7 +1328,7 @@
     return getTypeMatchFailure(locator);
   }
   for (unsigned i = 0, n = args1.size(); i != n; ++i) {
-    auto result = matchTypes(args1[i], args2[i], ConstraintKind::Equal,
+    auto result = matchTypes(args1[i], args2[i], ConstraintKind::Bind,
                              subflags, locator.withPathElement(
                                         LocatorPathElt::getGenericArgument(i)));
 
@@ -1953,7 +1953,7 @@
       if (isa<MetatypeType>(meta1) &&
           !(instanceType1->mayHaveSuperclass() &&
             instanceType2->getClassOrBoundGenericClass())) {
-        subKind = ConstraintKind::Equal;
+        subKind = ConstraintKind::Bind;
       }
 
       return matchTypes(
@@ -1979,7 +1979,7 @@
         return getTypeMatchFailure(locator);
       return matchTypes(cast<LValueType>(desugar1)->getObjectType(),
                         cast<LValueType>(desugar2)->getObjectType(),
-                        ConstraintKind::Equal, subflags,
+                        ConstraintKind::Bind, subflags,
                         locator.withPathElement(
                           ConstraintLocator::LValueConversion));
     
@@ -1991,7 +1991,7 @@
       
       return matchTypes(cast<InOutType>(desugar1)->getObjectType(),
                         cast<InOutType>(desugar2)->getObjectType(),
-                        ConstraintKind::Equal, subflags,
+                        ConstraintKind::Bind, subflags,
                   locator.withPathElement(ConstraintLocator::LValueConversion));
 
     case TypeKind::UnboundGeneric:
@@ -2207,7 +2207,7 @@
               auto inoutBaseType = inoutType1->getInOutObjectType();
 
               Type simplifiedInoutBaseType = getFixedTypeRecursive(
-                  inoutBaseType, kind == ConstraintKind::Equal);
+                  inoutBaseType, /*wantRValue=*/true);
 
               // FIXME: If the base is still a type variable, we can't tell
               // what to do here. Might have to try \c ArrayToPointer and make
@@ -2309,7 +2309,7 @@
     if (auto *lvt = type1->getAs<LValueType>()) {
       if (auto *iot = type2->getAs<InOutType>()) {
         return matchTypes(lvt->getObjectType(), iot->getObjectType(),
-                          ConstraintKind::Equal, subflags,
+                          ConstraintKind::Bind, subflags,
                           locator.withPathElement(
                                   ConstraintLocator::LValueConversion));
       }
@@ -2465,13 +2465,13 @@
         // Determine the constraint kind. For a deep equality constraint, only
         // perform equality.
         if (*restriction == ConversionRestrictionKind::DeepEquality)
-          constraintKind = ConstraintKind::Equal;
+          constraintKind = ConstraintKind::Bind;
 
         constraints.push_back(
           Constraint::createRestricted(*this, constraintKind, *restriction,
                                        type1, type2, fixedLocator));
 
-        if (constraints.back()->getKind() == ConstraintKind::Equal)
+        if (constraints.back()->getKind() == ConstraintKind::Bind)
           constraints.back()->setFavored();
 
         continue;
@@ -4090,7 +4090,7 @@
       }
 
       // Make sure we have the bridged value type.
-      if (matchTypes(unwrappedToType, bridgedValueType, ConstraintKind::Equal,
+      if (matchTypes(unwrappedToType, bridgedValueType, ConstraintKind::Bind,
                      subflags, locator).isFailure())
         return SolutionKind::Error;
 
@@ -5686,7 +5686,7 @@
     kind = ConstraintKind::Subtype;
     break;
   case RequirementKind::SameType:
-    kind = ConstraintKind::Equal;
+    kind = ConstraintKind::Bind;
     break;
   case RequirementKind::Layout:
     // Only a class constraint can be modeled as a constraint, and only that can
diff --git a/lib/Sema/ConstraintSystem.cpp b/lib/Sema/ConstraintSystem.cpp
index e855bc4..b28f58e 100644
--- a/lib/Sema/ConstraintSystem.cpp
+++ b/lib/Sema/ConstraintSystem.cpp
@@ -442,7 +442,7 @@
         cast<GenericTypeParamType>(pair.first));
       assert(found != replacements.end() &&
              "Missing generic parameter?");
-      addConstraint(ConstraintKind::Equal, found->second, pair.second,
+      addConstraint(ConstraintKind::Bind, found->second, pair.second,
                     locator);
     }
   }
@@ -1148,7 +1148,7 @@
   }
 
   // Otherwise, the types must be equivalent.
-  cs.addConstraint(ConstraintKind::Equal, objectTy, selfTy,
+  cs.addConstraint(ConstraintKind::Bind, objectTy, selfTy,
                    cs.getConstraintLocator(locator));
 }
 
@@ -1321,7 +1321,7 @@
     // For a protocol, substitute the base object directly. We don't need a
     // conformance constraint because we wouldn't have found the declaration
     // if it didn't conform.
-    addConstraint(ConstraintKind::Equal, baseOpenedTy, selfObjTy,
+    addConstraint(ConstraintKind::Bind, baseOpenedTy, selfObjTy,
                   getConstraintLocator(locator));
   } else if (!isDynamicResult) {
     addSelfConstraint(*this, baseOpenedTy, selfObjTy, locator);
@@ -1846,7 +1846,7 @@
     auto elementObjTy = createTypeVariable(
         getConstraintLocator(locator, ConstraintLocator::FunctionArgument));
     addConstraint(ConstraintKind::Equal, elementTy, elementObjTy, locator);
-    
+
     // The element result is an lvalue or rvalue based on the key path class.
     addKeyPathApplicationConstraint(
                   keyPathIndexTy, choice.getBaseType(), elementTy, locator);
diff --git a/lib/Sema/TypeCheckProtocol.cpp b/lib/Sema/TypeCheckProtocol.cpp
index edd1adf..758009d 100644
--- a/lib/Sema/TypeCheckProtocol.cpp
+++ b/lib/Sema/TypeCheckProtocol.cpp
@@ -902,7 +902,7 @@
   // Match a type in the requirement to a type in the witness.
   auto matchTypes = [&](Type reqType,
                         Type witnessType) -> Optional<RequirementMatch> {
-    cs->addConstraint(ConstraintKind::Equal, reqType, witnessType, locator);
+    cs->addConstraint(ConstraintKind::Bind, reqType, witnessType, locator);
     // FIXME: Check whether this has already failed.
     return None;
   };
@@ -1274,9 +1274,6 @@
                                         ValueDecl *witness,
                                         bool *isSetter) {
   *isSetter = false;
-  if (TC.Context.isAccessControlDisabled())
-    return false;
-
   AccessScope actualScopeToCheck = getRequiredAccessScope();
 
   // Setting the 'forConformance' flag means that we admit witnesses in
diff --git a/lib/Sema/TypeCheckProtocol.h b/lib/Sema/TypeCheckProtocol.h
index 39d30a8..47266b2 100644
--- a/lib/Sema/TypeCheckProtocol.h
+++ b/lib/Sema/TypeCheckProtocol.h
@@ -497,9 +497,6 @@
   AccessScope getRequiredAccessScope();
 
   bool isUsableFromInlineRequired() {
-    if (TC.Context.isAccessControlDisabled())
-      return false;
-
     assert(RequiredAccessScopeAndUsableFromInline.hasValue() &&
            "must check access first using getRequiredAccessScope");
     return RequiredAccessScopeAndUsableFromInline.getValue().second;
diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp
index 48a7811..00deb8a 100644
--- a/lib/Serialization/Deserialization.cpp
+++ b/lib/Serialization/Deserialization.cpp
@@ -1140,21 +1140,20 @@
   return None;
 }
 
-/// Determine whether the two modules are re-exported to the same module.
-static bool reExportedToSameModule(const ModuleDecl *fromModule,
-                                   const ModuleDecl *toModule) {
+static bool isReExportedToModule(const ValueDecl *value,
+                                 const ModuleDecl *expectedModule) {
+  const DeclContext *valueDC = value->getDeclContext();
   auto fromClangModule
-    = dyn_cast<ClangModuleUnit>(fromModule->getFiles().front());
+      = dyn_cast<ClangModuleUnit>(valueDC->getModuleScopeContext());
   if (!fromClangModule)
     return false;
+  std::string exportedName = fromClangModule->getExportedModuleName();
 
   auto toClangModule
-  = dyn_cast<ClangModuleUnit>(toModule->getFiles().front());
-  if (!toClangModule)
-    return false;
-
-  return fromClangModule->getExportedModuleName() ==
-    toClangModule->getExportedModuleName();
+      = dyn_cast<ClangModuleUnit>(expectedModule->getFiles().front());
+  if (toClangModule)
+    return exportedName == toClangModule->getExportedModuleName();
+  return exportedName == expectedModule->getName().str();
 }
 
 /// Remove values from \p values that don't match the expected type or module.
@@ -1197,7 +1196,7 @@
     // module to the original definition in a base module.
     if (expectedModule && !value->hasClangNode() &&
         value->getModuleContext() != expectedModule &&
-        !reExportedToSameModule(value->getModuleContext(), expectedModule))
+        !isReExportedToModule(value, expectedModule))
       return true;
 
     // If we're expecting a member within a constrained extension with a
@@ -1357,6 +1356,7 @@
       if (entry.Kind != llvm::BitstreamEntry::Record)
         return Identifier();
 
+      scratch.clear();
       unsigned recordID = DeclTypeCursor.readRecord(entry.ID, scratch,
                                                     &blobData);
       switch (recordID) {
diff --git a/stdlib/public/Darwin/AppKit/NSGraphics.swift b/stdlib/public/Darwin/AppKit/NSGraphics.swift
index 6cc836c..f4e2a7c 100644
--- a/stdlib/public/Darwin/AppKit/NSGraphics.swift
+++ b/stdlib/public/Darwin/AppKit/NSGraphics.swift
@@ -181,7 +181,10 @@
 }
 
 extension NSAnimationEffect {
-  private class _CompletionHandlerDelegate : NSObject {
+  // NOTE: older overlays called this class _CompletionHandlerDelegate.
+  // The two must coexist without a conflicting ObjC class name, so it
+  // was renamed. The old name must not be used in the new runtime.
+  private class __CompletionHandlerDelegate : NSObject {
     var completionHandler: () -> Void = { }
     @objc func animationEffectDidEnd(_ contextInfo: UnsafeMutableRawPointer?) {
       completionHandler()
@@ -190,7 +193,7 @@
   @available(swift 4)
   public func show(centeredAt centerLocation: NSPoint, size: NSSize,
                    completionHandler: @escaping () -> Void = { }) {
-    let delegate = _CompletionHandlerDelegate()
+    let delegate = __CompletionHandlerDelegate()
     delegate.completionHandler = completionHandler
     // Note that the delegate of `__NSShowAnimationEffect` is retained for the
     // duration of the animation.
@@ -199,7 +202,7 @@
         centerLocation,
         size,
         delegate,
-        #selector(_CompletionHandlerDelegate.animationEffectDidEnd(_:)),
+        #selector(__CompletionHandlerDelegate.animationEffectDidEnd(_:)),
         nil)
   }
 }
diff --git a/stdlib/public/Darwin/Dispatch/Block.swift b/stdlib/public/Darwin/Dispatch/Block.swift
index e3558e4..1f9d8b1 100644
--- a/stdlib/public/Darwin/Dispatch/Block.swift
+++ b/stdlib/public/Darwin/Dispatch/Block.swift
@@ -34,7 +34,12 @@
 	public static let enforceQoS = DispatchWorkItemFlags(rawValue: 0x20)
 }
 
+// NOTE: older overlays had Dispatch.DispatchWorkItem as the ObjC name.
+// The two must coexist, so it was renamed. The old name must not be
+// used in the new runtime. _TtC8Dispatch17_DispatchWorkItem is the
+// mangled name for Dispatch._DispatchWorkItem.
 @available(macOS 10.10, iOS 8.0, *)
+@_objcRuntimeName(_TtC8Dispatch17_DispatchWorkItem)
 public class DispatchWorkItem {
 	internal var _block: _DispatchBlock
 
diff --git a/stdlib/public/Darwin/Foundation/CharacterSet.swift b/stdlib/public/Darwin/Foundation/CharacterSet.swift
index 3161d6a..68df36e 100644
--- a/stdlib/public/Darwin/Foundation/CharacterSet.swift
+++ b/stdlib/public/Darwin/Foundation/CharacterSet.swift
@@ -29,7 +29,10 @@
 
 // MARK: -
 
-fileprivate final class _CharacterSetStorage : Hashable {
+// NOTE: older overlays called this class _CharacterSetStorage.
+// The two must coexist without a conflicting ObjC class name, so it
+// was renamed. The old name must not be used in the new runtime.
+fileprivate final class __CharacterSetStorage : Hashable {
     fileprivate enum Backing {
         case immutable(CFCharacterSet)
         case mutable(CFMutableCharacterSet)
@@ -58,7 +61,7 @@
         }
     }
     
-    fileprivate static func ==(lhs : _CharacterSetStorage, rhs : _CharacterSetStorage) -> Bool {
+    fileprivate static func ==(lhs : __CharacterSetStorage, rhs : __CharacterSetStorage) -> Bool {
         switch (lhs._backing, rhs._backing) {
         case (.immutable(let cs1), .immutable(let cs2)):
             return CFEqual(cs1, cs2)
@@ -73,12 +76,12 @@
     
     // MARK: -
     
-    fileprivate func mutableCopy() -> _CharacterSetStorage {
+    fileprivate func mutableCopy() -> __CharacterSetStorage {
         switch _backing {
         case .immutable(let cs):
-            return _CharacterSetStorage(mutableReference: CFCharacterSetCreateMutableCopy(nil, cs))
+            return __CharacterSetStorage(mutableReference: CFCharacterSetCreateMutableCopy(nil, cs))
         case .mutable(let cs):
-            return _CharacterSetStorage(mutableReference: CFCharacterSetCreateMutableCopy(nil, cs))
+            return __CharacterSetStorage(mutableReference: CFCharacterSetCreateMutableCopy(nil, cs))
         }
     }
 
@@ -223,7 +226,7 @@
     
 
     // When the underlying collection does not have a method to return new CharacterSets with changes applied, so we will copy and apply here
-    private static func _apply(_ lhs : _CharacterSetStorage, _ rhs : _CharacterSetStorage, _ f : (CFMutableCharacterSet, CFCharacterSet) -> ()) -> CharacterSet {
+    private static func _apply(_ lhs : __CharacterSetStorage, _ rhs : __CharacterSetStorage, _ f : (CFMutableCharacterSet, CFCharacterSet) -> ()) -> CharacterSet {
         let copyOfMe : CFMutableCharacterSet
         switch lhs._backing {
         case .immutable(let cs):
@@ -239,10 +242,10 @@
             f(copyOfMe, cs)
         }
         
-        return CharacterSet(_uncopiedStorage: _CharacterSetStorage(mutableReference: copyOfMe))
+        return CharacterSet(_uncopiedStorage: __CharacterSetStorage(mutableReference: copyOfMe))
     }
     
-    private func _applyMutation(_ other : _CharacterSetStorage, _ f : (CFMutableCharacterSet, CFCharacterSet) -> ()) {
+    private func _applyMutation(_ other : __CharacterSetStorage, _ f : (CFMutableCharacterSet, CFCharacterSet) -> ()) {
         switch _backing {
         case .immutable(let cs):
             let r = CFCharacterSetCreateMutableCopy(nil, cs)!
@@ -267,47 +270,47 @@
     fileprivate var inverted : CharacterSet {
         switch _backing {
         case .immutable(let cs):
-            return CharacterSet(_uncopiedStorage: _CharacterSetStorage(immutableReference: CFCharacterSetCreateInvertedSet(nil, cs)))
+            return CharacterSet(_uncopiedStorage: __CharacterSetStorage(immutableReference: CFCharacterSetCreateInvertedSet(nil, cs)))
         case .mutable(let cs):
             // Even if input is mutable, the result is immutable
-            return CharacterSet(_uncopiedStorage: _CharacterSetStorage(immutableReference: CFCharacterSetCreateInvertedSet(nil, cs)))
+            return CharacterSet(_uncopiedStorage: __CharacterSetStorage(immutableReference: CFCharacterSetCreateInvertedSet(nil, cs)))
         }
     }
 
-    fileprivate func union(_ other: _CharacterSetStorage) -> CharacterSet {
-        return _CharacterSetStorage._apply(self, other, CFCharacterSetUnion)
+    fileprivate func union(_ other: __CharacterSetStorage) -> CharacterSet {
+        return __CharacterSetStorage._apply(self, other, CFCharacterSetUnion)
     }
     
-    fileprivate func formUnion(_ other: _CharacterSetStorage) {
+    fileprivate func formUnion(_ other: __CharacterSetStorage) {
         _applyMutation(other, CFCharacterSetUnion)
     }
     
-    fileprivate func intersection(_ other: _CharacterSetStorage) -> CharacterSet {
-        return _CharacterSetStorage._apply(self, other, CFCharacterSetIntersect)
+    fileprivate func intersection(_ other: __CharacterSetStorage) -> CharacterSet {
+        return __CharacterSetStorage._apply(self, other, CFCharacterSetIntersect)
     }
     
-    fileprivate func formIntersection(_ other: _CharacterSetStorage) {
+    fileprivate func formIntersection(_ other: __CharacterSetStorage) {
         _applyMutation(other, CFCharacterSetIntersect)
     }
     
-    fileprivate func subtracting(_ other: _CharacterSetStorage) -> CharacterSet {
+    fileprivate func subtracting(_ other: __CharacterSetStorage) -> CharacterSet {
         return intersection(other.inverted._storage)
     }
     
-    fileprivate func subtract(_ other: _CharacterSetStorage) {
+    fileprivate func subtract(_ other: __CharacterSetStorage) {
         _applyMutation(other.inverted._storage, CFCharacterSetIntersect)
     }
     
-    fileprivate func symmetricDifference(_ other: _CharacterSetStorage) -> CharacterSet {
+    fileprivate func symmetricDifference(_ other: __CharacterSetStorage) -> CharacterSet {
         return union(other).subtracting(intersection(other))
     }
     
-    fileprivate func formSymmetricDifference(_ other: _CharacterSetStorage) {
+    fileprivate func formSymmetricDifference(_ other: __CharacterSetStorage) {
         // This feels like cheating
         _backing = symmetricDifference(other)._storage._backing
     }
     
-    fileprivate func isSuperset(of other: _CharacterSetStorage) -> Bool {
+    fileprivate func isSuperset(of other: __CharacterSetStorage) -> Bool {
         switch _backing {
         case .immutable(let cs):
             switch other._backing {
@@ -363,35 +366,35 @@
 public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgebra {
     public typealias ReferenceType = NSCharacterSet
     
-    fileprivate var _storage : _CharacterSetStorage
+    fileprivate var _storage : __CharacterSetStorage
     
     // MARK: Init methods
     
     /// Initialize an empty instance.
     public init() {
         // It's unlikely that we are creating an empty character set with no intention to mutate it
-        _storage = _CharacterSetStorage(mutableReference: CFCharacterSetCreateMutable(nil))
+        _storage = __CharacterSetStorage(mutableReference: CFCharacterSetCreateMutable(nil))
     }
     
     /// Initialize with a range of integers.
     ///
     /// It is the caller's responsibility to ensure that the values represent valid `Unicode.Scalar` values, if that is what is desired.
     public init(charactersIn range: Range<Unicode.Scalar>) {
-        _storage = _CharacterSetStorage(immutableReference: CFCharacterSetCreateWithCharactersInRange(nil, _utfRangeToCFRange(range)))
+        _storage = __CharacterSetStorage(immutableReference: CFCharacterSetCreateWithCharactersInRange(nil, _utfRangeToCFRange(range)))
     }
 
     /// Initialize with a closed range of integers.
     ///
     /// It is the caller's responsibility to ensure that the values represent valid `Unicode.Scalar` values, if that is what is desired.
     public init(charactersIn range: ClosedRange<Unicode.Scalar>) {
-        _storage = _CharacterSetStorage(immutableReference: CFCharacterSetCreateWithCharactersInRange(nil, _utfRangeToCFRange(range)))
+        _storage = __CharacterSetStorage(immutableReference: CFCharacterSetCreateWithCharactersInRange(nil, _utfRangeToCFRange(range)))
     }
 
     /// Initialize with the characters in the given string.
     ///
     /// - parameter string: The string content to inspect for characters.
     public init(charactersIn string: __shared String) {
-        _storage = _CharacterSetStorage(immutableReference: CFCharacterSetCreateWithCharactersInString(nil, string as CFString))
+        _storage = __CharacterSetStorage(immutableReference: CFCharacterSetCreateWithCharactersInString(nil, string as CFString))
     }
     
     /// Initialize with a bitmap representation.
@@ -399,7 +402,7 @@
     /// This method is useful for creating a character set object with data from a file or other external data source.
     /// - parameter data: The bitmap representation.
     public init(bitmapRepresentation data: __shared Data) {
-        _storage = _CharacterSetStorage(immutableReference: CFCharacterSetCreateWithBitmapRepresentation(nil, data as CFData))
+        _storage = __CharacterSetStorage(immutableReference: CFCharacterSetCreateWithBitmapRepresentation(nil, data as CFData))
     }
     
     /// Initialize with the contents of a file.
@@ -409,26 +412,26 @@
     public init?(contentsOfFile file: __shared String) {
         do {
             let data = try Data(contentsOf: URL(fileURLWithPath: file), options: .mappedIfSafe)
-            _storage = _CharacterSetStorage(immutableReference: CFCharacterSetCreateWithBitmapRepresentation(nil, data as CFData))
+            _storage = __CharacterSetStorage(immutableReference: CFCharacterSetCreateWithBitmapRepresentation(nil, data as CFData))
         } catch {
             return nil
         }
     }
 
     fileprivate init(_bridged characterSet: __shared NSCharacterSet) {
-        _storage = _CharacterSetStorage(immutableReference: characterSet.copy() as! CFCharacterSet)
+        _storage = __CharacterSetStorage(immutableReference: characterSet.copy() as! CFCharacterSet)
     }
     
     fileprivate init(_uncopiedImmutableReference characterSet: CFCharacterSet) {
-        _storage = _CharacterSetStorage(immutableReference: characterSet)
+        _storage = __CharacterSetStorage(immutableReference: characterSet)
     }
 
-    fileprivate init(_uncopiedStorage : _CharacterSetStorage) {
+    fileprivate init(_uncopiedStorage : __CharacterSetStorage) {
         _storage = _uncopiedStorage
     }
 
     fileprivate init(_builtIn: __shared CFCharacterSetPredefinedSet) {
-        _storage = _CharacterSetStorage(immutableReference: CFCharacterSetGetPredefined(_builtIn))
+        _storage = __CharacterSetStorage(immutableReference: CFCharacterSetGetPredefined(_builtIn))
     }
     
     // MARK: Static functions
diff --git a/stdlib/public/Darwin/Foundation/Data.swift b/stdlib/public/Darwin/Foundation/Data.swift
index 699d334..725245b 100644
--- a/stdlib/public/Darwin/Foundation/Data.swift
+++ b/stdlib/public/Darwin/Foundation/Data.swift
@@ -64,8 +64,11 @@
 
 // Underlying storage representation for medium and large data.
 // Inlinability strategy: methods from here should not inline into InlineSlice or LargeSlice unless trivial.
+// NOTE: older overlays called this class _DataStorage. The two must
+// coexist without a conflicting ObjC class name, so it was renamed.
+// The old name must not be used in the new runtime.
 @usableFromInline
-internal final class _DataStorage {
+internal final class __DataStorage {
     @usableFromInline static let maxSize = Int.max >> 1
     @usableFromInline static let vmOpsThreshold = NSPageSize() * 4
     
@@ -83,7 +86,7 @@
         var dest = dest_
         var source = source_
         var num = num_
-        if _DataStorage.vmOpsThreshold <= num && ((unsafeBitCast(source, to: Int.self) | Int(bitPattern: dest)) & (NSPageSize() - 1)) == 0 {
+        if __DataStorage.vmOpsThreshold <= num && ((unsafeBitCast(source, to: Int.self) | Int(bitPattern: dest)) & (NSPageSize() - 1)) == 0 {
             let pages = NSRoundDownToMultipleOfPageSize(num)
             NSCopyMemoryPages(source!, dest, pages)
             source = source!.advanced(by: pages)
@@ -146,7 +149,7 @@
     
     @inlinable // This is inlinable as trivially computable.
     var isExternallyOwned: Bool {
-        // all _DataStorages will have some sort of capacity, because empty cases hit the .empty enum _Representation
+        // all __DataStorages will have some sort of capacity, because empty cases hit the .empty enum _Representation
         // anything with 0 capacity means that we have not allocated this pointer and concequently mutation is not ours to make.
         return _capacity == 0
     }
@@ -158,8 +161,8 @@
         if newLength == 0 {
             if isExternallyOwned {
                 let newCapacity = malloc_good_size(_length)
-                let newBytes = _DataStorage.allocate(newCapacity, false)
-                _DataStorage.move(newBytes!, _bytes!, _length)
+                let newBytes = __DataStorage.allocate(newCapacity, false)
+                __DataStorage.move(newBytes!, _bytes!, _length)
                 _freeBytes()
                 _bytes = newBytes
                 _capacity = newCapacity
@@ -167,9 +170,9 @@
             }
         } else if isExternallyOwned {
             let newCapacity = malloc_good_size(newLength)
-            let newBytes = _DataStorage.allocate(newCapacity, clear)
+            let newBytes = __DataStorage.allocate(newCapacity, clear)
             if let bytes = _bytes {
-                _DataStorage.move(newBytes!, bytes, _length)
+                __DataStorage.move(newBytes!, bytes, _length)
             }
             _freeBytes()
             _bytes = newBytes
@@ -178,27 +181,27 @@
             _needToZero = true
         } else {
             let cap = _capacity
-            var additionalCapacity = (newLength >> (_DataStorage.vmOpsThreshold <= newLength ? 2 : 1))
+            var additionalCapacity = (newLength >> (__DataStorage.vmOpsThreshold <= newLength ? 2 : 1))
             if Int.max - additionalCapacity < newLength {
                 additionalCapacity = 0
             }
             var newCapacity = malloc_good_size(Swift.max(cap, newLength + additionalCapacity))
             let origLength = _length
-            var allocateCleared = clear && _DataStorage.shouldAllocateCleared(newCapacity)
+            var allocateCleared = clear && __DataStorage.shouldAllocateCleared(newCapacity)
             var newBytes: UnsafeMutableRawPointer? = nil
             if _bytes == nil {
-                newBytes = _DataStorage.allocate(newCapacity, allocateCleared)
+                newBytes = __DataStorage.allocate(newCapacity, allocateCleared)
                 if newBytes == nil {
                     /* Try again with minimum length */
-                    allocateCleared = clear && _DataStorage.shouldAllocateCleared(newLength)
-                    newBytes = _DataStorage.allocate(newLength, allocateCleared)
+                    allocateCleared = clear && __DataStorage.shouldAllocateCleared(newLength)
+                    newBytes = __DataStorage.allocate(newLength, allocateCleared)
                 }
             } else {
                 let tryCalloc = (origLength == 0 || (newLength / origLength) >= 4)
                 if allocateCleared && tryCalloc {
-                    newBytes = _DataStorage.allocate(newCapacity, true)
+                    newBytes = __DataStorage.allocate(newCapacity, true)
                     if let newBytes = newBytes {
-                        _DataStorage.move(newBytes, _bytes!, origLength)
+                        __DataStorage.move(newBytes, _bytes!, origLength)
                         _freeBytes()
                     }
                 }
@@ -206,9 +209,9 @@
                 if newBytes == nil {
                     allocateCleared = false
                     if _deallocator != nil {
-                        newBytes = _DataStorage.allocate(newCapacity, true)
+                        newBytes = __DataStorage.allocate(newCapacity, true)
                         if let newBytes = newBytes {
-                            _DataStorage.move(newBytes, _bytes!, origLength)
+                            __DataStorage.move(newBytes, _bytes!, origLength)
                             _freeBytes()
                         }
                     } else {
@@ -218,11 +221,11 @@
                 /* Try again with minimum length */
                 if newBytes == nil {
                     newCapacity = malloc_good_size(newLength)
-                    allocateCleared = clear && _DataStorage.shouldAllocateCleared(newCapacity)
+                    allocateCleared = clear && __DataStorage.shouldAllocateCleared(newCapacity)
                     if allocateCleared && tryCalloc {
-                        newBytes = _DataStorage.allocate(newCapacity, true)
+                        newBytes = __DataStorage.allocate(newCapacity, true)
                         if let newBytes = newBytes {
-                            _DataStorage.move(newBytes, _bytes!, origLength)
+                            __DataStorage.move(newBytes, _bytes!, origLength)
                             _freeBytes()
                         }
                     }
@@ -293,10 +296,10 @@
             ensureUniqueBufferReference(growingTo: newLength, clear: false)
         }
         _length = newLength
-        _DataStorage.move(_bytes!.advanced(by: origLength), bytes, length)
+        __DataStorage.move(_bytes!.advanced(by: origLength), bytes, length)
     }
     
-    @inlinable // This is @inlinable despite escaping the _DataStorage boundary layer because it is trivially computed.
+    @inlinable // This is @inlinable despite escaping the __DataStorage boundary layer because it is trivially computed.
     func get(_ index: Int) -> UInt8 {
         return _bytes!.advanced(by: index - _offset).assumingMemoryBound(to: UInt8.self).pointee
     }
@@ -364,14 +367,14 @@
 
     @usableFromInline // This is not @inlinable as a non-trivial, non-convenience initializer.
     init(length: Int) {
-        precondition(length < _DataStorage.maxSize)
+        precondition(length < __DataStorage.maxSize)
         var capacity = (length < 1024 * 1024 * 1024) ? length + (length >> 2) : length
-        if _DataStorage.vmOpsThreshold <= capacity {
+        if __DataStorage.vmOpsThreshold <= capacity {
             capacity = NSRoundUpToMultipleOfPageSize(capacity)
         }
         
-        let clear = _DataStorage.shouldAllocateCleared(length)
-        _bytes = _DataStorage.allocate(capacity, clear)!
+        let clear = __DataStorage.shouldAllocateCleared(length)
+        _bytes = __DataStorage.allocate(capacity, clear)!
         _capacity = capacity
         _needToZero = !clear
         _length = 0
@@ -382,12 +385,12 @@
     @usableFromInline // This is not @inlinable as a non-convience initializer.
     init(capacity capacity_: Int = 0) {
         var capacity = capacity_
-        precondition(capacity < _DataStorage.maxSize)
-        if _DataStorage.vmOpsThreshold <= capacity {
+        precondition(capacity < __DataStorage.maxSize)
+        if __DataStorage.vmOpsThreshold <= capacity {
             capacity = NSRoundUpToMultipleOfPageSize(capacity)
         }
         _length = 0
-        _bytes = _DataStorage.allocate(capacity, false)!
+        _bytes = __DataStorage.allocate(capacity, false)!
         _capacity = capacity
         _needToZero = true
         _offset = 0
@@ -395,35 +398,35 @@
     
     @usableFromInline // This is not @inlinable as a non-convience initializer.
     init(bytes: UnsafeRawPointer?, length: Int) {
-        precondition(length < _DataStorage.maxSize)
+        precondition(length < __DataStorage.maxSize)
         _offset = 0
         if length == 0 {
             _capacity = 0
             _length = 0
             _needToZero = false
             _bytes = nil
-        } else if _DataStorage.vmOpsThreshold <= length {
+        } else if __DataStorage.vmOpsThreshold <= length {
             _capacity = length
             _length = length
             _needToZero = true
-            _bytes = _DataStorage.allocate(length, false)!
-            _DataStorage.move(_bytes!, bytes, length)
+            _bytes = __DataStorage.allocate(length, false)!
+            __DataStorage.move(_bytes!, bytes, length)
         } else {
             var capacity = length
-            if _DataStorage.vmOpsThreshold <= capacity {
+            if __DataStorage.vmOpsThreshold <= capacity {
                 capacity = NSRoundUpToMultipleOfPageSize(capacity)
             }
             _length = length
-            _bytes = _DataStorage.allocate(capacity, false)!
+            _bytes = __DataStorage.allocate(capacity, false)!
             _capacity = capacity
             _needToZero = true
-            _DataStorage.move(_bytes!, bytes, length)
+            __DataStorage.move(_bytes!, bytes, length)
         }
     }
     
     @usableFromInline // This is not @inlinable as a non-convience initializer.
     init(bytes: UnsafeMutableRawPointer?, length: Int, copy: Bool, deallocator: ((UnsafeMutableRawPointer, Int) -> Void)?, offset: Int) {
-        precondition(length < _DataStorage.maxSize)
+        precondition(length < __DataStorage.maxSize)
         _offset = offset
         if length == 0 {
             _capacity = 0
@@ -440,25 +443,25 @@
             _needToZero = false
             _bytes = bytes
             _deallocator = deallocator
-        } else if _DataStorage.vmOpsThreshold <= length {
+        } else if __DataStorage.vmOpsThreshold <= length {
             _capacity = length
             _length = length
             _needToZero = true
-            _bytes = _DataStorage.allocate(length, false)!
-            _DataStorage.move(_bytes!, bytes, length)
+            _bytes = __DataStorage.allocate(length, false)!
+            __DataStorage.move(_bytes!, bytes, length)
             if let dealloc = deallocator {
                 dealloc(bytes!, length)
             }
         } else {
             var capacity = length
-            if _DataStorage.vmOpsThreshold <= capacity {
+            if __DataStorage.vmOpsThreshold <= capacity {
                 capacity = NSRoundUpToMultipleOfPageSize(capacity)
             }
             _length = length
-            _bytes = _DataStorage.allocate(capacity, false)!
+            _bytes = __DataStorage.allocate(capacity, false)!
             _capacity = capacity
             _needToZero = true
-            _DataStorage.move(_bytes!, bytes, length)
+            __DataStorage.move(_bytes!, bytes, length)
             if let dealloc = deallocator {
                 dealloc(bytes!, length)
             }
@@ -517,9 +520,9 @@
         _freeBytes()
     }
     
-    @inlinable // This is @inlinable despite escaping the _DataStorage boundary layer because it is trivially computed.
-    func mutableCopy(_ range: Range<Int>) -> _DataStorage {
-        return _DataStorage(bytes: _bytes?.advanced(by: range.lowerBound - _offset), length: range.upperBound - range.lowerBound, copy: true, deallocator: nil, offset: range.lowerBound)
+    @inlinable // This is @inlinable despite escaping the __DataStorage boundary layer because it is trivially computed.
+    func mutableCopy(_ range: Range<Int>) -> __DataStorage {
+        return __DataStorage(bytes: _bytes?.advanced(by: range.lowerBound - _offset), length: range.upperBound - range.lowerBound, copy: true, deallocator: nil, offset: range.lowerBound)
     }
 
     @inlinable // This is @inlinable despite escaping the _DataStorage boundary layer because it is generic and trivially computed.
@@ -541,14 +544,14 @@
     }
 }
 
-// NOTE: older runtimes called this _NSSwiftData. The two must
+// NOTE: older overlays called this _NSSwiftData. The two must
 // coexist, so it was renamed. The old name must not be used in the new
 // runtime.
 internal class __NSSwiftData : NSData {
-    var _backing: _DataStorage!
+    var _backing: __DataStorage!
     var _range: Range<Data.Index>!
 
-    convenience init(backing: _DataStorage, range: Range<Data.Index>) {
+    convenience init(backing: __DataStorage, range: Range<Data.Index>) {
         self.init()
         _backing = backing
         _range = range
@@ -841,7 +844,7 @@
         // ***WARNING***
         // These ivars are specifically laid out so that they cause the enum _Representation to be 16 bytes on 64 bit platforms. This means we _MUST_ have the class type thing last
         @usableFromInline var slice: Range<HalfInt>
-        @usableFromInline var storage: _DataStorage
+        @usableFromInline var storage: __DataStorage
 
         @inlinable // This is @inlinable as trivially computable.
         static func canStore(count: Int) -> Bool {
@@ -851,32 +854,32 @@
         @inlinable // This is @inlinable as a convenience initializer.
         init(_ buffer: UnsafeRawBufferPointer) {
             assert(buffer.count < HalfInt.max)
-            self.init(_DataStorage(bytes: buffer.baseAddress, length: buffer.count), count: buffer.count)
+            self.init(__DataStorage(bytes: buffer.baseAddress, length: buffer.count), count: buffer.count)
         }
 
         @inlinable // This is @inlinable as a convenience initializer.
         init(capacity: Int) {
             assert(capacity < HalfInt.max)
-            self.init(_DataStorage(capacity: capacity), count: 0)
+            self.init(__DataStorage(capacity: capacity), count: 0)
         }
 
         @inlinable // This is @inlinable as a convenience initializer.
         init(count: Int) {
             assert(count < HalfInt.max)
-            self.init(_DataStorage(length: count), count: count)
+            self.init(__DataStorage(length: count), count: count)
         }
 
         @inlinable // This is @inlinable as a convenience initializer.
         init(_ inline: InlineData) {
             assert(inline.count < HalfInt.max)
-            self.init(inline.withUnsafeBytes { return _DataStorage(bytes: $0.baseAddress, length: $0.count) }, count: inline.count)
+            self.init(inline.withUnsafeBytes { return __DataStorage(bytes: $0.baseAddress, length: $0.count) }, count: inline.count)
         }
 
         @inlinable // This is @inlinable as a convenience initializer.
         init(_ inline: InlineData, range: Range<Int>) {
             assert(range.lowerBound < HalfInt.max)
             assert(range.upperBound < HalfInt.max)
-            self.init(inline.withUnsafeBytes { return _DataStorage(bytes: $0.baseAddress, length: $0.count) }, range: range)
+            self.init(inline.withUnsafeBytes { return __DataStorage(bytes: $0.baseAddress, length: $0.count) }, range: range)
         }
 
         @inlinable // This is @inlinable as a convenience initializer.
@@ -894,14 +897,14 @@
         }
 
         @inlinable // This is @inlinable as a trivial initializer.
-        init(_ storage: _DataStorage, count: Int) {
+        init(_ storage: __DataStorage, count: Int) {
             assert(count < HalfInt.max)
             self.storage = storage
             slice = 0..<HalfInt(count)
         }
 
         @inlinable // This is @inlinable as a trivial initializer.
-        init(_ storage: _DataStorage, range: Range<Int>) {
+        init(_ storage: __DataStorage, range: Range<Int>) {
             assert(range.lowerBound < HalfInt.max)
             assert(range.upperBound < HalfInt.max)
             self.storage = storage
@@ -1087,26 +1090,26 @@
         // ***WARNING***
         // These ivars are specifically laid out so that they cause the enum _Representation to be 16 bytes on 64 bit platforms. This means we _MUST_ have the class type thing last
         @usableFromInline var slice: RangeReference
-        @usableFromInline var storage: _DataStorage
+        @usableFromInline var storage: __DataStorage
 
         @inlinable // This is @inlinable as a convenience initializer.
         init(_ buffer: UnsafeRawBufferPointer) {
-            self.init(_DataStorage(bytes: buffer.baseAddress, length: buffer.count), count: buffer.count)
+            self.init(__DataStorage(bytes: buffer.baseAddress, length: buffer.count), count: buffer.count)
         }
 
         @inlinable // This is @inlinable as a convenience initializer.
         init(capacity: Int) {
-            self.init(_DataStorage(capacity: capacity), count: 0)
+            self.init(__DataStorage(capacity: capacity), count: 0)
         }
 
         @inlinable // This is @inlinable as a convenience initializer.
         init(count: Int) {
-            self.init(_DataStorage(length: count), count: count)
+            self.init(__DataStorage(length: count), count: count)
         }
 
         @inlinable // This is @inlinable as a convenience initializer.
         init(_ inline: InlineData) {
-            let storage = inline.withUnsafeBytes { return _DataStorage(bytes: $0.baseAddress, length: $0.count) }
+            let storage = inline.withUnsafeBytes { return __DataStorage(bytes: $0.baseAddress, length: $0.count) }
             self.init(storage, count: inline.count)
         }
 
@@ -1117,7 +1120,7 @@
         }
 
         @inlinable // This is @inlinable as a trivial initializer.
-        init(_ storage: _DataStorage, count: Int) {
+        init(_ storage: __DataStorage, count: Int) {
             self.storage = storage
             self.slice = RangeReference(0..<count)
         }
@@ -1286,7 +1289,7 @@
                 self = .inline(InlineData(buffer))
             } else {
                 let count = buffer.count
-                let storage = _DataStorage(bytes: UnsafeMutableRawPointer(mutating: buffer.baseAddress), length: count, copy: false, deallocator: { _, _ in
+                let storage = __DataStorage(bytes: UnsafeMutableRawPointer(mutating: buffer.baseAddress), length: count, copy: false, deallocator: { _, _ in
                     _fixLifetime(owner)
                 }, offset: 0)
                 if InlineSlice.canStore(count: count) {
@@ -1324,7 +1327,7 @@
         }
 
         @inlinable // This is @inlinable as a trivial initializer.
-        init(_ storage: _DataStorage, count: Int) {
+        init(_ storage: __DataStorage, count: Int) {
             if count == 0 {
                 self = .empty
             } else if InlineData.canStore(count: count) {
@@ -1974,7 +1977,7 @@
             deallocator._deallocator(bytes, count)
             _representation = .empty
         } else {
-            _representation = _Representation(_DataStorage(bytes: bytes, length: count, copy: false, deallocator: whichDeallocator, offset: 0), count: count)
+            _representation = _Representation(__DataStorage(bytes: bytes, length: count, copy: false, deallocator: whichDeallocator, offset: 0), count: count)
         }
     }
     
@@ -2037,9 +2040,9 @@
             let providesConcreteBacking = (reference as AnyObject)._providesConcreteBacking?() ?? false
 #endif
             if providesConcreteBacking {
-                _representation = _Representation(_DataStorage(immutableReference: reference.copy() as! NSData, offset: 0), count: length)
+                _representation = _Representation(__DataStorage(immutableReference: reference.copy() as! NSData, offset: 0), count: length)
             } else {
-                _representation = _Representation(_DataStorage(customReference: reference.copy() as! NSData, offset: 0), count: length)
+                _representation = _Representation(__DataStorage(customReference: reference.copy() as! NSData, offset: 0), count: length)
             }
         }
         
diff --git a/stdlib/public/Darwin/Foundation/JSONEncoder.swift b/stdlib/public/Darwin/Foundation/JSONEncoder.swift
index 8f90826..e5811a0 100644
--- a/stdlib/public/Darwin/Foundation/JSONEncoder.swift
+++ b/stdlib/public/Darwin/Foundation/JSONEncoder.swift
@@ -51,6 +51,11 @@
 //===----------------------------------------------------------------------===//
 
 /// `JSONEncoder` facilitates the encoding of `Encodable` values into JSON.
+// NOTE: older overlays had Foundation.JSONEncoder as the ObjC name.
+// The two must coexist, so it was renamed. The old name must not be
+// used in the new runtime. _TtC10Foundation12_JSONEncoder is the
+// mangled name for Foundation._JSONEncoder.
+@_objcRuntimeName(_TtC10Foundation12_JSONEncoder)
 open class JSONEncoder {
     // MARK: Options
 
@@ -245,7 +250,7 @@
     /// - throws: `EncodingError.invalidValue` if a non-conforming floating-point value is encountered during encoding, and the encoding strategy is `.throw`.
     /// - throws: An error if any value throws an error during encoding.
     open func encode<T : Encodable>(_ value: T) throws -> Data {
-        let encoder = _JSONEncoder(options: self.options)
+        let encoder = __JSONEncoder(options: self.options)
 
         guard let topLevel = try encoder.box_(value) else {
             throw EncodingError.invalidValue(value, 
@@ -273,9 +278,12 @@
     }
 }
 
-// MARK: - _JSONEncoder
+// MARK: - __JSONEncoder
 
-fileprivate class _JSONEncoder : Encoder {
+// NOTE: older overlays called this class _JSONEncoder.
+// The two must coexist without a conflicting ObjC class name, so it
+// was renamed. The old name must not be used in the new runtime.
+fileprivate class __JSONEncoder : Encoder {
     // MARK: Properties
 
     /// The encoder's storage.
@@ -405,7 +413,7 @@
     // MARK: Properties
 
     /// A reference to the encoder we're writing to.
-    private let encoder: _JSONEncoder
+    private let encoder: __JSONEncoder
 
     /// A reference to the container we're writing to.
     private let container: NSMutableDictionary
@@ -416,7 +424,7 @@
     // MARK: - Initialization
 
     /// Initializes `self` with the given references.
-    fileprivate init(referencing encoder: _JSONEncoder, codingPath: [CodingKey], wrapping container: NSMutableDictionary) {
+    fileprivate init(referencing encoder: __JSONEncoder, codingPath: [CodingKey], wrapping container: NSMutableDictionary) {
         self.encoder = encoder
         self.codingPath = codingPath
         self.container = container
@@ -519,11 +527,11 @@
     }
 
     public mutating func superEncoder() -> Encoder {
-        return _JSONReferencingEncoder(referencing: self.encoder, key: _JSONKey.super, convertedKey: _converted(_JSONKey.super), wrapping: self.container)
+        return __JSONReferencingEncoder(referencing: self.encoder, key: _JSONKey.super, convertedKey: _converted(_JSONKey.super), wrapping: self.container)
     }
 
     public mutating func superEncoder(forKey key: Key) -> Encoder {
-        return _JSONReferencingEncoder(referencing: self.encoder, key: key, convertedKey: _converted(key), wrapping: self.container)
+        return __JSONReferencingEncoder(referencing: self.encoder, key: key, convertedKey: _converted(key), wrapping: self.container)
     }
 }
 
@@ -531,7 +539,7 @@
     // MARK: Properties
 
     /// A reference to the encoder we're writing to.
-    private let encoder: _JSONEncoder
+    private let encoder: __JSONEncoder
 
     /// A reference to the container we're writing to.
     private let container: NSMutableArray
@@ -547,7 +555,7 @@
     // MARK: - Initialization
 
     /// Initializes `self` with the given references.
-    fileprivate init(referencing encoder: _JSONEncoder, codingPath: [CodingKey], wrapping container: NSMutableArray) {
+    fileprivate init(referencing encoder: __JSONEncoder, codingPath: [CodingKey], wrapping container: NSMutableArray) {
         self.encoder = encoder
         self.codingPath = codingPath
         self.container = container
@@ -610,11 +618,11 @@
     }
 
     public mutating func superEncoder() -> Encoder {
-        return _JSONReferencingEncoder(referencing: self.encoder, at: self.container.count, wrapping: self.container)
+        return __JSONReferencingEncoder(referencing: self.encoder, at: self.container.count, wrapping: self.container)
     }
 }
 
-extension _JSONEncoder : SingleValueEncodingContainer {
+extension __JSONEncoder : SingleValueEncodingContainer {
     // MARK: - SingleValueEncodingContainer Methods
 
     fileprivate func assertCanEncodeNewValue() {
@@ -704,7 +712,7 @@
 
 // MARK: - Concrete Value Representations
 
-extension _JSONEncoder {
+extension __JSONEncoder {
     /// Returns the given value boxed in a container appropriate for pushing onto the container stack.
     fileprivate func box(_ value: Bool)   -> NSObject { return NSNumber(value: value) }
     fileprivate func box(_ value: Int)    -> NSObject { return NSNumber(value: value) }
@@ -902,7 +910,7 @@
             return try self.box(value as! [String : Encodable])
         }
 
-        // The value should request a container from the _JSONEncoder.
+        // The value should request a container from the __JSONEncoder.
         let depth = self.storage.count
         do {
             try value.encode(to: self)
@@ -924,11 +932,14 @@
     }
 }
 
-// MARK: - _JSONReferencingEncoder
+// MARK: - __JSONReferencingEncoder
 
-/// _JSONReferencingEncoder is a special subclass of _JSONEncoder which has its own storage, but references the contents of a different encoder.
+/// __JSONReferencingEncoder is a special subclass of __JSONEncoder which has its own storage, but references the contents of a different encoder.
 /// It's used in superEncoder(), which returns a new encoder for encoding a superclass -- the lifetime of the encoder should not escape the scope it's created in, but it doesn't necessarily know when it's done being used (to write to the original container).
-fileprivate class _JSONReferencingEncoder : _JSONEncoder {
+// NOTE: older overlays called this class _JSONReferencingEncoder.
+// The two must coexist without a conflicting ObjC class name, so it
+// was renamed. The old name must not be used in the new runtime.
+fileprivate class __JSONReferencingEncoder : __JSONEncoder {
     // MARK: Reference types.
 
     /// The type of container we're referencing.
@@ -943,7 +954,7 @@
     // MARK: - Properties
 
     /// The encoder we're referencing.
-    fileprivate let encoder: _JSONEncoder
+    fileprivate let encoder: __JSONEncoder
 
     /// The container reference itself.
     private let reference: Reference
@@ -951,7 +962,7 @@
     // MARK: - Initialization
 
     /// Initializes `self` by referencing the given array container in the given encoder.
-    fileprivate init(referencing encoder: _JSONEncoder, at index: Int, wrapping array: NSMutableArray) {
+    fileprivate init(referencing encoder: __JSONEncoder, at index: Int, wrapping array: NSMutableArray) {
         self.encoder = encoder
         self.reference = .array(array, index)
         super.init(options: encoder.options, codingPath: encoder.codingPath)
@@ -960,7 +971,7 @@
     }
 
     /// Initializes `self` by referencing the given dictionary container in the given encoder.
-    fileprivate init(referencing encoder: _JSONEncoder,
+    fileprivate init(referencing encoder: __JSONEncoder,
                      key: CodingKey, convertedKey: __shared CodingKey, wrapping dictionary: NSMutableDictionary) {
         self.encoder = encoder
         self.reference = .dictionary(dictionary, convertedKey.stringValue)
@@ -1004,6 +1015,11 @@
 //===----------------------------------------------------------------------===//
 
 /// `JSONDecoder` facilitates the decoding of JSON into semantic `Decodable` types.
+// NOTE: older overlays had Foundation.JSONDecoder as the ObjC name.
+// The two must coexist, so it was renamed. The old name must not be
+// used in the new runtime. _TtC10Foundation12_JSONDecoder is the
+// mangled name for Foundation._JSONDecoder.
+@_objcRuntimeName(_TtC10Foundation12_JSONDecoder)
 open class JSONDecoder {
     // MARK: Options
 
diff --git a/stdlib/public/Darwin/Foundation/NSDictionary.swift b/stdlib/public/Darwin/Foundation/NSDictionary.swift
index 2b5b58b..90be2e4 100644
--- a/stdlib/public/Darwin/Foundation/NSDictionary.swift
+++ b/stdlib/public/Darwin/Foundation/NSDictionary.swift
@@ -348,6 +348,11 @@
 extension NSDictionary : Sequence {
   // FIXME: A class because we can't pass a struct with class fields through an
   // [objc] interface without prematurely destroying the references.
+  // NOTE: older runtimes had
+  // _TtCE10FoundationCSo12NSDictionary8Iterator as the ObjC name. The
+  // two must coexist, so it was renamed. The old name must not be used
+  // in the new runtime.
+  @_objcRuntimeName(_TtCE10FoundationCSo12NSDictionary9_Iterator)
   final public class Iterator : IteratorProtocol {
     var _fastIterator: NSFastEnumerationIterator
     var _dictionary: NSDictionary {
diff --git a/stdlib/public/Darwin/Foundation/NSError.swift b/stdlib/public/Darwin/Foundation/NSError.swift
index 6c4c212..57a2385 100644
--- a/stdlib/public/Darwin/Foundation/NSError.swift
+++ b/stdlib/public/Darwin/Foundation/NSError.swift
@@ -74,7 +74,10 @@
 /// Class that implements the informal protocol
 /// NSErrorRecoveryAttempting, which is used by NSError when it
 /// attempts recovery from an error.
-class _NSErrorRecoveryAttempter {
+// NOTE: older overlays called this class _NSErrorRecoveryAttempter.
+// The two must coexist without a conflicting ObjC class name, so it
+// was renamed. The old name must not be used in the new runtime.
+class __NSErrorRecoveryAttempter {
   @objc(attemptRecoveryFromError:optionIndex:delegate:didRecoverSelector:contextInfo:)
   func attemptRecovery(fromError nsError: NSError,
                        optionIndex recoveryOptionIndex: Int,
@@ -252,7 +255,7 @@
 
           case NSRecoveryAttempterErrorKey:
             if error is RecoverableError {
-              return _NSErrorRecoveryAttempter()
+              return __NSErrorRecoveryAttempter()
             }
             return nil
 
@@ -308,7 +311,7 @@
      let recoverableError = error as? RecoverableError {
     result[NSLocalizedRecoveryOptionsErrorKey] =
       recoverableError.recoveryOptions
-    result[NSRecoveryAttempterErrorKey] = _NSErrorRecoveryAttempter()
+    result[NSRecoveryAttempterErrorKey] = __NSErrorRecoveryAttempter()
   }
 
   return result as AnyObject
diff --git a/stdlib/public/Darwin/Foundation/PlistEncoder.swift b/stdlib/public/Darwin/Foundation/PlistEncoder.swift
index 151f275..8480c85 100644
--- a/stdlib/public/Darwin/Foundation/PlistEncoder.swift
+++ b/stdlib/public/Darwin/Foundation/PlistEncoder.swift
@@ -15,6 +15,11 @@
 //===----------------------------------------------------------------------===//
 
 /// `PropertyListEncoder` facilitates the encoding of `Encodable` values into property lists.
+// NOTE: older overlays had Foundation.PropertyListEncoder as the ObjC
+// name. The two must coexist, so it was renamed. The old name must not
+// be used in the new runtime. _TtC10Foundation20_PropertyListEncoder
+// is the mangled name for Foundation._PropertyListEncoder.
+@_objcRuntimeName(_TtC10Foundation20_PropertyListEncoder)
 open class PropertyListEncoder {
 
     // MARK: - Options
@@ -80,7 +85,7 @@
     /// - throws: `EncodingError.invalidValue` if a non-conforming floating-point value is encountered during encoding, and the encoding strategy is `.throw`.
     /// - throws: An error if any value throws an error during encoding.
     internal func encodeToTopLevelContainer<Value : Encodable>(_ value: Value) throws -> Any {
-        let encoder = _PlistEncoder(options: self.options)
+        let encoder = __PlistEncoder(options: self.options)
         guard let topLevel = try encoder.box_(value) else {
             throw EncodingError.invalidValue(value,
                                              EncodingError.Context(codingPath: [],
@@ -91,9 +96,12 @@
     }
 }
 
-// MARK: - _PlistEncoder
+// MARK: - __PlistEncoder
 
-fileprivate class _PlistEncoder : Encoder {
+// NOTE: older overlays called this class _PlistEncoder. The two must
+// coexist without a conflicting ObjC class name, so it was renamed.
+// The old name must not be used in the new runtime.
+fileprivate class __PlistEncoder : Encoder {
     // MARK: Properties
 
     /// The encoder's storage.
@@ -223,7 +231,7 @@
     // MARK: Properties
 
     /// A reference to the encoder we're writing to.
-    private let encoder: _PlistEncoder
+    private let encoder: __PlistEncoder
 
     /// A reference to the container we're writing to.
     private let container: NSMutableDictionary
@@ -234,7 +242,7 @@
     // MARK: - Initialization
 
     /// Initializes `self` with the given references.
-    fileprivate init(referencing encoder: _PlistEncoder, codingPath: [CodingKey], wrapping container: NSMutableDictionary) {
+    fileprivate init(referencing encoder: __PlistEncoder, codingPath: [CodingKey], wrapping container: NSMutableDictionary) {
         self.encoder = encoder
         self.codingPath = codingPath
         self.container = container
@@ -285,11 +293,11 @@
     }
 
     public mutating func superEncoder() -> Encoder {
-        return _PlistReferencingEncoder(referencing: self.encoder, at: _PlistKey.super, wrapping: self.container)
+        return __PlistReferencingEncoder(referencing: self.encoder, at: _PlistKey.super, wrapping: self.container)
     }
 
     public mutating func superEncoder(forKey key: Key) -> Encoder {
-        return _PlistReferencingEncoder(referencing: self.encoder, at: key, wrapping: self.container)
+        return __PlistReferencingEncoder(referencing: self.encoder, at: key, wrapping: self.container)
     }
 }
 
@@ -297,7 +305,7 @@
     // MARK: Properties
 
     /// A reference to the encoder we're writing to.
-    private let encoder: _PlistEncoder
+    private let encoder: __PlistEncoder
 
     /// A reference to the container we're writing to.
     private let container: NSMutableArray
@@ -313,7 +321,7 @@
     // MARK: - Initialization
 
     /// Initializes `self` with the given references.
-    fileprivate init(referencing encoder: _PlistEncoder, codingPath: [CodingKey], wrapping container: NSMutableArray) {
+    fileprivate init(referencing encoder: __PlistEncoder, codingPath: [CodingKey], wrapping container: NSMutableArray) {
         self.encoder = encoder
         self.codingPath = codingPath
         self.container = container
@@ -364,11 +372,11 @@
     }
 
     public mutating func superEncoder() -> Encoder {
-        return _PlistReferencingEncoder(referencing: self.encoder, at: self.container.count, wrapping: self.container)
+        return __PlistReferencingEncoder(referencing: self.encoder, at: self.container.count, wrapping: self.container)
     }
 }
 
-extension _PlistEncoder : SingleValueEncodingContainer {
+extension __PlistEncoder : SingleValueEncodingContainer {
     // MARK: - SingleValueEncodingContainer Methods
 
     private func assertCanEncodeNewValue() {
@@ -458,7 +466,7 @@
 
 // MARK: - Concrete Value Representations
 
-extension _PlistEncoder {
+extension __PlistEncoder {
 
     /// Returns the given value boxed in a container appropriate for pushing onto the container stack.
     fileprivate func box(_ value: Bool)   -> NSObject { return NSNumber(value: value) }
@@ -489,7 +497,7 @@
             return (value as! NSData)
         }
 
-        // The value should request a container from the _PlistEncoder.
+        // The value should request a container from the __PlistEncoder.
         let depth = self.storage.count
         do {
             try value.encode(to: self)
@@ -511,11 +519,14 @@
     }
 }
 
-// MARK: - _PlistReferencingEncoder
+// MARK: - __PlistReferencingEncoder
 
-/// _PlistReferencingEncoder is a special subclass of _PlistEncoder which has its own storage, but references the contents of a different encoder.
+/// __PlistReferencingEncoder is a special subclass of __PlistEncoder which has its own storage, but references the contents of a different encoder.
 /// It's used in superEncoder(), which returns a new encoder for encoding a superclass -- the lifetime of the encoder should not escape the scope it's created in, but it doesn't necessarily know when it's done being used (to write to the original container).
-fileprivate class _PlistReferencingEncoder : _PlistEncoder {
+// NOTE: older overlays called this class _PlistReferencingEncoder.
+// The two must coexist without a conflicting ObjC class name, so it
+// was renamed. The old name must not be used in the new runtime.
+fileprivate class __PlistReferencingEncoder : __PlistEncoder {
     // MARK: Reference types.
 
     /// The type of container we're referencing.
@@ -530,7 +541,7 @@
     // MARK: - Properties
 
     /// The encoder we're referencing.
-    private let encoder: _PlistEncoder
+    private let encoder: __PlistEncoder
 
     /// The container reference itself.
     private let reference: Reference
@@ -538,7 +549,7 @@
     // MARK: - Initialization
 
     /// Initializes `self` by referencing the given array container in the given encoder.
-    fileprivate init(referencing encoder: _PlistEncoder, at index: Int, wrapping array: NSMutableArray) {
+    fileprivate init(referencing encoder: __PlistEncoder, at index: Int, wrapping array: NSMutableArray) {
         self.encoder = encoder
         self.reference = .array(array, index)
         super.init(options: encoder.options, codingPath: encoder.codingPath)
@@ -547,7 +558,7 @@
     }
 
     /// Initializes `self` by referencing the given dictionary container in the given encoder.
-    fileprivate init(referencing encoder: _PlistEncoder, at key: CodingKey, wrapping dictionary: NSMutableDictionary) {
+    fileprivate init(referencing encoder: __PlistEncoder, at key: CodingKey, wrapping dictionary: NSMutableDictionary) {
         self.encoder = encoder
         self.reference = .dictionary(dictionary, key.stringValue)
         super.init(options: encoder.options, codingPath: encoder.codingPath)
@@ -590,6 +601,11 @@
 //===----------------------------------------------------------------------===//
 
 /// `PropertyListDecoder` facilitates the decoding of property list values into semantic `Decodable` types.
+// NOTE: older overlays had Foundation.PropertyListDecoder as the ObjC
+// name. The two must coexist, so it was renamed. The old name must not
+// be used in the new runtime. _TtC10Foundation20_PropertyListDecoder
+// is the mangled name for Foundation._PropertyListDecoder.
+@_objcRuntimeName(_TtC10Foundation20_PropertyListDecoder)
 open class PropertyListDecoder {
     // MARK: Options
 
@@ -652,7 +668,7 @@
     /// - throws: `DecodingError.dataCorrupted` if values requested from the payload are corrupted, or if the given data is not a valid property list.
     /// - throws: An error if any value throws an error during decoding.
     internal func decode<T : Decodable>(_ type: T.Type, fromTopLevel container: Any) throws -> T {
-        let decoder = _PlistDecoder(referencing: container, options: self.options)
+        let decoder = __PlistDecoder(referencing: container, options: self.options)
         guard let value = try decoder.unbox(container, as: type) else {
             throw DecodingError.valueNotFound(type, DecodingError.Context(codingPath: [], debugDescription: "The given data did not contain a top-level value."))
         }
@@ -661,9 +677,12 @@
     }
 }
 
-// MARK: - _PlistDecoder
+// MARK: - __PlistDecoder
 
-fileprivate class _PlistDecoder : Decoder {
+// NOTE: older overlays called this class _PlistDecoder. The two must
+// coexist without a conflicting ObjC class name, so it was renamed.
+// The old name must not be used in the new runtime.
+fileprivate class __PlistDecoder : Decoder {
     // MARK: Properties
 
     /// The decoder's storage.
@@ -769,7 +788,7 @@
     // MARK: Properties
 
     /// A reference to the decoder we're reading from.
-    private let decoder: _PlistDecoder
+    private let decoder: __PlistDecoder
 
     /// A reference to the container we're reading from.
     private let container: [String : Any]
@@ -780,7 +799,7 @@
     // MARK: - Initialization
 
     /// Initializes `self` by referencing the given decoder and container.
-    fileprivate init(referencing decoder: _PlistDecoder, wrapping container: [String : Any]) {
+    fileprivate init(referencing decoder: __PlistDecoder, wrapping container: [String : Any]) {
         self.decoder = decoder
         self.container = container
         self.codingPath = decoder.codingPath
@@ -1072,7 +1091,7 @@
         defer { self.decoder.codingPath.removeLast() }
 
         let value: Any = self.container[key.stringValue] ?? NSNull()
-        return _PlistDecoder(referencing: value, at: self.decoder.codingPath, options: self.decoder.options)
+        return __PlistDecoder(referencing: value, at: self.decoder.codingPath, options: self.decoder.options)
     }
 
     public func superDecoder() throws -> Decoder {
@@ -1088,7 +1107,7 @@
     // MARK: Properties
 
     /// A reference to the decoder we're reading from.
-    private let decoder: _PlistDecoder
+    private let decoder: __PlistDecoder
 
     /// A reference to the container we're reading from.
     private let container: [Any]
@@ -1102,7 +1121,7 @@
     // MARK: - Initialization
 
     /// Initializes `self` by referencing the given decoder and container.
-    fileprivate init(referencing decoder: _PlistDecoder, wrapping container: [Any]) {
+    fileprivate init(referencing decoder: __PlistDecoder, wrapping container: [Any]) {
         self.decoder = decoder
         self.container = container
         self.codingPath = decoder.codingPath
@@ -1434,11 +1453,11 @@
 
         let value = self.container[self.currentIndex]
         self.currentIndex += 1
-        return _PlistDecoder(referencing: value, at: self.decoder.codingPath, options: self.decoder.options)
+        return __PlistDecoder(referencing: value, at: self.decoder.codingPath, options: self.decoder.options)
     }
 }
 
-extension _PlistDecoder : SingleValueDecodingContainer {
+extension __PlistDecoder : SingleValueDecodingContainer {
     // MARK: SingleValueDecodingContainer Methods
 
     private func expectNonNull<T>(_ type: T.Type) throws {
@@ -1533,7 +1552,7 @@
 
 // MARK: - Concrete Value Representations
 
-extension _PlistDecoder {
+extension __PlistDecoder {
     /// Returns the given value unboxed from a container.
     fileprivate func unbox(_ value: Any, as type: Bool.Type) throws -> Bool? {
         if let string = value as? String, string == _plistNull { return nil }
diff --git a/stdlib/public/Darwin/Network/NWConnection.swift b/stdlib/public/Darwin/Network/NWConnection.swift
index 64e2355..8834ed6 100644
--- a/stdlib/public/Darwin/Network/NWConnection.swift
+++ b/stdlib/public/Darwin/Network/NWConnection.swift
@@ -20,6 +20,11 @@
 /// A connection handles establishment of any transport, security, or application-level protocols
 /// required to transmit and receive user data. Multiple protocol instances may be attempted during
 /// the establishment phase of the connection.
+// NOTE: older overlays had Network.NWConnection as the ObjC name.
+// The two must coexist, so it was renamed. The old name must not be
+// used in the new runtime. _TtC7Network13_NWConnection is the
+// mangled name for Network._NWConnection.
+@_objcRuntimeName(_TtC7Network13_NWConnection)
 @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
 public final class NWConnection : CustomDebugStringConvertible {
 
@@ -306,6 +311,8 @@
 	/// Content Context controls options for how data is sent, and access for metadata to send or receive.
 	/// All properties of Content Context are valid for sending. For received Content Context, only the protocolMetadata
 	/// values will be set.
+	// Set the ObjC name of this class to be nested in the customized ObjC name of NWConnection.
+	@_objcRuntimeName(_TtCC7Network13_NWConnection14ContentContext)
 	public class ContentContext {
         internal let nw: nw_content_context_t
 
diff --git a/stdlib/public/Darwin/Network/NWListener.swift b/stdlib/public/Darwin/Network/NWListener.swift
index e12a560..87e0e0a 100644
--- a/stdlib/public/Darwin/Network/NWListener.swift
+++ b/stdlib/public/Darwin/Network/NWListener.swift
@@ -22,6 +22,11 @@
 /// accepted connections will represent multiplexed streams on a new or existing transport
 /// binding.
 
+// NOTE: older overlays had Network.NWListener as the ObjC name.
+// The two must coexist, so it was renamed. The old name must not be
+// used in the new runtime. _TtC7Network11_NWListener is the
+// mangled name for Network._NWListener.
+@_objcRuntimeName(_TtC7Network11_NWListener)
 @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
 public final class NWListener: CustomDebugStringConvertible {
 	public var debugDescription: String {
diff --git a/stdlib/public/Darwin/Network/NWParameters.swift b/stdlib/public/Darwin/Network/NWParameters.swift
index 9880f8b..face2df 100644
--- a/stdlib/public/Darwin/Network/NWParameters.swift
+++ b/stdlib/public/Darwin/Network/NWParameters.swift
@@ -16,6 +16,11 @@
 /// endpoint requirements); preferences for data transfer and quality of service;
 /// and the protocols to be used for a connection along with any protocol-specific
 /// options.
+// NOTE: older overlays had Network.NWParameters as the ObjC name.
+// The two must coexist, so it was renamed. The old name must not be
+// used in the new runtime. _TtC7Network13_NWParameters is the
+// mangled name for Network._NWParameters.
+@_objcRuntimeName(_TtC7Network13_NWParameters)
 @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
 public final class NWParameters : CustomDebugStringConvertible {
 	public var debugDescription: String {
@@ -422,6 +427,9 @@
 	/// transport-level protocol, and an optional internet-level protocol. If the internet-
 	/// level protocol is not specified, any available and applicable IP address family
 	/// may be used.
+  // Set the ObjC name of this class to be nested in the customized ObjC
+  // name of NWParameters.
+	@_objcRuntimeName(_TtCC7Network13_NWParameters13ProtocolStack)
 	public class ProtocolStack {
 		public var applicationProtocols: [NWProtocolOptions] {
 			set {
diff --git a/stdlib/public/Darwin/Network/NWPath.swift b/stdlib/public/Darwin/Network/NWPath.swift
index 437aa0c..000552a 100644
--- a/stdlib/public/Darwin/Network/NWPath.swift
+++ b/stdlib/public/Darwin/Network/NWPath.swift
@@ -225,6 +225,11 @@
 /// The paths will watch the state of multiple interfaces, and allows the
 /// application to enumerate the available interfaces for use in creating connections
 /// or listeners bound to specific interfaces.
+// NOTE: older overlays had Network.NWPathMonitor as the ObjC name.
+// The two must coexist, so it was renamed. The old name must not be
+// used in the new runtime. _TtC7Network14_NWPathMonitor is the
+// mangled name for Network._NWPathMonitor.
+@_objcRuntimeName(_TtC7Network14_NWPathMonitor)
 @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
 public final class NWPathMonitor {
 
diff --git a/stdlib/public/Darwin/Network/NWProtocol.swift b/stdlib/public/Darwin/Network/NWProtocol.swift
index 1512194..f05e30c 100644
--- a/stdlib/public/Darwin/Network/NWProtocol.swift
+++ b/stdlib/public/Darwin/Network/NWProtocol.swift
@@ -12,6 +12,11 @@
 
 /// NWProtocolDefinition is an abstract superclass that represents the identifier of a
 /// protocol that can be used with connections and listeners, such as TCP.
+// NOTE: older overlays had Network.NWProtocolDefinition as the ObjC name.
+// The two must coexist, so it was renamed. The old name must not be
+// used in the new runtime. _TtC7Network21_NWProtocolDefinition is the
+// mangled name for Network._NWProtocolDefinition.
+@_objcRuntimeName(_TtC7Network21_NWProtocolDefinition)
 @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
 public class NWProtocolDefinition : Equatable, CustomDebugStringConvertible {
 	public static func == (lhs: NWProtocolDefinition, rhs: NWProtocolDefinition) -> Bool {
@@ -35,6 +40,11 @@
 /// NWProtocolOptions is an abstract superclass that represents a configuration options
 /// that can be used to add a protocol into an NWParameters.ProtocolStack. These options
 /// configure the behavior of a protocol and cannot be changed after starting a connection.
+// NOTE: older overlays had Network.NWProtocolOptions as the ObjC name.
+// The two must coexist, so it was renamed. The old name must not be
+// used in the new runtime. _TtC7Network18_NWProtocolOptions is the
+// mangled name for Network._NWProtocolOptions.
+@_objcRuntimeName(_TtC7Network18_NWProtocolOptions)
 @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
 public class NWProtocolOptions {
 	internal let nw: nw_protocol_options_t
@@ -50,6 +60,11 @@
 /// specific to some content being sent; as well as to retrieve metadata specific to some
 /// content that was received. Each protocol is responsible for defining its own accessor
 /// functions to set and get metadata.
+// NOTE: older overlays had Network.NWProtocolMetadata as the ObjC name.
+// The two must coexist, so it was renamed. The old name must not be
+// used in the new runtime. _TtC7Network19_NWProtocolMetadata is the
+// mangled name for Network._NWProtocolMetadata.
+@_objcRuntimeName(_TtC7Network19_NWProtocolMetadata)
 @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
 public class NWProtocolMetadata {
 	internal let nw: nw_protocol_metadata_t
@@ -60,6 +75,11 @@
 }
 
 /// NWProtocol is an abstract superclass to which protocol implementations conform.
+// NOTE: older overlays had Network.NWProtocol as the ObjC name.
+// The two must coexist, so it was renamed. The old name must not be
+// used in the new runtime. _TtC7Network11_NWProtocol is the
+// mangled name for Network._NWProtocol.
+@_objcRuntimeName(_TtC7Network11_NWProtocol)
 @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
 public class NWProtocol {
 
diff --git a/stdlib/public/Darwin/Network/NWProtocolIP.swift b/stdlib/public/Darwin/Network/NWProtocolIP.swift
index 45c78f2..1e585bb 100644
--- a/stdlib/public/Darwin/Network/NWProtocolIP.swift
+++ b/stdlib/public/Darwin/Network/NWProtocolIP.swift
@@ -10,12 +10,20 @@
 //
 //===----------------------------------------------------------------------===//
 
+// NOTE: older overlays had Network.NWProtocolIP as the ObjC name.
+// The two must coexist, so it was renamed. The old name must not be
+// used in the new runtime. _TtC7Network13_NWProtocolIP is the
+// mangled name for Network._NWProtocolIP.
+@_objcRuntimeName(_TtC7Network13_NWProtocolIP)
 @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
 public class NWProtocolIP : NWProtocol {
 	public static let definition: NWProtocolDefinition = {
 		NWProtocolDefinition(nw_protocol_copy_ip_definition(), "ip")
 	}()
 
+  // Set the ObjC name of this class to be nested in the customized ObjC
+  // name of NWProtocolIP.
+  @_objcRuntimeName(_TtCC7Network13_NWProtocolIP7Options)
 	public class Options : NWProtocolOptions {
 		public enum Version {
 			/// Allow any IP version
@@ -167,6 +175,9 @@
 	}
 
 	/// IP Metadata can be sent or received as part of ContentContext
+  // Set the ObjC name of this class to be nested in the customized ObjC
+  // name of NWProtocolIP.
+  @_objcRuntimeName(_TtCC7Network13_NWProtocolIP8Metadata)
 	public class Metadata: NWProtocolMetadata {
 		/// Set ECN flags to be sent on a packet, or get ECN flags
 		/// received on a packet. These flags will not take effect
diff --git a/stdlib/public/Darwin/Network/NWProtocolTCP.swift b/stdlib/public/Darwin/Network/NWProtocolTCP.swift
index d85d5d7..f7968eb 100644
--- a/stdlib/public/Darwin/Network/NWProtocolTCP.swift
+++ b/stdlib/public/Darwin/Network/NWProtocolTCP.swift
@@ -10,12 +10,20 @@
 //
 //===----------------------------------------------------------------------===//
 
+// NOTE: older overlays had Network.NWProtocolTCP as the ObjC name.
+// The two must coexist, so it was renamed. The old name must not be
+// used in the new runtime. _TtC7Network14_NWProtocolTCP is the
+// mangled name for Network._NWProtocolTCP.
+@_objcRuntimeName(_TtC7Network14_NWProtocolTCP)
 @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
 public class NWProtocolTCP : NWProtocol {
 	public static let definition: NWProtocolDefinition = {
 		NWProtocolDefinition(nw_protocol_copy_tcp_definition(), "tcp")
 	}()
 
+  // Set the ObjC name of this class to be nested in the customized ObjC
+  // name of NWProtocolTCP.
+  @_objcRuntimeName(_TtCC7Network14_NWProtocolTCP7Options)
 	public class Options : NWProtocolOptions {
 
 		private var _noDelay: Bool = false
@@ -244,6 +252,9 @@
 
 	/// Access TCP metadata using NWConnection.metadata(protocolDefinition: NWProtocolTCP.definition)
 	/// or in received ContentContext
+  // Set the ObjC name of this class to be nested in the customized ObjC
+  // name of NWProtocolTCP.
+  @_objcRuntimeName(_TtCC7Network14_NWProtocolTCP8Metadata)
 	public class Metadata: NWProtocolMetadata {
 		override internal init(_ nw: nw_protocol_metadata_t) {
 			super.init(nw)
diff --git a/stdlib/public/Darwin/Network/NWProtocolTLS.swift b/stdlib/public/Darwin/Network/NWProtocolTLS.swift
index beb21fa..0522d8d 100644
--- a/stdlib/public/Darwin/Network/NWProtocolTLS.swift
+++ b/stdlib/public/Darwin/Network/NWProtocolTLS.swift
@@ -10,12 +10,20 @@
 //
 //===----------------------------------------------------------------------===//
 
+// NOTE: older overlays had Network.NWProtocolTLS as the ObjC name.
+// The two must coexist, so it was renamed. The old name must not be
+// used in the new runtime. _TtC7Network14_NWProtocolTLS is the
+// mangled name for Network._NWProtocolTLS.
+@_objcRuntimeName(_TtC7Network14_NWProtocolTLS)
 @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
 public class NWProtocolTLS : NWProtocol {
 	public static let definition: NWProtocolDefinition = {
 		NWProtocolDefinition(nw_protocol_copy_tls_definition(), "tls")
 	}()
 
+  // Set the ObjC name of this class to be nested in the customized ObjC
+  // name of NWProtocolTLS.
+  @_objcRuntimeName(_TtCC7Network14_NWProtocolTLS7Options)
 	public class Options : NWProtocolOptions {
 		/// Access the sec_protocol_options_t for a given network protocol
 		/// options instance. See <Security/SecProtocolOptions.h> for functions
@@ -36,6 +44,9 @@
 
 	/// Access TLS metadata using NWConnection.metadata(protocolDefinition: NWProtocolTLS.definition)
 	/// or in received ContentContext
+  // Set the ObjC name of this class to be nested in the customized ObjC
+  // name of NWNWProtocolTLSProtocolIP.
+  @_objcRuntimeName(_TtCC7Network14_NWProtocolTLS8Metadata)
 	public class Metadata: NWProtocolMetadata {
 		/// Access the sec_protocol_metadata_t for a given network protocol
 		/// metadata instance. See <Security/SecProtocolMetadata.h> for functions
diff --git a/stdlib/public/Darwin/Network/NWProtocolUDP.swift b/stdlib/public/Darwin/Network/NWProtocolUDP.swift
index fe77087..7f345d7 100644
--- a/stdlib/public/Darwin/Network/NWProtocolUDP.swift
+++ b/stdlib/public/Darwin/Network/NWProtocolUDP.swift
@@ -10,12 +10,20 @@
 //
 //===----------------------------------------------------------------------===//
 
+// NOTE: older overlays had Network.NWProtocolUDP as the ObjC name.
+// The two must coexist, so it was renamed. The old name must not be
+// used in the new runtime. _TtC7Network14_NWProtocolUDP is the
+// mangled name for Network._NWProtocolUDP.
+@_objcRuntimeName(_TtC7Network14_NWProtocolUDP)
 @available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
 public class NWProtocolUDP : NWProtocol {
 	public static let definition: NWProtocolDefinition = {
 		NWProtocolDefinition(nw_protocol_copy_udp_definition(), "udp")
 	}()
 
+  // Set the ObjC name of this class to be nested in the customized ObjC
+  // name of NWProtocolUDP.
+  @_objcRuntimeName(_TtCC7Network14_NWProtocolUDP7Options)
 	public class Options : NWProtocolOptions {
 
 		private var _preferNoChecksum: Bool = false
@@ -42,7 +50,10 @@
 		}
 	}
 
-    public class Metadata: NWProtocolMetadata {
+  // Set the ObjC name of this class to be nested in the customized ObjC
+  // name of NWProtocolUDP.
+  @_objcRuntimeName(_TtCC7Network14_NWProtocolUDP8Metadata)
+  public class Metadata: NWProtocolMetadata {
 		override internal init(_ nw: nw_protocol_metadata_t) {
 			super.init(nw)
 		}
diff --git a/stdlib/public/Darwin/SpriteKit/SpriteKit.swift b/stdlib/public/Darwin/SpriteKit/SpriteKit.swift
index aa6fd22..6b78367 100644
--- a/stdlib/public/Darwin/SpriteKit/SpriteKit.swift
+++ b/stdlib/public/Darwin/SpriteKit/SpriteKit.swift
@@ -25,7 +25,7 @@
 // since that method only exists in a private header in SpriteKit, the lookup
 // mechanism by default fails to accept it as a valid AnyObject call
 //
-// NOTE: older runtimes called this _SpriteKitMethodProvider. The two must
+// NOTE: older overlays called this _SpriteKitMethodProvider. The two must
 // coexist, so it was renamed. The old name must not be used in the new
 // runtime.
 @objc class __SpriteKitMethodProvider : NSObject {
diff --git a/stdlib/public/core/BridgingBuffer.swift b/stdlib/public/core/BridgingBuffer.swift
index 34d0c3e..c3d0613 100644
--- a/stdlib/public/core/BridgingBuffer.swift
+++ b/stdlib/public/core/BridgingBuffer.swift
@@ -15,7 +15,10 @@
   internal var count: Int
 }
 
-internal final class _BridgingBufferStorage
+// NOTE: older runtimes called this class _BridgingBufferStorage.
+// The two must coexist without a conflicting ObjC class name, so it
+// was renamed. The old name must not be used in the new runtime.
+internal final class __BridgingBufferStorage
   : ManagedBuffer<_BridgingBufferHeader, AnyObject> {
 }
 
@@ -26,7 +29,7 @@
 where Header == _BridgingBufferHeader, Element == AnyObject {
   internal init(_ count: Int) {
     self.init(
-      _uncheckedBufferClass: _BridgingBufferStorage.self,
+      _uncheckedBufferClass: __BridgingBufferStorage.self,
       minimumCapacity: count)
     self.withUnsafeMutablePointerToHeader {
       $0.initialize(to: Header(count))
diff --git a/stdlib/public/core/CTypes.swift b/stdlib/public/core/CTypes.swift
index bdbe228..2a2a67b 100644
--- a/stdlib/public/core/CTypes.swift
+++ b/stdlib/public/core/CTypes.swift
@@ -219,15 +219,15 @@
 }
 
 /// A wrapper around a C `va_list` pointer.
-#if arch(arm64) && os(Linux)
+#if arch(arm64) && !(os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Windows))
 @_fixed_layout
 public struct CVaListPointer {
   @usableFromInline // unsafe-performance
-  internal var value: (__stack: UnsafeMutablePointer<Int>?,
-                       __gr_top: UnsafeMutablePointer<Int>?,
-                       __vr_top: UnsafeMutablePointer<Int>?,
-                       __gr_off: Int32,
-                       __vr_off: Int32)
+  internal var _value: (__stack: UnsafeMutablePointer<Int>?,
+                        __gr_top: UnsafeMutablePointer<Int>?,
+                        __vr_top: UnsafeMutablePointer<Int>?,
+                        __gr_off: Int32,
+                        __vr_off: Int32)
 
   @inlinable // unsafe-performance
   public // @testable
@@ -236,7 +236,17 @@
        __vr_top: UnsafeMutablePointer<Int>?,
        __gr_off: Int32,
        __vr_off: Int32) {
-    value = (__stack, __gr_top, __vr_top, __gr_off, __vr_off)
+    _value = (__stack, __gr_top, __vr_top, __gr_off, __vr_off)
+  }
+}
+
+extension CVaListPointer : CustomDebugStringConvertible {
+  public var debugDescription: String {
+    return "(\(_value.__stack.debugDescription), " +
+           "\(_value.__gr_top.debugDescription), " +
+           "\(_value.__vr_top.debugDescription), " +
+           "\(_value.__gr_off), " +
+           "\(_value.__vr_off))"
   }
 }
 
diff --git a/stdlib/public/core/Codable.swift.gyb b/stdlib/public/core/Codable.swift.gyb
index ee0dd97..d33c4d1 100644
--- a/stdlib/public/core/Codable.swift.gyb
+++ b/stdlib/public/core/Codable.swift.gyb
@@ -1767,6 +1767,40 @@
   }
 }
 
+extension ContiguousArray : Encodable where Element : Encodable {
+  /// Encodes the elements of this contiguous array into the given encoder
+  /// in an unkeyed container.
+  ///
+  /// This function throws an error if any values are invalid for the given
+  /// encoder's format.
+  ///
+  /// - Parameter encoder: The encoder to write data to.
+  public func encode(to encoder: Encoder) throws {
+    var container = encoder.unkeyedContainer()
+    for element in self {
+      try container.encode(element)
+    }
+  }
+}
+
+extension ContiguousArray : Decodable where Element : Decodable {
+  /// Creates a new contiguous array by decoding from the given decoder.
+  ///
+  /// This initializer throws an error if reading from the decoder fails, or
+  /// if the data read is corrupted or otherwise invalid.
+  ///
+  /// - Parameter decoder: The decoder to read data from.
+  public init(from decoder: Decoder) throws {
+    self.init()
+
+    var container = try decoder.unkeyedContainer()
+    while !container.isAtEnd {
+      let element = try container.decode(Element.self)
+      self.append(element)
+    }
+  }
+}
+
 extension Set : Encodable where Element : Encodable {
   /// Encodes the elements of this set into the given encoder in an unkeyed
   /// container.
diff --git a/stdlib/public/core/Dictionary.swift b/stdlib/public/core/Dictionary.swift
index 9f0a733..b1b8bd1 100644
--- a/stdlib/public/core/Dictionary.swift
+++ b/stdlib/public/core/Dictionary.swift
@@ -40,7 +40,7 @@
 //       /
 //      |
 //      V
-//   class _RawDictionaryStorage
+//   class __RawDictionaryStorage
 //   +-----------------------------------------------------------+
 //   | <isa>                                                     |
 //   | <refcount>                                                |
@@ -62,7 +62,7 @@
 //   +----------------------------------------------+
 //   | enum Dictionary<K,V>._Variant                |
 //   | +----------------------------------------+   |
-//   | | [ struct _CocoaDictionary              |   |
+//   | | [ struct __CocoaDictionary             |   |
 //   | +---|------------------------------------+   |
 //   +----/-----------------------------------------+
 //       /
@@ -75,9 +75,9 @@
 //   +--------------+
 //     ^
 //     |
-//      \  struct _CocoaDictionary.Index
+//      \  struct __CocoaDictionary.Index
 //   +--|------------------------------------+
-//   |  * base: _CocoaDictionary             |
+//   |  * base: __CocoaDictionary            |
 //   |  allKeys: array of all keys           |
 //   |  currentKeyIndex: index into allKeys  |
 //   +---------------------------------------+
@@ -87,8 +87,8 @@
 // ---------------------------
 //
 // The native backing store is represented by three different classes:
-// * `_RawDictionaryStorage`
-// * `_EmptyDictionarySingleton` (extends Raw)
+// * `__RawDictionaryStorage`
+// * `__EmptyDictionarySingleton` (extends Raw)
 // * `_DictionaryStorage<K: Hashable, V>` (extends Raw)
 //
 // (Hereafter `Raw`, `Empty`, and `Storage`, respectively)
@@ -401,7 +401,7 @@
 
 #if _runtime(_ObjC)
   @inlinable
-  internal init(_cocoa: __owned _CocoaDictionary) {
+  internal init(_cocoa: __owned __CocoaDictionary) {
     _variant = _Variant(cocoa: _cocoa)
   }
 
@@ -422,7 +422,7 @@
       Dictionary can be backed by NSDictionary buffer only when both Key \
       and Value are bridged verbatim to Objective-C
       """)
-    self.init(_cocoa: _CocoaDictionary(_immutableCocoaDictionary))
+    self.init(_cocoa: __CocoaDictionary(_immutableCocoaDictionary))
   }
 #endif
 
@@ -1744,7 +1744,7 @@
     internal enum _Variant {
       case native(_HashTable.Index)
 #if _runtime(_ObjC)
-      case cocoa(_CocoaDictionary.Index)
+      case cocoa(__CocoaDictionary.Index)
 #endif
     }
 
@@ -1766,7 +1766,7 @@
 #if _runtime(_ObjC)
     @inlinable
     @inline(__always)
-    internal init(_cocoa index: __owned _CocoaDictionary.Index) {
+    internal init(_cocoa index: __owned __CocoaDictionary.Index) {
       self.init(_variant: .cocoa(index))
     }
 #endif
@@ -1824,7 +1824,7 @@
 
 #if _runtime(_ObjC)
   @usableFromInline
-  internal var _asCocoa: _CocoaDictionary.Index {
+  internal var _asCocoa: __CocoaDictionary.Index {
     @_transparent
     get {
       switch _variant {
@@ -1925,7 +1925,7 @@
     internal enum _Variant {
       case native(_NativeDictionary<Key, Value>.Iterator)
 #if _runtime(_ObjC)
-      case cocoa(_CocoaDictionary.Iterator)
+      case cocoa(__CocoaDictionary.Iterator)
 #endif
     }
 
@@ -1944,7 +1944,7 @@
 
 #if _runtime(_ObjC)
     @inlinable
-    internal init(_cocoa: __owned _CocoaDictionary.Iterator) {
+    internal init(_cocoa: __owned __CocoaDictionary.Iterator) {
       self.init(_variant: .cocoa(_cocoa))
     }
 #endif
@@ -1998,7 +1998,7 @@
 
 #if _runtime(_ObjC)
   @usableFromInline @_transparent
-  internal var _asCocoa: _CocoaDictionary.Iterator {
+  internal var _asCocoa: __CocoaDictionary.Iterator {
     get {
       switch _variant {
       case .native:
diff --git a/stdlib/public/core/DictionaryBridging.swift b/stdlib/public/core/DictionaryBridging.swift
index f22e00d..23d753a 100644
--- a/stdlib/public/core/DictionaryBridging.swift
+++ b/stdlib/public/core/DictionaryBridging.swift
@@ -35,8 +35,8 @@
     // Temporary var for SOME type safety.
     let nsDictionary: _NSDictionaryCore
 
-    if _storage === _RawDictionaryStorage.empty || count == 0 {
-      nsDictionary = _RawDictionaryStorage.empty
+    if _storage === __RawDictionaryStorage.empty || count == 0 {
+      nsDictionary = __RawDictionaryStorage.empty
     } else if _isBridgedVerbatimToObjectiveC(Key.self),
       _isBridgedVerbatimToObjectiveC(Value.self) {
       nsDictionary = unsafeDowncast(
@@ -56,7 +56,7 @@
   : __SwiftNativeNSEnumerator, _NSEnumerator {
 
   @nonobjc internal var base: _NativeDictionary<Key, Value>
-  @nonobjc internal var bridgedKeys: _BridgingHashBuffer?
+  @nonobjc internal var bridgedKeys: __BridgingHashBuffer?
   @nonobjc internal var nextBucket: _NativeDictionary<Key, Value>.Bucket
   @nonobjc internal var endBucket: _NativeDictionary<Key, Value>.Bucket
 
@@ -186,41 +186,41 @@
 
   /// The buffer for bridged keys, if present.
   @nonobjc
-  private var _bridgedKeys: _BridgingHashBuffer? {
+  private var _bridgedKeys: __BridgingHashBuffer? {
     guard let ref = _stdlib_atomicLoadARCRef(object: _bridgedKeysPtr) else {
       return nil
     }
-    return unsafeDowncast(ref, to: _BridgingHashBuffer.self)
+    return unsafeDowncast(ref, to: __BridgingHashBuffer.self)
   }
 
   /// The buffer for bridged values, if present.
   @nonobjc
-  private var _bridgedValues: _BridgingHashBuffer? {
+  private var _bridgedValues: __BridgingHashBuffer? {
     guard let ref = _stdlib_atomicLoadARCRef(object: _bridgedValuesPtr) else {
       return nil
     }
-    return unsafeDowncast(ref, to: _BridgingHashBuffer.self)
+    return unsafeDowncast(ref, to: __BridgingHashBuffer.self)
   }
 
   /// Attach a buffer for bridged Dictionary keys.
   @nonobjc
-  private func _initializeBridgedKeys(_ storage: _BridgingHashBuffer) {
+  private func _initializeBridgedKeys(_ storage: __BridgingHashBuffer) {
     _stdlib_atomicInitializeARCRef(object: _bridgedKeysPtr, desired: storage)
   }
 
   /// Attach a buffer for bridged Dictionary values.
   @nonobjc
-  private func _initializeBridgedValues(_ storage: _BridgingHashBuffer) {
+  private func _initializeBridgedValues(_ storage: __BridgingHashBuffer) {
     _stdlib_atomicInitializeARCRef(object: _bridgedValuesPtr, desired: storage)
   }
 
   @nonobjc
-  internal func bridgeKeys() -> _BridgingHashBuffer? {
+  internal func bridgeKeys() -> __BridgingHashBuffer? {
     if _isBridgedVerbatimToObjectiveC(Key.self) { return nil }
     if let bridgedKeys = _bridgedKeys { return bridgedKeys }
 
     // Allocate and initialize heap storage for bridged keys.
-    let bridged = _BridgingHashBuffer.allocate(
+    let bridged = __BridgingHashBuffer.allocate(
       owner: native._storage,
       hashTable: native.hashTable)
     for bucket in native.hashTable {
@@ -234,12 +234,12 @@
   }
 
   @nonobjc
-  internal func bridgeValues() -> _BridgingHashBuffer? {
+  internal func bridgeValues() -> __BridgingHashBuffer? {
     if _isBridgedVerbatimToObjectiveC(Value.self) { return nil }
     if let bridgedValues = _bridgedValues { return bridgedValues }
 
     // Allocate and initialize heap storage for bridged values.
-    let bridged = _BridgingHashBuffer.allocate(
+    let bridged = __BridgingHashBuffer.allocate(
       owner: native._storage,
       hashTable: native.hashTable)
     for bucket in native.hashTable {
@@ -263,7 +263,7 @@
   @inline(__always)
   private func _key(
     at bucket: Bucket,
-    bridgedKeys: _BridgingHashBuffer?
+    bridgedKeys: __BridgingHashBuffer?
   ) -> AnyObject {
     if let bridgedKeys = bridgedKeys {
       return bridgedKeys[bucket]
@@ -274,7 +274,7 @@
   @inline(__always)
   private func _value(
     at bucket: Bucket,
-    bridgedValues: _BridgingHashBuffer?
+    bridgedValues: __BridgingHashBuffer?
   ) -> AnyObject {
     if let bridgedValues = bridgedValues {
       return bridgedValues[bucket]
@@ -417,9 +417,13 @@
   }
 }
 
+// NOTE: older runtimes called this struct _CocoaDictionary. The two
+// must coexist without conflicting ObjC class names from the nested
+// classes, so it was renamed. The old names must not be used in the new
+// runtime.
 @usableFromInline
 @_fixed_layout
-internal struct _CocoaDictionary {
+internal struct __CocoaDictionary {
   @usableFromInline
   internal let object: AnyObject
 
@@ -429,14 +433,14 @@
   }
 }
 
-extension _CocoaDictionary {
+extension __CocoaDictionary {
   @usableFromInline
-  internal func isEqual(to other: _CocoaDictionary) -> Bool {
+  internal func isEqual(to other: __CocoaDictionary) -> Bool {
     return _stdlib_NSObject_isEqual(self.object, other.object)
   }
 }
 
-extension _CocoaDictionary: _DictionaryBuffer {
+extension __CocoaDictionary: _DictionaryBuffer {
   @usableFromInline
   internal typealias Key = AnyObject
   @usableFromInline
@@ -545,7 +549,7 @@
   }
 }
 
-extension _CocoaDictionary {
+extension __CocoaDictionary {
   @inlinable
   internal func mapValues<Key: Hashable, Value, T>(
     _ transform: (Value) throws -> T
@@ -560,7 +564,7 @@
   }
 }
 
-extension _CocoaDictionary {
+extension __CocoaDictionary {
   @_fixed_layout
   @usableFromInline
   internal struct Index {
@@ -582,7 +586,7 @@
   }
 }
 
-extension _CocoaDictionary.Index {
+extension __CocoaDictionary.Index {
   // FIXME(cocoa-index): Try using an NSEnumerator to speed this up.
   internal class Storage {
   // Assumption: we rely on NSDictionary.getObjects when being
@@ -592,7 +596,7 @@
 
     /// A reference to the NSDictionary, which owns members in `allObjects`,
     /// or `allKeys`, for NSSet and NSDictionary respectively.
-    internal let base: _CocoaDictionary
+    internal let base: __CocoaDictionary
     // FIXME: swift-3-indexing-model: try to remove the cocoa reference, but
     // make sure that we have a safety check for accessing `allKeys`.  Maybe
     // move both into the dictionary/set itself.
@@ -601,7 +605,7 @@
     internal var allKeys: _BridgingBuffer
 
     internal init(
-      _ base: __owned _CocoaDictionary,
+      _ base: __owned __CocoaDictionary,
       _ allKeys: __owned _BridgingBuffer
     ) {
       self.base = base
@@ -610,7 +614,7 @@
   }
 }
 
-extension _CocoaDictionary.Index {
+extension __CocoaDictionary.Index {
   @usableFromInline
   internal var handleBitPattern: UInt {
     @_effects(readonly)
@@ -620,7 +624,7 @@
   }
 
   @usableFromInline
-  internal var dictionary: _CocoaDictionary {
+  internal var dictionary: __CocoaDictionary {
     @_effects(releasenone)
     get {
       return storage.base
@@ -628,7 +632,7 @@
   }
 }
 
-extension _CocoaDictionary.Index {
+extension __CocoaDictionary.Index {
   @usableFromInline // FIXME(cocoa-index): Make inlinable
   @nonobjc
   internal var key: AnyObject {
@@ -650,12 +654,12 @@
   }
 }
 
-extension _CocoaDictionary.Index: Equatable {
+extension __CocoaDictionary.Index: Equatable {
   @usableFromInline // FIXME(cocoa-index): Make inlinable
   @_effects(readonly)
   internal static func == (
-    lhs: _CocoaDictionary.Index,
-    rhs: _CocoaDictionary.Index
+    lhs: __CocoaDictionary.Index,
+    rhs: __CocoaDictionary.Index
   ) -> Bool {
     _precondition(lhs.storage.base.object === rhs.storage.base.object,
       "Comparing indexes from different dictionaries")
@@ -663,12 +667,12 @@
   }
 }
 
-extension _CocoaDictionary.Index: Comparable {
+extension __CocoaDictionary.Index: Comparable {
   @usableFromInline // FIXME(cocoa-index): Make inlinable
   @_effects(readonly)
   internal static func < (
-    lhs: _CocoaDictionary.Index,
-    rhs: _CocoaDictionary.Index
+    lhs: __CocoaDictionary.Index,
+    rhs: __CocoaDictionary.Index
   ) -> Bool {
     _precondition(lhs.storage.base.object === rhs.storage.base.object,
       "Comparing indexes from different dictionaries")
@@ -676,7 +680,7 @@
   }
 }
 
-extension _CocoaDictionary: Sequence {
+extension __CocoaDictionary: Sequence {
   @usableFromInline
   final internal class Iterator {
     // Cocoa Dictionary iterator has to be a class, otherwise we cannot
@@ -692,7 +696,7 @@
     // `_fastEnumerationState`.  There's code below relying on this.
     internal var _fastEnumerationStackBuf = _CocoaFastEnumerationStackBuf()
 
-    internal let base: _CocoaDictionary
+    internal let base: __CocoaDictionary
 
     internal var _fastEnumerationStatePtr:
       UnsafeMutablePointer<_SwiftNSFastEnumerationState> {
@@ -713,7 +717,7 @@
     internal var itemIndex: Int = 0
     internal var itemCount: Int = 0
 
-    internal init(_ base: __owned _CocoaDictionary) {
+    internal init(_ base: __owned __CocoaDictionary) {
       self.base = base
     }
   }
@@ -725,7 +729,7 @@
   }
 }
 
-extension _CocoaDictionary.Iterator: IteratorProtocol {
+extension __CocoaDictionary.Iterator: IteratorProtocol {
   @usableFromInline
   internal typealias Element = (key: AnyObject, value: AnyObject)
 
@@ -796,7 +800,7 @@
       return Dictionary(_native: _NativeDictionary(nativeStorage))
     }
 
-    if s === _RawDictionaryStorage.empty {
+    if s === __RawDictionaryStorage.empty {
       return Dictionary()
     }
 
diff --git a/stdlib/public/core/DictionaryStorage.swift b/stdlib/public/core/DictionaryStorage.swift
index f3579af..39ac765 100644
--- a/stdlib/public/core/DictionaryStorage.swift
+++ b/stdlib/public/core/DictionaryStorage.swift
@@ -16,10 +16,13 @@
 /// Enough bytes are allocated to hold the bitmap for marking valid entries,
 /// keys, and values. The data layout starts with the bitmap, followed by the
 /// keys, followed by the values.
+// NOTE: older runtimes called this class _RawDictionaryStorage. The two
+// must coexist without a conflicting ObjC class name, so it was
+// renamed. The old name must not be used in the new runtime.
 @_fixed_layout
 @usableFromInline
 @_objc_non_lazy_realization
-internal class _RawDictionaryStorage: __SwiftNativeNSDictionary {
+internal class __RawDictionaryStorage: __SwiftNativeNSDictionary {
   // NOTE: The precise layout of this type is relied on in the runtime to
   // provide a statically allocated empty singleton.  See
   // stdlib/public/stubs/GlobalObjects.cpp for details.
@@ -109,9 +112,12 @@
 
 /// The storage class for the singleton empty set.
 /// The single instance of this class is created by the runtime.
+// NOTE: older runtimes called this class _EmptyDictionarySingleton.
+// The two must coexist without a conflicting ObjC class name, so it was
+// renamed. The old name must not be used in the new runtime.
 @_fixed_layout
 @usableFromInline
-internal class _EmptyDictionarySingleton: _RawDictionaryStorage {
+internal class __EmptyDictionarySingleton: __RawDictionaryStorage {
   @nonobjc
   internal override init(_doNotCallMe: ()) {
     _internalInvariantFailure("This class cannot be directly initialized")
@@ -130,7 +136,7 @@
 }
 
 #if _runtime(_ObjC)
-extension _EmptyDictionarySingleton: _NSDictionaryCore {
+extension __EmptyDictionarySingleton: _NSDictionaryCore {
   @objc(copyWithZone:)
   internal func copy(with zone: _SwiftNSZone?) -> AnyObject {
     return self
@@ -167,7 +173,7 @@
 
   @objc(keyEnumerator)
   internal func keyEnumerator() -> _NSEnumerator {
-    return _SwiftEmptyNSEnumerator()
+    return __SwiftEmptyNSEnumerator()
   }
 
   @objc(getObjects:andKeys:count:)
@@ -180,13 +186,13 @@
 }
 #endif
 
-extension _RawDictionaryStorage {
+extension __RawDictionaryStorage {
   /// The empty singleton that is used for every single Dictionary that is
   /// created without any elements. The contents of the storage should never
   /// be mutated.
   @inlinable
   @nonobjc
-  internal static var empty: _EmptyDictionarySingleton {
+  internal static var empty: __EmptyDictionarySingleton {
     return Builtin.bridgeFromRawPointer(
       Builtin.addressof(&_swiftEmptyDictionarySingleton))
   }
@@ -194,7 +200,7 @@
 
 @usableFromInline
 final internal class _DictionaryStorage<Key: Hashable, Value>
-  : _RawDictionaryStorage, _NSDictionaryCore {
+  : __RawDictionaryStorage, _NSDictionaryCore {
   // This type is made with allocWithTailElems, so no init is ever called.
   // But we still need to have an init to satisfy the compiler.
   @nonobjc
@@ -359,7 +365,7 @@
   @usableFromInline
   @_effects(releasenone)
   internal static func copy(
-    original: _RawDictionaryStorage
+    original: __RawDictionaryStorage
   ) -> _DictionaryStorage {
     return allocate(
       scale: original._scale,
@@ -370,7 +376,7 @@
   @usableFromInline
   @_effects(releasenone)
   static internal func resize(
-    original: _RawDictionaryStorage,
+    original: __RawDictionaryStorage,
     capacity: Int,
     move: Bool
   ) -> _DictionaryStorage {
@@ -389,7 +395,7 @@
   @usableFromInline
   @_effects(releasenone)
   static internal func convert(
-    _ cocoa: _CocoaDictionary,
+    _ cocoa: __CocoaDictionary,
     capacity: Int
   ) -> _DictionaryStorage {
     let scale = _HashTable.scale(forCapacity: capacity)
diff --git a/stdlib/public/core/DictionaryVariant.swift b/stdlib/public/core/DictionaryVariant.swift
index 3d9992d..c091de0 100644
--- a/stdlib/public/core/DictionaryVariant.swift
+++ b/stdlib/public/core/DictionaryVariant.swift
@@ -35,7 +35,7 @@
   @_fixed_layout
   internal struct _Variant {
     @usableFromInline
-    internal var object: _BridgeStorage<_RawDictionaryStorage>
+    internal var object: _BridgeStorage<__RawDictionaryStorage>
 
     @inlinable
     @inline(__always)
@@ -56,7 +56,7 @@
 #if _runtime(_ObjC)
     @inlinable
     @inline(__always)
-    init(cocoa: __owned _CocoaDictionary) {
+    init(cocoa: __owned __CocoaDictionary) {
       self.object = _BridgeStorage(objC: cocoa.object)
     }
 #endif
@@ -102,8 +102,8 @@
 
 #if _runtime(_ObjC)
   @inlinable
-  internal var asCocoa: _CocoaDictionary {
-    return _CocoaDictionary(object.objCInstance)
+  internal var asCocoa: __CocoaDictionary {
+    return __CocoaDictionary(object.objCInstance)
   }
 #endif
 
diff --git a/stdlib/public/core/Hashing.swift b/stdlib/public/core/Hashing.swift
index 379e83b..1429f5c 100644
--- a/stdlib/public/core/Hashing.swift
+++ b/stdlib/public/core/Hashing.swift
@@ -71,7 +71,10 @@
 #if _runtime(_ObjC)
 /// An NSEnumerator implementation returning zero elements. This is useful when
 /// a concrete element type is not recoverable from the empty singleton.
-final internal class _SwiftEmptyNSEnumerator
+// NOTE: older runtimes called this class _SwiftEmptyNSEnumerator. The two
+// must coexist without conflicting ObjC class names, so it was
+// renamed. The old name must not be used in the new runtime.
+final internal class __SwiftEmptyNSEnumerator
   : __SwiftNativeNSEnumerator, _NSEnumerator {
   internal override required init() {}
 
@@ -107,8 +110,11 @@
 ///
 /// Using a dedicated class for this rather than a _BridgingBuffer makes it easy
 /// to recognize these in heap dumps etc.
-internal final class _BridgingHashBuffer
-  : ManagedBuffer<_BridgingHashBuffer.Header, AnyObject> {
+// NOTE: older runtimes called this class _BridgingHashBuffer.
+// The two must coexist without a conflicting ObjC class name, so it
+// was renamed. The old name must not be used in the new runtime.
+internal final class __BridgingHashBuffer
+  : ManagedBuffer<__BridgingHashBuffer.Header, AnyObject> {
   struct Header {
     internal var owner: AnyObject
     internal var hashTable: _HashTable
@@ -122,11 +128,11 @@
   internal static func allocate(
     owner: AnyObject,
     hashTable: _HashTable
-  ) -> _BridgingHashBuffer {
+  ) -> __BridgingHashBuffer {
     let buffer = self.create(minimumCapacity: hashTable.bucketCount) { _ in
       Header(owner: owner, hashTable: hashTable)
     }
-    return unsafeDowncast(buffer, to: _BridgingHashBuffer.self)
+    return unsafeDowncast(buffer, to: __BridgingHashBuffer.self)
   }
 
   deinit {
diff --git a/stdlib/public/core/NativeDictionary.swift b/stdlib/public/core/NativeDictionary.swift
index f6abdaf..c475f33 100644
--- a/stdlib/public/core/NativeDictionary.swift
+++ b/stdlib/public/core/NativeDictionary.swift
@@ -10,7 +10,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-/// A wrapper around _RawDictionaryStorage that provides most of the
+/// A wrapper around __RawDictionaryStorage that provides most of the
 /// implementation of Dictionary.
 @usableFromInline
 @_fixed_layout
@@ -18,20 +18,20 @@
   @usableFromInline
   internal typealias Element = (key: Key, value: Value)
 
-  /// See this comments on _RawDictionaryStorage and its subclasses to
+  /// See this comments on __RawDictionaryStorage and its subclasses to
   /// understand why we store an untyped storage here.
   @usableFromInline
-  internal var _storage: _RawDictionaryStorage
+  internal var _storage: __RawDictionaryStorage
 
   /// Constructs an instance from the empty singleton.
   @inlinable
   internal init() {
-    self._storage = _RawDictionaryStorage.empty
+    self._storage = __RawDictionaryStorage.empty
   }
 
   /// Constructs a dictionary adopting the given storage.
   @inlinable
-  internal init(_ storage: __owned _RawDictionaryStorage) {
+  internal init(_ storage: __owned __RawDictionaryStorage) {
     self._storage = storage
   }
 
@@ -42,12 +42,12 @@
 
 #if _runtime(_ObjC)
   @inlinable
-  internal init(_ cocoa: __owned _CocoaDictionary) {
+  internal init(_ cocoa: __owned __CocoaDictionary) {
     self.init(cocoa, capacity: cocoa.count)
   }
 
   @inlinable
-  internal init(_ cocoa: __owned _CocoaDictionary, capacity: Int) {
+  internal init(_ cocoa: __owned __CocoaDictionary, capacity: Int) {
     _internalInvariant(cocoa.count <= capacity)
     self._storage =
       _DictionaryStorage<Key, Value>.convert(cocoa, capacity: capacity)
@@ -591,7 +591,7 @@
 
 #if _runtime(_ObjC)
   @inlinable
-  func isEqual(to other: _CocoaDictionary) -> Bool {
+  func isEqual(to other: __CocoaDictionary) -> Bool {
     if self.count != other.count { return false }
 
     defer { _fixLifetime(self) }
diff --git a/stdlib/public/core/NativeSet.swift b/stdlib/public/core/NativeSet.swift
index fa7a89e..ec18aef 100644
--- a/stdlib/public/core/NativeSet.swift
+++ b/stdlib/public/core/NativeSet.swift
@@ -10,27 +10,27 @@
 //
 //===----------------------------------------------------------------------===//
 
-/// A wrapper around _RawSetStorage that provides most of the
+/// A wrapper around __RawSetStorage that provides most of the
 /// implementation of Set.
 @usableFromInline
 @_fixed_layout
 internal struct _NativeSet<Element: Hashable> {
-  /// See the comments on _RawSetStorage and its subclasses to understand why we
+  /// See the comments on __RawSetStorage and its subclasses to understand why we
   /// store an untyped storage here.
   @usableFromInline
-  internal var _storage: _RawSetStorage
+  internal var _storage: __RawSetStorage
 
   /// Constructs an instance from the empty singleton.
   @inlinable
   @inline(__always)
   internal init() {
-    self._storage = _RawSetStorage.empty
+    self._storage = __RawSetStorage.empty
   }
 
   /// Constructs a native set adopting the given storage.
   @inlinable
   @inline(__always)
-  internal init(_ storage: __owned _RawSetStorage) {
+  internal init(_ storage: __owned __RawSetStorage) {
     self._storage = storage
   }
 
@@ -41,12 +41,12 @@
 
 #if _runtime(_ObjC)
   @inlinable
-  internal init(_ cocoa: __owned _CocoaSet) {
+  internal init(_ cocoa: __owned __CocoaSet) {
     self.init(cocoa, capacity: cocoa.count)
   }
 
   @inlinable
-  internal init(_ cocoa: __owned _CocoaSet, capacity: Int) {
+  internal init(_ cocoa: __owned __CocoaSet, capacity: Int) {
     _internalInvariant(cocoa.count <= capacity)
     self._storage = _SetStorage<Element>.convert(cocoa, capacity: capacity)
     for element in cocoa {
@@ -439,7 +439,7 @@
 
 #if _runtime(_ObjC)
   @inlinable
-  func isEqual(to other: _CocoaSet) -> Bool {
+  func isEqual(to other: __CocoaSet) -> Bool {
     if self.count != other.count { return false }
 
     defer { _fixLifetime(self) }
diff --git a/stdlib/public/core/Set.swift b/stdlib/public/core/Set.swift
index 4326bf8..33c3d0f 100644
--- a/stdlib/public/core/Set.swift
+++ b/stdlib/public/core/Set.swift
@@ -174,7 +174,7 @@
 
 #if _runtime(_ObjC)
   @inlinable
-  internal init(_cocoa: __owned _CocoaSet) {
+  internal init(_cocoa: __owned __CocoaSet) {
     _variant = _Variant(cocoa: _cocoa)
   }
 
@@ -190,7 +190,7 @@
   init(_immutableCocoaSet: __owned AnyObject) {
     _internalInvariant(_isBridgedVerbatimToObjectiveC(Element.self),
       "Set can be backed by NSSet _variant only when the member type can be bridged verbatim to Objective-C")
-    self.init(_cocoa: _CocoaSet(_immutableCocoaSet))
+    self.init(_cocoa: __CocoaSet(_immutableCocoaSet))
   }
 #endif
 }
@@ -1279,7 +1279,7 @@
     internal enum _Variant {
       case native(_HashTable.Index)
 #if _runtime(_ObjC)
-      case cocoa(_CocoaSet.Index)
+      case cocoa(__CocoaSet.Index)
 #endif
     }
 
@@ -1301,7 +1301,7 @@
 #if _runtime(_ObjC)
     @inlinable
     @inline(__always)
-    internal init(_cocoa index: __owned _CocoaSet.Index) {
+    internal init(_cocoa index: __owned __CocoaSet.Index) {
       self.init(_variant: .cocoa(index))
     }
 #endif
@@ -1362,7 +1362,7 @@
 
 #if _runtime(_ObjC)
   @usableFromInline
-  internal var _asCocoa: _CocoaSet.Index {
+  internal var _asCocoa: __CocoaSet.Index {
     @_transparent
     get {
       switch _variant {
@@ -1467,7 +1467,7 @@
     internal enum _Variant {
       case native(_NativeSet<Element>.Iterator)
 #if _runtime(_ObjC)
-      case cocoa(_CocoaSet.Iterator)
+      case cocoa(__CocoaSet.Iterator)
 #endif
     }
 
@@ -1486,7 +1486,7 @@
 
 #if _runtime(_ObjC)
     @usableFromInline
-    internal init(_cocoa: __owned _CocoaSet.Iterator) {
+    internal init(_cocoa: __owned __CocoaSet.Iterator) {
       self.init(_variant: .cocoa(_cocoa))
     }
 #endif
@@ -1542,7 +1542,7 @@
 
 #if _runtime(_ObjC)
   @usableFromInline @_transparent
-  internal var _asCocoa: _CocoaSet.Iterator {
+  internal var _asCocoa: __CocoaSet.Iterator {
     get {
       switch _variant {
       case .native:
diff --git a/stdlib/public/core/SetBridging.swift b/stdlib/public/core/SetBridging.swift
index 9c9d208..bc84a59 100644
--- a/stdlib/public/core/SetBridging.swift
+++ b/stdlib/public/core/SetBridging.swift
@@ -38,8 +38,8 @@
     // Temporary var for SOME type safety.
     let nsSet: _NSSetCore
 
-    if _storage === _RawSetStorage.empty || count == 0 {
-      nsSet = _RawSetStorage.empty
+    if _storage === __RawSetStorage.empty || count == 0 {
+      nsSet = __RawSetStorage.empty
     } else if _isBridgedVerbatimToObjectiveC(Element.self) {
       nsSet = unsafeDowncast(_storage, to: _SetStorage<Element>.self)
     } else {
@@ -59,7 +59,7 @@
   : __SwiftNativeNSEnumerator, _NSEnumerator {
 
   @nonobjc internal var base: _NativeSet<Element>
-  @nonobjc internal var bridgedElements: _BridgingHashBuffer?
+  @nonobjc internal var bridgedElements: __BridgingHashBuffer?
   @nonobjc internal var nextBucket: _NativeSet<Element>.Bucket
   @nonobjc internal var endBucket: _NativeSet<Element>.Bucket
 
@@ -172,27 +172,27 @@
 
   /// The buffer for bridged Set elements, if present.
   @nonobjc
-  private var _bridgedElements: _BridgingHashBuffer? {
+  private var _bridgedElements: __BridgingHashBuffer? {
     guard let ref = _stdlib_atomicLoadARCRef(object: _bridgedElementsPtr) else {
       return nil
     }
-    return unsafeDowncast(ref, to: _BridgingHashBuffer.self)
+    return unsafeDowncast(ref, to: __BridgingHashBuffer.self)
   }
 
   /// Attach a buffer for bridged Set elements.
   @nonobjc
-  private func _initializeBridgedElements(_ storage: _BridgingHashBuffer) {
+  private func _initializeBridgedElements(_ storage: __BridgingHashBuffer) {
     _stdlib_atomicInitializeARCRef(
       object: _bridgedElementsPtr,
       desired: storage)
   }
 
   @nonobjc
-  internal func bridgeElements() -> _BridgingHashBuffer {
+  internal func bridgeElements() -> __BridgingHashBuffer {
     if let bridgedElements = _bridgedElements { return bridgedElements }
 
     // Allocate and initialize heap storage for bridged objects.
-    let bridged = _BridgingHashBuffer.allocate(
+    let bridged = __BridgingHashBuffer.allocate(
       owner: native._storage,
       hashTable: native.hashTable)
     for bucket in native.hashTable {
@@ -285,9 +285,13 @@
   }
 }
 
+// NOTE: older overlays called this struct _CocoaSet. The two
+// must coexist without conflicting ObjC class names from the nested
+// classes, so it was renamed. The old names must not be used in the new
+// runtime.
 @usableFromInline
 @_fixed_layout
-internal struct _CocoaSet {
+internal struct __CocoaSet {
   @usableFromInline
   internal let object: AnyObject
 
@@ -297,7 +301,7 @@
   }
 }
 
-extension _CocoaSet {
+extension __CocoaSet {
   @usableFromInline
   @_effects(releasenone)
   internal func member(for index: Index) -> AnyObject {
@@ -311,14 +315,14 @@
   }
 }
 
-extension _CocoaSet {
+extension __CocoaSet {
   @usableFromInline
-  internal func isEqual(to other: _CocoaSet) -> Bool {
+  internal func isEqual(to other: __CocoaSet) -> Bool {
     return _stdlib_NSObject_isEqual(self.object, other.object)
   }
 }
 
-extension _CocoaSet: _SetBuffer {
+extension __CocoaSet: _SetBuffer {
   @usableFromInline
   internal typealias Element = AnyObject
 
@@ -404,7 +408,7 @@
   }
 }
 
-extension _CocoaSet {
+extension __CocoaSet {
   @_fixed_layout
   @usableFromInline
   internal struct Index {
@@ -426,7 +430,7 @@
   }
 }
 
-extension _CocoaSet.Index {
+extension __CocoaSet.Index {
   // FIXME(cocoa-index): Try using an NSEnumerator to speed this up.
   internal class Storage {
     // Assumption: we rely on NSDictionary.getObjects when being
@@ -436,7 +440,7 @@
 
     /// A reference to the NSSet, which owns members in `allObjects`,
     /// or `allKeys`, for NSSet and NSDictionary respectively.
-    internal let base: _CocoaSet
+    internal let base: __CocoaSet
     // FIXME: swift-3-indexing-model: try to remove the cocoa reference, but
     // make sure that we have a safety check for accessing `allKeys`.  Maybe
     // move both into the dictionary/set itself.
@@ -445,7 +449,7 @@
     internal var allKeys: _BridgingBuffer
 
     internal init(
-      _ base: __owned _CocoaSet,
+      _ base: __owned __CocoaSet,
       _ allKeys: __owned _BridgingBuffer
     ) {
       self.base = base
@@ -454,7 +458,7 @@
   }
 }
 
-extension _CocoaSet.Index {
+extension __CocoaSet.Index {
   @usableFromInline
   internal var handleBitPattern: UInt {
     @_effects(readonly)
@@ -464,7 +468,7 @@
   }
 }
 
-extension _CocoaSet.Index {
+extension __CocoaSet.Index {
   @usableFromInline // FIXME(cocoa-index): Make inlinable
   @nonobjc
   internal var element: AnyObject {
@@ -486,27 +490,27 @@
   }
 }
 
-extension _CocoaSet.Index: Equatable {
+extension __CocoaSet.Index: Equatable {
   @usableFromInline // FIXME(cocoa-index): Make inlinable
   @_effects(readonly)
-  internal static func == (lhs: _CocoaSet.Index, rhs: _CocoaSet.Index) -> Bool {
+  internal static func == (lhs: __CocoaSet.Index, rhs: __CocoaSet.Index) -> Bool {
     _precondition(lhs.storage.base.object === rhs.storage.base.object,
       "Comparing indexes from different sets")
     return lhs._offset == rhs._offset
   }
 }
 
-extension _CocoaSet.Index: Comparable {
+extension __CocoaSet.Index: Comparable {
   @usableFromInline // FIXME(cocoa-index): Make inlinable
   @_effects(readonly)
-  internal static func < (lhs: _CocoaSet.Index, rhs: _CocoaSet.Index) -> Bool {
+  internal static func < (lhs: __CocoaSet.Index, rhs: __CocoaSet.Index) -> Bool {
     _precondition(lhs.storage.base.object === rhs.storage.base.object,
       "Comparing indexes from different sets")
     return lhs._offset < rhs._offset
   }
 }
 
-extension _CocoaSet: Sequence {
+extension __CocoaSet: Sequence {
   @usableFromInline
   final internal class Iterator {
     // Cocoa Set iterator has to be a class, otherwise we cannot
@@ -522,7 +526,7 @@
     // `_fastEnumerationState`.  There's code below relying on this.
     internal var _fastEnumerationStackBuf = _CocoaFastEnumerationStackBuf()
 
-    internal let base: _CocoaSet
+    internal let base: __CocoaSet
 
     internal var _fastEnumerationStatePtr:
       UnsafeMutablePointer<_SwiftNSFastEnumerationState> {
@@ -543,7 +547,7 @@
     internal var itemIndex: Int = 0
     internal var itemCount: Int = 0
 
-    internal init(_ base: __owned _CocoaSet) {
+    internal init(_ base: __owned __CocoaSet) {
       self.base = base
     }
   }
@@ -554,7 +558,7 @@
   }
 }
 
-extension _CocoaSet.Iterator: IteratorProtocol {
+extension __CocoaSet.Iterator: IteratorProtocol {
   @usableFromInline
   internal typealias Element = AnyObject
 
@@ -618,7 +622,7 @@
       return Set(_native: _NativeSet(nativeStorage))
     }
 
-    if s === _RawSetStorage.empty {
+    if s === __RawSetStorage.empty {
       return Set()
     }
 
diff --git a/stdlib/public/core/SetStorage.swift b/stdlib/public/core/SetStorage.swift
index f4a5086..44936c8 100644
--- a/stdlib/public/core/SetStorage.swift
+++ b/stdlib/public/core/SetStorage.swift
@@ -16,10 +16,13 @@
 /// Enough bytes are allocated to hold the bitmap for marking valid entries,
 /// keys, and values. The data layout starts with the bitmap, followed by the
 /// keys, followed by the values.
+// NOTE: older runtimes called this class _RawSetStorage. The two
+// must coexist without a conflicting ObjC class name, so it was
+// renamed. The old name must not be used in the new runtime.
 @_fixed_layout
 @usableFromInline
 @_objc_non_lazy_realization
-internal class _RawSetStorage: __SwiftNativeNSSet {
+internal class __RawSetStorage: __SwiftNativeNSSet {
   // NOTE: The precise layout of this type is relied on in the runtime to
   // provide a statically allocated empty singleton.  See
   // stdlib/public/stubs/GlobalObjects.cpp for details.
@@ -104,9 +107,12 @@
 
 /// The storage class for the singleton empty set.
 /// The single instance of this class is created by the runtime.
+// NOTE: older runtimes called this class _EmptySetSingleton. The two
+// must coexist without conflicting ObjC class names, so it was renamed.
+// The old names must not be used in the new runtime.
 @_fixed_layout
 @usableFromInline
-internal class _EmptySetSingleton: _RawSetStorage {
+internal class __EmptySetSingleton: __RawSetStorage {
   @nonobjc
   override internal init(_doNotCallMe: ()) {
     _internalInvariantFailure("This class cannot be directly initialized")
@@ -120,18 +126,18 @@
 #endif
 }
 
-extension _RawSetStorage {
+extension __RawSetStorage {
   /// The empty singleton that is used for every single Set that is created
   /// without any elements. The contents of the storage must never be mutated.
   @inlinable
   @nonobjc
-  internal static var empty: _EmptySetSingleton {
+  internal static var empty: __EmptySetSingleton {
     return Builtin.bridgeFromRawPointer(
       Builtin.addressof(&_swiftEmptySetSingleton))
   }
 }
 
-extension _EmptySetSingleton: _NSSetCore {
+extension __EmptySetSingleton: _NSSetCore {
 #if _runtime(_ObjC)
   //
   // NSSet implementation, assuming Self is the empty singleton
@@ -153,7 +159,7 @@
 
   @objc
   internal func objectEnumerator() -> _NSEnumerator {
-    return _SwiftEmptyNSEnumerator()
+    return __SwiftEmptyNSEnumerator()
   }
 
   @objc(countByEnumeratingWithState:objects:count:)
@@ -177,7 +183,7 @@
 
 @usableFromInline
 final internal class _SetStorage<Element: Hashable>
-  : _RawSetStorage, _NSSetCore {
+  : __RawSetStorage, _NSSetCore {
   // This type is made with allocWithTailElems, so no init is ever called.
   // But we still need to have an init to satisfy the compiler.
   @nonobjc
@@ -284,7 +290,7 @@
 extension _SetStorage {
   @usableFromInline
   @_effects(releasenone)
-  internal static func copy(original: _RawSetStorage) -> _SetStorage {
+  internal static func copy(original: __RawSetStorage) -> _SetStorage {
     return .allocate(
       scale: original._scale,
       age: original._age,
@@ -294,7 +300,7 @@
   @usableFromInline
   @_effects(releasenone)
   static internal func resize(
-    original: _RawSetStorage,
+    original: __RawSetStorage,
     capacity: Int,
     move: Bool
   ) -> _SetStorage {
@@ -313,7 +319,7 @@
   @usableFromInline
   @_effects(releasenone)
   static internal func convert(
-    _ cocoa: _CocoaSet,
+    _ cocoa: __CocoaSet,
     capacity: Int
   ) -> _SetStorage {
     let scale = _HashTable.scale(forCapacity: capacity)
diff --git a/stdlib/public/core/SetVariant.swift b/stdlib/public/core/SetVariant.swift
index 24e4e50..355b5188 100644
--- a/stdlib/public/core/SetVariant.swift
+++ b/stdlib/public/core/SetVariant.swift
@@ -31,7 +31,7 @@
   @_fixed_layout
   internal struct _Variant {
     @usableFromInline
-    internal var object: _BridgeStorage<_RawSetStorage>
+    internal var object: _BridgeStorage<__RawSetStorage>
 
     @inlinable
     @inline(__always)
@@ -52,7 +52,7 @@
 #if _runtime(_ObjC)
     @inlinable
     @inline(__always)
-    init(cocoa: __owned _CocoaSet) {
+    init(cocoa: __owned __CocoaSet) {
       self.object = _BridgeStorage(objC: cocoa.object)
     }
 #endif
@@ -103,8 +103,8 @@
 
 #if _runtime(_ObjC)
   @inlinable
-  internal var asCocoa: _CocoaSet {
-    return _CocoaSet(object.objCInstance)
+  internal var asCocoa: __CocoaSet {
+    return __CocoaSet(object.objCInstance)
   }
 #endif
 
@@ -318,7 +318,7 @@
 #if _runtime(_ObjC)
   @inlinable
   internal mutating func _migrateToNative(
-    _ cocoa: _CocoaSet,
+    _ cocoa: __CocoaSet,
     removing member: Element
   ) -> Element {
     // FIXME(performance): fuse data migration and element deletion into one
diff --git a/stdlib/public/core/StringBridge.swift b/stdlib/public/core/StringBridge.swift
index 1fc25c2..21b7cb9 100644
--- a/stdlib/public/core/StringBridge.swift
+++ b/stdlib/public/core/StringBridge.swift
@@ -149,9 +149,9 @@
 #endif
     
     switch _unsafeAddressOfCocoaStringClass(str) {
-    case unsafeBitCast(_StringStorage.self, to: UInt.self):
+    case unsafeBitCast(__StringStorage.self, to: UInt.self):
       self = .storage
-    case unsafeBitCast(_SharedStringStorage.self, to: UInt.self):
+    case unsafeBitCast(__SharedStringStorage.self, to: UInt.self):
       self = .shared
     default:
       self = .cocoa
@@ -216,10 +216,10 @@
   switch _KnownCocoaString(cocoaString) {
   case .storage:
     return _unsafeUncheckedDowncast(
-      cocoaString, to: _StringStorage.self).asString._guts
+      cocoaString, to: __StringStorage.self).asString._guts
   case .shared:
     return _unsafeUncheckedDowncast(
-      cocoaString, to: _SharedStringStorage.self).asString._guts
+      cocoaString, to: __SharedStringStorage.self).asString._guts
 #if !(arch(i386) || arch(arm))
   case .tagged:
     return _StringGuts(_SmallString(taggedCocoa: cocoaString))
@@ -284,7 +284,7 @@
       // TODO: We'd rather emit a valid ObjC object statically than create a
       // shared string class instance.
       let gutsCountAndFlags = _guts._object._countAndFlags
-      return _SharedStringStorage(
+      return __SharedStringStorage(
         immortal: _guts._object.fastUTF8.baseAddress!,
         countAndFlags: _StringObject.CountAndFlags(
           sharedCount: _guts.count, isASCII: gutsCountAndFlags.isASCII))
diff --git a/stdlib/public/core/StringCreate.swift b/stdlib/public/core/StringCreate.swift
index ec032c1..262f0ee 100644
--- a/stdlib/public/core/StringCreate.swift
+++ b/stdlib/public/core/StringCreate.swift
@@ -38,7 +38,7 @@
       return String(_StringGuts(smol))
     }
 
-    let storage = _StringStorage.create(initializingFrom: input, isASCII: true)
+    let storage = __StringStorage.create(initializingFrom: input, isASCII: true)
     return storage.asString
   }
 
@@ -83,7 +83,7 @@
       return String(_StringGuts(smol))
     }
 
-    let storage = _StringStorage.create(
+    let storage = __StringStorage.create(
       initializingFrom: input, isASCII: isASCII)
     return storage.asString
   }
@@ -98,7 +98,7 @@
     }
 
     let isASCII = asciiPreScanResult
-    let storage = _StringStorage.create(
+    let storage = __StringStorage.create(
       initializingFrom: input, isASCII: isASCII)
     return storage.asString
   }
diff --git a/stdlib/public/core/StringGuts.swift b/stdlib/public/core/StringGuts.swift
index 03aeb06..f90a886 100644
--- a/stdlib/public/core/StringGuts.swift
+++ b/stdlib/public/core/StringGuts.swift
@@ -56,11 +56,11 @@
   }
 
   @inline(__always)
-  internal init(_ storage: _StringStorage) {
+  internal init(_ storage: __StringStorage) {
     self.init(_StringObject(storage))
   }
 
-  internal init(_ storage: _SharedStringStorage) {
+  internal init(_ storage: __SharedStringStorage) {
     self.init(_StringObject(storage))
   }
 
diff --git a/stdlib/public/core/StringGutsRangeReplaceable.swift b/stdlib/public/core/StringGutsRangeReplaceable.swift
index f1c918d..fc27b12 100644
--- a/stdlib/public/core/StringGutsRangeReplaceable.swift
+++ b/stdlib/public/core/StringGutsRangeReplaceable.swift
@@ -84,7 +84,7 @@
     if _fastPath(isFastUTF8) {
       let isASCII = self.isASCII
       let storage = self.withFastUTF8 {
-        _StringStorage.create(
+        __StringStorage.create(
           initializingFrom: $0, capacity: growthTarget, isASCII: isASCII)
       }
 
@@ -101,7 +101,7 @@
     // into a StringStorage space.
     let selfUTF8 = Array(String(self).utf8)
     selfUTF8.withUnsafeBufferPointer {
-      self = _StringGuts(_StringStorage.create(
+      self = _StringGuts(__StringStorage.create(
         initializingFrom: $0, capacity: n, isASCII: self.isASCII))
     }
   }
diff --git a/stdlib/public/core/StringObject.swift b/stdlib/public/core/StringObject.swift
index 49b94f3..5bc877f 100644
--- a/stdlib/public/core/StringObject.swift
+++ b/stdlib/public/core/StringObject.swift
@@ -838,13 +838,13 @@
     }
   }
 
-  internal var nativeStorage: _StringStorage {
+  internal var nativeStorage: __StringStorage {
     @inline(__always) get {
 #if arch(i386) || arch(arm)
       guard case .native(let storage) = _variant else {
         _internalInvariantFailure()
       }
-      return _unsafeUncheckedDowncast(storage, to: _StringStorage.self)
+      return _unsafeUncheckedDowncast(storage, to: __StringStorage.self)
 #else
       _internalInvariant(hasNativeStorage)
       return Builtin.reinterpretCast(largeAddressBits)
@@ -852,13 +852,13 @@
     }
   }
 
-  internal var sharedStorage: _SharedStringStorage {
+  internal var sharedStorage: __SharedStringStorage {
     @inline(__always) get {
 #if arch(i386) || arch(arm)
       guard case .native(let storage) = _variant else {
         _internalInvariantFailure()
       }
-      return _unsafeUncheckedDowncast(storage, to: _SharedStringStorage.self)
+      return _unsafeUncheckedDowncast(storage, to: __SharedStringStorage.self)
 #else
       _internalInvariant(largeFastIsShared && !largeIsCocoa)
       _internalInvariant(hasSharedStorage)
@@ -982,7 +982,7 @@
   }
 
   @inline(__always)
-  internal init(_ storage: _StringStorage) {
+  internal init(_ storage: __StringStorage) {
 #if arch(i386) || arch(arm)
     self.init(
       variant: .native(storage),
@@ -996,7 +996,7 @@
 #endif
   }
 
-  internal init(_ storage: _SharedStringStorage) {
+  internal init(_ storage: __SharedStringStorage) {
 #if arch(i386) || arch(arm)
     self.init(
       variant: .native(storage),
@@ -1100,7 +1100,7 @@
       }
       if _countAndFlags.isNativelyStored {
         let anyObj = Builtin.reinterpretCast(largeAddressBits) as AnyObject
-        _internalInvariant(anyObj is _StringStorage)
+        _internalInvariant(anyObj is __StringStorage)
       }
     }
 
diff --git a/stdlib/public/core/StringStorage.swift b/stdlib/public/core/StringStorage.swift
index 260d958..d6f2694 100644
--- a/stdlib/public/core/StringStorage.swift
+++ b/stdlib/public/core/StringStorage.swift
@@ -126,10 +126,10 @@
     switch knownOther {
     case .storage:
       return _nativeIsEqual(
-        _unsafeUncheckedDowncast(other, to: _StringStorage.self))
+        _unsafeUncheckedDowncast(other, to: __StringStorage.self))
     case .shared:
       return _nativeIsEqual(
-        _unsafeUncheckedDowncast(other, to: _SharedStringStorage.self))
+        _unsafeUncheckedDowncast(other, to: __SharedStringStorage.self))
 #if !(arch(i386) || arch(arm))
     case .tagged:
       fallthrough
@@ -172,7 +172,10 @@
 // Optional<_StringBreadcrumbs>.
 //
 
-final internal class _StringStorage
+// NOTE: older runtimes called this class _StringStorage. The two
+// must coexist without conflicting ObjC class names, so it was
+// renamed. The old name must not be used in the new runtime.
+final internal class __StringStorage
   : __SwiftNativeNSString, _AbstractStringStorage {
 #if arch(i386) || arch(arm)
   // The total allocated storage capacity. Note that this includes the required
@@ -299,7 +302,7 @@
 
   @objc(copyWithZone:)
   final internal func copy(with zone: _SwiftNSZone?) -> AnyObject {
-    // While _StringStorage instances aren't immutable in general,
+    // While __StringStorage instances aren't immutable in general,
     // mutations may only occur when instances are uniquely referenced.
     // Therefore, it is safe to return self here; any outstanding Objective-C
     // reference will make the instance non-unique.
@@ -350,13 +353,13 @@
 }
 
 // Creation
-extension _StringStorage {
+extension __StringStorage {
   @_effects(releasenone)
   private static func create(
     realCodeUnitCapacity: Int, countAndFlags: CountAndFlags
-  ) -> _StringStorage {
+  ) -> __StringStorage {
     let storage = Builtin.allocWithTailElems_2(
-      _StringStorage.self,
+      __StringStorage.self,
       realCodeUnitCapacity._builtinWordValue, UInt8.self,
       1._builtinWordValue, Optional<_StringBreadcrumbs>.self)
 #if arch(i386) || arch(arm)
@@ -380,12 +383,12 @@
   @_effects(releasenone)
   private static func create(
     capacity: Int, countAndFlags: CountAndFlags
-  ) -> _StringStorage {
+  ) -> __StringStorage {
     _internalInvariant(capacity >= countAndFlags.count)
 
     let realCapacity = determineCodeUnitCapacity(capacity)
     _internalInvariant(realCapacity > capacity)
-    return _StringStorage.create(
+    return __StringStorage.create(
       realCodeUnitCapacity: realCapacity, countAndFlags: countAndFlags)
   }
 
@@ -394,11 +397,11 @@
     initializingFrom bufPtr: UnsafeBufferPointer<UInt8>,
     capacity: Int,
     isASCII: Bool
-  ) -> _StringStorage {
+  ) -> __StringStorage {
     let countAndFlags = CountAndFlags(
       mortalCount: bufPtr.count, isASCII: isASCII)
     _internalInvariant(capacity >= bufPtr.count)
-    let storage = _StringStorage.create(
+    let storage = __StringStorage.create(
       capacity: capacity, countAndFlags: countAndFlags)
     let addr = bufPtr.baseAddress._unsafelyUnwrappedUnchecked
     storage.mutableStart.initialize(from: addr, count: bufPtr.count)
@@ -409,14 +412,14 @@
   @_effects(releasenone)
   internal static func create(
     initializingFrom bufPtr: UnsafeBufferPointer<UInt8>, isASCII: Bool
-  ) -> _StringStorage {
-    return _StringStorage.create(
+  ) -> __StringStorage {
+    return __StringStorage.create(
       initializingFrom: bufPtr, capacity: bufPtr.count, isASCII: isASCII)
   }
 }
 
 // Usage
-extension _StringStorage {
+extension __StringStorage {
   @inline(__always)
   private var mutableStart: UnsafeMutablePointer<UInt8> {
     return UnsafeMutablePointer(Builtin.projectTailElems(self, UInt8.self))
@@ -504,7 +507,7 @@
 }
 
 // Appending
-extension _StringStorage {
+extension __StringStorage {
   // Perform common post-RRC adjustments and invariant enforcement.
   @_effects(releasenone)
   private func _postRRCAdjust(newCount: Int, newIsASCII: Bool) {
@@ -564,7 +567,7 @@
 }
 
 // Removing
-extension _StringStorage {
+extension __StringStorage {
   @_effects(releasenone)
   internal func remove(from lower: Int, to upper: Int) {
     _internalInvariant(lower <= upper)
@@ -646,7 +649,10 @@
 }
 
 // For shared storage and bridging literals
-final internal class _SharedStringStorage
+// NOTE: older runtimes called this class _SharedStringStorage. The two
+// must coexist without conflicting ObjC class names, so it was
+// renamed. The old name must not be used in the new runtime.
+final internal class __SharedStringStorage
   : __SwiftNativeNSString, _AbstractStringStorage {
   internal var _owner: AnyObject?
   internal var start: UnsafePointer<UInt8>
@@ -775,7 +781,7 @@
 
   @objc(copyWithZone:)
   final internal func copy(with zone: _SwiftNSZone?) -> AnyObject {
-    // While _StringStorage instances aren't immutable in general,
+    // While __StringStorage instances aren't immutable in general,
     // mutations may only occur when instances are uniquely referenced.
     // Therefore, it is safe to return self here; any outstanding Objective-C
     // reference will make the instance non-unique.
@@ -786,7 +792,7 @@
 
 }
 
-extension _SharedStringStorage {
+extension __SharedStringStorage {
 #if !INTERNAL_CHECKS_ENABLED
   @inline(__always)
   internal func _invariantCheck() {}
diff --git a/stdlib/public/core/SwiftNativeNSArray.swift b/stdlib/public/core/SwiftNativeNSArray.swift
index f6a6d1e..1c18175 100644
--- a/stdlib/public/core/SwiftNativeNSArray.swift
+++ b/stdlib/public/core/SwiftNativeNSArray.swift
@@ -160,10 +160,10 @@
       to: Optional<AnyObject>.self)
   }
 
-  internal var _heapBufferBridged: _BridgingBufferStorage? {
+  internal var _heapBufferBridged: __BridgingBufferStorage? {
     if let ref =
       _stdlib_atomicLoadARCRef(object: _heapBufferBridgedPtr) {
-      return unsafeBitCast(ref, to: _BridgingBufferStorage.self)
+      return unsafeBitCast(ref, to: __BridgingBufferStorage.self)
     }
     return nil
   }
@@ -174,7 +174,7 @@
     self._nativeStorage = _nativeStorage
   }
 
-  internal func _destroyBridgedStorage(_ hb: _BridgingBufferStorage?) {
+  internal func _destroyBridgedStorage(_ hb: __BridgingBufferStorage?) {
     if let bridgedStorage = hb {
       let buffer = _BridgingBuffer(bridgedStorage)
       let count = buffer.count
@@ -216,7 +216,7 @@
 
           // Another thread won the race.  Throw out our buffer.
           _destroyBridgedStorage(
-            unsafeDowncast(objects.storage!, to: _BridgingBufferStorage.self))
+            unsafeDowncast(objects.storage!, to: __BridgingBufferStorage.self))
         }
         continue // Try again
       }
diff --git a/stdlib/public/core/VarArgs.swift b/stdlib/public/core/VarArgs.swift
index 2de5a21..0e31463 100644
--- a/stdlib/public/core/VarArgs.swift
+++ b/stdlib/public/core/VarArgs.swift
@@ -91,7 +91,7 @@
 @usableFromInline
 internal let _registerSaveWords = _countGPRegisters
 
-#elseif arch(arm64) && os(Linux)
+#elseif arch(arm64) && !(os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Windows))
 // ARM Procedure Call Standard for aarch64. (IHI0055B)
 // The va_list type may refer to any parameter in a parameter list may be in one
 // of three memory locations depending on its type and position in the argument
@@ -408,7 +408,7 @@
   public var _cVarArgEncoding: [Int] {
     return _encodeBitsAsWords(self)
   }
-  
+
   /// Returns the required alignment in bytes of
   /// the value returned by `_cVarArgEncoding`.
   @inlinable // FIXME(sil-serialize-all)
@@ -419,7 +419,7 @@
 }
 #endif
 
-#if arch(x86_64) || arch(s390x)
+#if arch(x86_64) || arch(s390x) || (arch(arm64) && !(os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Windows)))
 
 /// An object that can manage the lifetime of storage backing a
 /// `CVaListPointer`.
@@ -429,6 +429,7 @@
 @_fixed_layout
 @usableFromInline // c-abi
 final internal class __VaListBuilder {
+  #if arch(x86_64) || arch(s390x)
   @_fixed_layout // c-abi
   @usableFromInline
   internal struct Header {
@@ -445,15 +446,19 @@
     @usableFromInline // c-abi
     internal var reg_save_area: UnsafeMutablePointer<Int>?
   }
+  #endif
 
   @usableFromInline // c-abi
   internal var gpRegistersUsed = 0
   @usableFromInline // c-abi
   internal var fpRegistersUsed = 0
 
+  #if arch(x86_64) || arch(s390x)
   @usableFromInline // c-abi
   final  // Property must be final since it is used by Builtin.addressof.
   internal var header = Header()
+  #endif
+
   @usableFromInline // c-abi
   internal var storage: ContiguousArray<Int>
 
@@ -470,12 +475,16 @@
   internal func append(_ arg: CVarArg) {
     var encoded = arg._cVarArgEncoding
 
-#if arch(x86_64)
+#if arch(x86_64) || arch(arm64)
     let isDouble = arg is _CVarArgPassedAsDouble
 
     if isDouble && fpRegistersUsed < _countFPRegisters {
-      var startIndex = _countGPRegisters
-           + (fpRegistersUsed * _fpRegisterWords)
+      #if arch(arm64)
+        var startIndex = fpRegistersUsed * _fpRegisterWords
+      #else
+        var startIndex = _countGPRegisters
+             + (fpRegistersUsed * _fpRegisterWords)
+      #endif
       for w in encoded {
         storage[startIndex] = w
         startIndex += 1
@@ -485,7 +494,12 @@
     else if encoded.count == 1
       && !isDouble
       && gpRegistersUsed < _countGPRegisters {
-      storage[gpRegistersUsed] = encoded[0]
+      #if arch(arm64)
+        let startIndex = ( _fpRegisterWords * _countFPRegisters) + gpRegistersUsed
+      #else
+        let startIndex = gpRegistersUsed
+      #endif
+      storage[startIndex] = encoded[0]
       gpRegistersUsed += 1
     }
     else {
@@ -510,140 +524,25 @@
 
   @inlinable // c-abi
   internal func va_list() -> CVaListPointer {
-    header.reg_save_area = storage._baseAddress
-    header.overflow_arg_area
-      = storage._baseAddress + _registerSaveWords
-    return CVaListPointer(
-             _fromUnsafeMutablePointer: UnsafeMutableRawPointer(
-               Builtin.addressof(&self.header)))
+    #if arch(x86_64) || arch(s390x)
+      header.reg_save_area = storage._baseAddress
+      header.overflow_arg_area
+        = storage._baseAddress + _registerSaveWords
+      return CVaListPointer(
+               _fromUnsafeMutablePointer: UnsafeMutableRawPointer(
+                 Builtin.addressof(&self.header)))
+    #elseif arch(arm64)
+      let vr_top = storage._baseAddress + (_fpRegisterWords * _countFPRegisters)
+      let gr_top = vr_top + _countGPRegisters
+
+      return CVaListPointer(__stack: gr_top,
+                            __gr_top: gr_top,
+                            __vr_top: vr_top,
+                            __gr_off: -64,
+                            __vr_off: -128)
+    #endif
   }
 }
-#elseif arch(arm64) && os(Linux)
-
-// NOTE: older runtimes called this _VaListBuilder. The two must
-// coexist, so it was renamed. The old name must not be used in the new
-// runtime.
-@_fixed_layout // FIXME(sil-serialize-all)
-@usableFromInline // FIXME(sil-serialize-all)
-final internal class __VaListBuilder {
-  @usableFromInline // FIXME(sil-serialize-all)
-  internal init() {
-    // Prepare the register save area.
-    allocated = _registerSaveWords
-    storage = allocStorage(wordCount: allocated)
-    // Append stack arguments after register save area.
-    count = allocated
-  }
-
-  @usableFromInline // FIXME(sil-serialize-all)
-  deinit {
-    if let allocatedStorage = storage {
-      deallocStorage(wordCount: allocated, storage: allocatedStorage)
-    }
-  }
-
-  @usableFromInline // FIXME(sil-serialize-all)
-  internal func append(_ arg: CVarArg) {
-    var encoded = arg._cVarArgEncoding
-
-    if arg is _CVarArgPassedAsDouble
-      && fpRegistersUsed < _countFPRegisters {
-      var startIndex = (fpRegistersUsed * _fpRegisterWords)
-      for w in encoded {
-        storage[startIndex] = w
-        startIndex += 1
-      }
-      fpRegistersUsed += 1
-    } else if encoded.count == 1
-      && !(arg is _CVarArgPassedAsDouble)
-      && gpRegistersUsed < _countGPRegisters {
-      var startIndex = ( _fpRegisterWords * _countFPRegisters) + gpRegistersUsed
-      storage[startIndex] = encoded[0]
-      gpRegistersUsed += 1
-    } else {
-      // Arguments in stack slot.
-      appendWords(encoded)
-    }
-  }
-
-  @usableFromInline // FIXME(sil-serialize-all)
-  internal func va_list() -> CVaListPointer {
-    let vr_top = storage + (_fpRegisterWords * _countFPRegisters)
-    let gr_top = vr_top + _countGPRegisters
-
-    return CVaListPointer(__stack: gr_top, __gr_top: gr_top,
-                          __vr_top: vr_top, __gr_off: -64, __vr_off: -128)
-  }
-
-  @usableFromInline // FIXME(sil-serialize-all)
-  internal func appendWords(_ words: [Int]) {
-    let newCount = count + words.count
-    if newCount > allocated {
-      let oldAllocated = allocated
-      let oldStorage = storage
-      let oldCount = count
-
-      allocated = max(newCount, allocated * 2)
-      let newStorage = allocStorage(wordCount: allocated)
-      storage = newStorage
-      // Count is updated below.
-      if let allocatedOldStorage = oldStorage {
-        newStorage.moveInitialize(from: allocatedOldStorage, count: oldCount)
-        deallocStorage(wordCount: oldAllocated, storage: allocatedOldStorage)
-      }
-    }
-
-    let allocatedStorage = storage!
-    for word in words {
-      allocatedStorage[count] = word
-      count += 1
-    }
-  }
-
-  @usableFromInline // FIXME(sil-serialize-all)
-  internal func rawSizeAndAlignment(
-    _ wordCount: Int
-  ) -> (Builtin.Word, Builtin.Word) {
-    return ((wordCount * MemoryLayout<Int>.stride)._builtinWordValue,
-      requiredAlignmentInBytes._builtinWordValue)
-  }
-
-  @usableFromInline // FIXME(sil-serialize-all)
-  internal func allocStorage(wordCount: Int) -> UnsafeMutablePointer<Int> {
-    let (rawSize, rawAlignment) = rawSizeAndAlignment(wordCount)
-    let rawStorage = Builtin.allocRaw(rawSize, rawAlignment)
-    return UnsafeMutablePointer<Int>(rawStorage)
-  }
-
-  @usableFromInline // FIXME(sil-serialize-all)
-  internal func deallocStorage(
-    wordCount: Int, storage: UnsafeMutablePointer<Int>
-  ) {
-    let (rawSize, rawAlignment) = rawSizeAndAlignment(wordCount)
-    Builtin.deallocRaw(storage._rawValue, rawSize, rawAlignment)
-  }
-
-  @usableFromInline // FIXME(sil-serialize-all)
-  internal let requiredAlignmentInBytes = MemoryLayout<Double>.alignment
-
-  @usableFromInline // FIXME(sil-serialize-all)
-  internal var count = 0
-
-  @usableFromInline // FIXME(sil-serialize-all)
-  internal var allocated = 0
-
-  @usableFromInline // FIXME(sil-serialize-all)
-  internal var storage: UnsafeMutablePointer<Int>!
-
-  @usableFromInline // FIXME(sil-serialize-all)
-  internal var gpRegistersUsed = 0
-
-  @usableFromInline // FIXME(sil-serialize-all)
-  internal var fpRegistersUsed = 0
-
-  @usableFromInline // FIXME(sil-serialize-all)
-  internal var overflowWordsUsed = 0
-}
 
 #else
 
diff --git a/stdlib/public/runtime/Metadata.cpp b/stdlib/public/runtime/Metadata.cpp
index 8e7287e..6e3f00a 100644
--- a/stdlib/public/runtime/Metadata.cpp
+++ b/stdlib/public/runtime/Metadata.cpp
@@ -2204,9 +2204,24 @@
 
   auto string = Demangle::mangleNodeOld(globalNode);
 
-  auto fullNameBuf = (char*)swift_slowAlloc(string.size() + 1, 0);
+  // If the class is in the Swift module, add a $ to the end of the ObjC
+  // name. The old and new Swift libraries must be able to coexist in
+  // the same process, and this avoids warnings due to the ObjC names
+  // colliding.
+  bool addSuffix = strncmp(string.c_str(), "_TtGCs", 6) == 0;
+
+  size_t allocationSize = string.size() + 1;
+  if (addSuffix)
+    allocationSize += 1;
+  
+  auto fullNameBuf = (char*)swift_slowAlloc(allocationSize, 0);
   memcpy(fullNameBuf, string.c_str(), string.size() + 1);
 
+  if (addSuffix) {
+    fullNameBuf[string.size()] = '$';
+    fullNameBuf[string.size() + 1] = '\0';
+  }
+
   auto theMetaclass = (ClassMetadata *)object_getClass((id)theClass);
 
   getROData(theClass)->Name = fullNameBuf;
diff --git a/stdlib/public/stubs/GlobalObjects.cpp b/stdlib/public/stubs/GlobalObjects.cpp
index aeed5ae..a59c3c1 100644
--- a/stdlib/public/stubs/GlobalObjects.cpp
+++ b/stdlib/public/stubs/GlobalObjects.cpp
@@ -28,13 +28,13 @@
 SWIFT_RUNTIME_STDLIB_API
 ClassMetadata CLASS_METADATA_SYM(s19__EmptyArrayStorage);
 
-// _direct type metadata for Swift._EmptyDictionarySingleton
+// _direct type metadata for Swift.__EmptyDictionarySingleton
 SWIFT_RUNTIME_STDLIB_API
-ClassMetadata CLASS_METADATA_SYM(s25_EmptyDictionarySingleton);
+ClassMetadata CLASS_METADATA_SYM(s26__EmptyDictionarySingleton);
 
-// _direct type metadata for Swift._EmptySetSingleton
+// _direct type metadata for Swift.__EmptySetSingleton
 SWIFT_RUNTIME_STDLIB_API
-ClassMetadata CLASS_METADATA_SYM(s18_EmptySetSingleton);
+ClassMetadata CLASS_METADATA_SYM(s19__EmptySetSingleton);
 } // namespace swift
 
 SWIFT_RUNTIME_STDLIB_API
@@ -55,7 +55,7 @@
 swift::_SwiftEmptyDictionarySingleton swift::_swiftEmptyDictionarySingleton = {
   // HeapObject header;
   {
-    &swift::CLASS_METADATA_SYM(s25_EmptyDictionarySingleton), // isa pointer
+    &swift::CLASS_METADATA_SYM(s26__EmptyDictionarySingleton), // isa pointer
   },
   
   // _SwiftDictionaryBodyStorage body;
@@ -82,7 +82,7 @@
 swift::_SwiftEmptySetSingleton swift::_swiftEmptySetSingleton = {
   // HeapObject header;
   {
-    &swift::CLASS_METADATA_SYM(s18_EmptySetSingleton), // isa pointer
+    &swift::CLASS_METADATA_SYM(s19__EmptySetSingleton), // isa pointer
   },
   
   // _SwiftSetBodyStorage body;
diff --git a/test/ClangImporter/private_frameworks.swift b/test/ClangImporter/private_frameworks.swift
index fe36da2..733ec81 100644
--- a/test/ClangImporter/private_frameworks.swift
+++ b/test/ClangImporter/private_frameworks.swift
@@ -12,7 +12,7 @@
 // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil -o /dev/null -F %S/Inputs/privateframeworks/withprivate -swift-version 4 %s -import-objc-header %S/Inputs/privateframeworks/bridging-somekitcore.h -verify
 
 // Use the overlay without private frameworks.
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil -o /dev/null -F %S/Inputs/privateframeworks/withoutprivate -I %t -swift-version 4 -import-objc-header %S/Inputs/privateframeworks/bridging-somekit.h %s
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil -o /dev/null -F %S/Inputs/privateframeworks/withoutprivate -swift-version 4 -import-objc-header %S/Inputs/privateframeworks/bridging-somekit.h %s
 
 // Build the overlay with public frameworks.
 // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -F %S/Inputs/privateframeworks/withoutprivate -o %t %S/Inputs/privateframeworks/overlay/SomeKit.swift
@@ -21,7 +21,18 @@
 // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil -o /dev/null -F %S/Inputs/privateframeworks/withprivate -swift-version 4 %s -import-objc-header %S/Inputs/privateframeworks/bridging-somekitcore.h -verify
 
 // Use the overlay without private frameworks.
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil -o /dev/null -F %S/Inputs/privateframeworks/withoutprivate -I %t -swift-version 4 %s -import-objc-header %S/Inputs/privateframeworks/bridging-somekit.h 
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil -o /dev/null -F %S/Inputs/privateframeworks/withoutprivate -swift-version 4 %s -import-objc-header %S/Inputs/privateframeworks/bridging-somekit.h 
+
+// Use something that uses the overlay.
+// RUN: echo 'import private_frameworks; testErrorConformance()' > %t/main.swift
+
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -o %t -F %S/Inputs/privateframeworks/withprivate -swift-version 4 %s -import-objc-header %S/Inputs/privateframeworks/bridging-somekitcore.h
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil -o /dev/null -F %S/Inputs/privateframeworks/withprivate %t/main.swift -verify
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil -o /dev/null -F %S/Inputs/privateframeworks/withoutprivate %t/main.swift -verify
+
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -o %t -F %S/Inputs/privateframeworks/withoutprivate -swift-version 4 %s -import-objc-header %S/Inputs/privateframeworks/bridging-somekit.h
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil -o /dev/null -F %S/Inputs/privateframeworks/withprivate %t/main.swift -verify
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil -o /dev/null -F %S/Inputs/privateframeworks/withoutprivate %t/main.swift -verify
 
 // REQUIRES: objc_interop
 
@@ -50,3 +61,6 @@
   SomeKit.someKitOtherGlobalFunc()
   someKitOtherGlobalFunc()
 }
+
+public struct ErrorsOnly<T: Error> {}
+public func testErrorConformance(_ code: ErrorsOnly<SKWidget.Error>? = nil) {}
diff --git a/test/IRGen/autolink-coff-force-link.swift b/test/IRGen/autolink-coff-force-link.swift
index 71422e1..e6a8fce 100644
--- a/test/IRGen/autolink-coff-force-link.swift
+++ b/test/IRGen/autolink-coff-force-link.swift
@@ -14,7 +14,7 @@
 
 import swiftMSVCRT
 
-// CHECK: @"_swift_FORCE_LOAD_$_swiftMSVCRT_$_autolink" = weak hidden constant void ()* @"_swift_FORCE_LOAD_$_swiftMSVCRT"
+// CHECK: @"_swift_FORCE_LOAD_$_swiftMSVCRT_$_autolink" = weak_odr hidden constant void ()* @"_swift_FORCE_LOAD_$_swiftMSVCRT"
 // CHECK: define dllexport void @"_swift_FORCE_LOAD_$_autolink"()
 
 // CHECK-ASM-GNU: .ascii  " -export:__swift_FORCE_LOAD_$_autolink"
diff --git a/test/IRGen/c_functions.swift b/test/IRGen/c_functions.swift
index f6fc966..20e4123 100644
--- a/test/IRGen/c_functions.swift
+++ b/test/IRGen/c_functions.swift
@@ -1,13 +1,13 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -import-objc-header %S/Inputs/c_functions.h -primary-file %s -emit-ir | %FileCheck %s -check-prefix CHECK -check-prefix %target-cpu
+// RUN: %target-swift-frontend -enable-objc-interop -disable-objc-attr-requires-foundation-module -import-objc-header %S/Inputs/c_functions.h -primary-file %s -emit-ir | %FileCheck %s -check-prefix CHECK -check-prefix %target-cpu
 
 // This is deliberately not a SIL test so that we can test SILGen too.
 
 // CHECK-LABEL: define hidden swiftcc void @"$s11c_functions14testOverloadedyyF"
 func testOverloaded() {
-  // CHECK: call void @{{_Z10overloadedv|"\\01\?overloaded@@\$\$J0YAXXZ"}}()
+  // CHECK: call void @{{_Z10overloadedv|"\?overloaded@@\$\$J0YAXXZ"}}()
   overloaded()
-  // CHECK: call void @{{_Z10overloadedi|"\\01\?overloaded@@\$\$J0YAXH@Z"}}(i32{{( signext)?}} 42)
+  // CHECK: call void @{{_Z10overloadedi|"\?overloaded@@\$\$J0YAXH@Z"}}(i32{{( signext)?}} 42)
   overloaded(42)
   // CHECK: call void @{{.*}}test_my_log
   test_my_log()
diff --git a/test/IRGen/class.sil b/test/IRGen/class.sil
index b161747..0fe2463 100644
--- a/test/IRGen/class.sil
+++ b/test/IRGen/class.sil
@@ -34,7 +34,7 @@
 
 //   CHECK: @"$s5class1CCMf" = internal global <{ {{.*}} }> <{
 // \ CHECK:   void ([[C_CLASS]]*)* @"$s5class1CCfD",
-// \ CHECK:   i8** @"$sBoWV",
+// \ CHECK:   i8** {{@"\$sBoWV"|null}},
 // \ CHECK:   i64 ptrtoint ([[OBJCCLASS]]* @"$s5class1CCMm" to i64),
 // \ CHECK:   [[OBJCCLASS]]* @"OBJC_CLASS_$_{{(_TtCs12_)?}}SwiftObject",
 // \ CHECK:   [[OPAQUE]]* @_objc_empty_cache,
diff --git a/test/IRGen/class_resilience.swift b/test/IRGen/class_resilience.swift
index c7285aa..831a86d 100644
--- a/test/IRGen/class_resilience.swift
+++ b/test/IRGen/class_resilience.swift
@@ -30,7 +30,7 @@
 
 // CHECK: @"$s16class_resilience14ResilientChildCMo" = {{(protected )?}}{{(dllexport )?}}global [[BOUNDS]] zeroinitializer
 
-// CHECK: @"$s15resilient_class22ResilientOutsideParentC8getValueSiyFTq" = external global %swift.method_descriptor
+// CHECK: @"$s15resilient_class22ResilientOutsideParentC8getValueSiyFTq" = external{{( dllimport)?}} global %swift.method_descriptor
 
 // CHECK: @"$s16class_resilience14ResilientChildCMn" = {{(protected )?}}{{(dllexport )?}}constant <{{.*}}> <{
 // --       flags: class, unique, has vtable, has override table, in-place initialization, has resilient superclass
@@ -54,7 +54,7 @@
 // --       field offset vector offset:
 // CHECK-SAME:   i32 0,
 // -- superclass:
-// CHECK-SAME:   @"got.$s15resilient_class22ResilientOutsideParentCMn"
+// CHECK-SAME:   @"{{got.|__imp_}}$s15resilient_class22ResilientOutsideParentCMn"
 // --       singleton metadata initialization cache:
 // CHECK-SAME:   @"$s16class_resilience14ResilientChildCMl"
 // --       resilient pattern:
@@ -65,17 +65,17 @@
 // CHECK-SAME:   i32 2,
 // CHECK-SAME:   %swift.method_override_descriptor {
 // --       base class:
-// CHECK-SAME:   @"got.$s15resilient_class22ResilientOutsideParentCMn"
+// CHECK-SAME:   @"{{got.|__imp_}}$s15resilient_class22ResilientOutsideParentCMn"
 // --       base method:
-// CHECK-SAME:   @"got.$s15resilient_class22ResilientOutsideParentC8getValueSiyFTq"
+// CHECK-SAME:   @"{{got.|__imp_}}$s15resilient_class22ResilientOutsideParentC8getValueSiyFTq"
 // --       implementation:
 // CHECK-SAME:   @"$s16class_resilience14ResilientChildC8getValueSiyF"
 // CHECK-SAME:   }
 // CHECK-SAME:   %swift.method_override_descriptor {
 // --       base class:
-// CHECK-SAME:   @"got.$s15resilient_class22ResilientOutsideParentCMn"
+// CHECK-SAME:   @"{{got.|__imp_}}$s15resilient_class22ResilientOutsideParentCMn"
 // --       base method:
-// CHECK-SAME:   @"got.$s15resilient_class22ResilientOutsideParentCACycfCTq"
+// CHECK-SAME:   @"{{got.|__imp_}}$s15resilient_class22ResilientOutsideParentCACycfCTq"
 // --       implementation:
 // CHECK-SAME:   @"$s16class_resilience14ResilientChildCACycfC"
 // CHECK-SAME:   }
diff --git a/test/IRGen/dead_method.swift b/test/IRGen/dead_method.swift
index b6a2127..fd52c73 100644
--- a/test/IRGen/dead_method.swift
+++ b/test/IRGen/dead_method.swift
@@ -37,7 +37,7 @@
 // CHECK-SAME:   void (%T11dead_method5ClassC*)* @"$s11dead_method5ClassCfD",
 
 // -- value witness table
-// CHECK-SAME:   i8** @"$sBoWV",
+// CHECK-SAME:   i8** {{@"\$sBoWV"|null}},
 
 // -- nominal type descriptor
 // CHECK-SAME:   @"$s11dead_method5ClassCMn",
diff --git a/test/IRGen/generic_vtable.swift b/test/IRGen/generic_vtable.swift
index b84079d..48259c4 100644
--- a/test/IRGen/generic_vtable.swift
+++ b/test/IRGen/generic_vtable.swift
@@ -41,7 +41,7 @@
 // -- destructor
 // CHECK-SAME: void (%T14generic_vtable4BaseC*)* @"$s14generic_vtable4BaseCfD"
 // -- value witness table
-// CHECK-SAME: i8** @"$sBoWV"
+// CHECK-SAME: i8** {{@"\$sBoWV"|null}}
 // -- vtable entry for 'm1()'
 // CHECK-SAME: void (%T14generic_vtable4BaseC*)* @"$s14generic_vtable4BaseC2m1yyF"
 // -- vtable entry for 'm2()'
diff --git a/test/IRGen/ivar_destroyer.sil b/test/IRGen/ivar_destroyer.sil
index e339aa4..c700b3b 100644
--- a/test/IRGen/ivar_destroyer.sil
+++ b/test/IRGen/ivar_destroyer.sil
@@ -8,7 +8,7 @@
 
 // CHECK-LABEL: @"$s14ivar_destroyer17NonTrivialDerivedCMf" = internal global <{ {{.*}} }> <{
 // CHECK-SAME:    i8* null,
-// CHECK-SAME:    i8** @"$sBoWV",
+// CHECK-SAME:    i8** {{@"\$sBoWV"|null}},
 // CHECK-SAME:    i64 ptrtoint ([[OBJCCLASS]]* @"$s14ivar_destroyer17NonTrivialDerivedCMm" to i64),
 // CHECK-SAME:    [[TYPE]]* bitcast (i64* getelementptr inbounds (<{ {{.*}} }>, <{ {{.*}} }>* @"$s14ivar_destroyer11TrivialBaseCMf", i32 0, i32 2) to [[TYPE]]*),
 // CHECK-SAME:    [[OPAQUE]]* @_objc_empty_cache,
diff --git a/test/IRGen/keypath_witness_overrides.swift b/test/IRGen/keypath_witness_overrides.swift
index 6649ee1..a2cc3f3 100644
--- a/test/IRGen/keypath_witness_overrides.swift
+++ b/test/IRGen/keypath_witness_overrides.swift
@@ -5,7 +5,7 @@
 import protocol_overrides
 
 // CHECK: @keypath = private global
-// CHECK-SAME: %swift.method_descriptor** @"got.$s18protocol_overrides14OriginalGetterPy7ElementQz5IndexQzcigTq"
+// CHECK-SAME: %swift.method_descriptor** @"{{got.|__imp_}}$s18protocol_overrides14OriginalGetterPy7ElementQz5IndexQzcigTq"
 public func getWritableKeyPath<OS: OverridesSetter>(_ c: OS, index: OS.Index) -> AnyKeyPath
 where OS.Index: Hashable {
   let keypath = \OS.[index]
diff --git a/test/IRGen/keypaths.sil b/test/IRGen/keypaths.sil
index d71a08f..92838a8 100644
--- a/test/IRGen/keypaths.sil
+++ b/test/IRGen/keypaths.sil
@@ -157,7 +157,7 @@
 // CHECK-SAME: <i32 0x8000_000c>,
 // -- computed, get-only, identified by (indirected) function pointer, no args
 // CHECK-SAME: <i32 0x0200_0002>,
-// CHECK-SAME: @got.k_id
+// CHECK-SAME: @{{got.|__imp_}}k_id
 // CHECK-SAME: void (%TSi*, %T8keypaths1SV*)* @k_get
 
 // -- %l: computed
@@ -169,7 +169,7 @@
 // CHECK-SAME: <i32 0x8000_0010>,
 // -- computed, settable, nonmutating, identified by indirect pointer, no args
 // CHECK-SAME: <i32 0x0240_0002>,
-// CHECK-SAME: @"got.$s8keypaths1CC1wSivgTq"
+// CHECK-SAME: @"{{got.|__imp_}}$s8keypaths1CC1wSivgTq"
 // CHECK-SAME: void (%TSi*, %T8keypaths1CC**)* @l_get
 // CHECK-SAME: void (%TSi*, %T8keypaths1CC**)* @l_set
 
diff --git a/test/IRGen/keypaths_external.sil b/test/IRGen/keypaths_external.sil
index 3b06e79..813b711 100644
--- a/test/IRGen/keypaths_external.sil
+++ b/test/IRGen/keypaths_external.sil
@@ -41,13 +41,13 @@
 sil @s_hash : $@convention(thin) <A: Hashable, B: Hashable> (UnsafeRawPointer) -> Int
 
 // -- %t
-// CHECK: [[KP_T:@keypath(\..*)?]] = private global <{ {{.*}} }> <{ {{.*}} i32 1, {{.*}} @"got.$s23keypaths_external_other1GV1xxvpMV"
+// CHECK: [[KP_T:@keypath(\..*)?]] = private global <{ {{.*}} }> <{ {{.*}} i32 1, {{.*}} @"{{got.|__imp_}}$s23keypaths_external_other1GV1xxvpMV"
 // CHECK-SAME:   @"symbolic x"
 //            -- computed get-only property, identified by indirect pointer
 // CHECK-SAME:   <i32 0x0208_0002>
 
 // -- %u
-// CHECK: [[KP_U:@keypath(\..*)?]] = private global <{ {{.*}} }> <{ {{.*}} i32 3, {{.*}} @"got.$s23keypaths_external_other1GVyxqd__cSHRd__luipMV"
+// CHECK: [[KP_U:@keypath(\..*)?]] = private global <{ {{.*}} }> <{ {{.*}} i32 3, {{.*}} @"{{got.|__imp_}}$s23keypaths_external_other1GVyxqd__cSHRd__luipMV"
 // CHECK-SAME:   @"symbolic q_"
 // CHECK-SAME:   @"symbolic x"
 // CHECK-SAME:   @"keypath_get_witness_table
diff --git a/test/IRGen/property_descriptor.sil b/test/IRGen/property_descriptor.sil
index 96da26f..d857113 100644
--- a/test/IRGen/property_descriptor.sil
+++ b/test/IRGen/property_descriptor.sil
@@ -54,7 +54,7 @@
 // CHECK: @"$s19property_descriptor15ExternalGenericV10computedROxvpMV" =
 // -- 0x0108_0000 - computed, readonly, has arguments, identified by indirect
 // CHECK-SAME:  <{ <i32 0x0208_0002>,
-// CHECK-SAME:     @got.id_computed
+// CHECK-SAME:     @{{got.|__imp_}}id_computed
 // CHECK-SAME:     [[GET_COMPUTEDRO:@keypath_get[.0-9]*]]
 // CHECK-SAME:     [[GET_ARG_LAYOUT_COMPUTEDRO:@keypath_get_arg_layout[.0-9]*]]
 // -- default witness table
@@ -68,7 +68,7 @@
 // CHECK: @"$s19property_descriptor15ExternalGenericV10computedRWxvpMV" =
 // -- 0x01c8_0000 - computed, settable, mutating, has arguments, indirect id
 // CHECK-SAME:  <{ <i32 0x02c8_0002>, 
-// CHECK-SAME:     @got.id_computed
+// CHECK-SAME:     @{{got.|__imp_}}id_computed
 // CHECK-SAME:     [[GET_COMPUTEDRW:@keypath_get[.0-9]*]]
 // CHECK-SAME:     [[SET_COMPUTEDRW:@keypath_set[.0-9]*]]
 // CHECK-SAME:     [[GET_ARG_LAYOUT_COMPUTEDRW:@keypath_get_arg_layout[.0-9]*]]
@@ -83,7 +83,7 @@
 // CHECK: @"$s19property_descriptor15ExternalGenericVyxqd__cSHRd__luipMV" =
 // -- 0x01c8_0000 - computed, settable, mutating, has arguments, indirect id
 // CHECK-SAME:  <{ <i32 0x02c8_0002>, 
-// CHECK-SAME:     @got.id_computed
+// CHECK-SAME:     @{{got.|__imp_}}id_computed
 // CHECK-SAME:     [[GET_SUBSCRIPT:@keypath_get[.0-9]*]]
 // CHECK-SAME:     [[SET_SUBSCRIPT:@keypath_set[.0-9]*]]
 // CHECK-SAME:     [[GET_ARG_LAYOUT_SUBSCRIPT:@keypath_get_arg_layout[.0-9]*]]
diff --git a/test/IRGen/protocol_resilience_descriptors.swift b/test/IRGen/protocol_resilience_descriptors.swift
index 8820e69..98e6582 100644
--- a/test/IRGen/protocol_resilience_descriptors.swift
+++ b/test/IRGen/protocol_resilience_descriptors.swift
@@ -18,7 +18,7 @@
 // CHECK: @"default assoc type \01____y2T118resilient_protocol29ProtocolWithAssocTypeDefaultsPQzG 18resilient_protocol7WrapperV" =
 
 // Protocol descriptor
-// CHECK-DEFINITION-LABEL: @"$s18resilient_protocol29ProtocolWithAssocTypeDefaultsMp" ={{( protected)?}} constant
+// CHECK-DEFINITION-LABEL: @"$s18resilient_protocol29ProtocolWithAssocTypeDefaultsMp" ={{( dllexport)?}}{{( protected)?}} constant
 // CHECK-DEFINITION-SAME: @"default associated conformance2T218resilient_protocol29ProtocolWithAssocTypeDefaultsP_AB014OtherResilientD0"
 
 // Associated type default + flags
diff --git a/test/IRGen/subclass.swift b/test/IRGen/subclass.swift
index b8af411..75463fb 100644
--- a/test/IRGen/subclass.swift
+++ b/test/IRGen/subclass.swift
@@ -13,7 +13,7 @@
 // CHECK: @_DATA__TtC8subclass1A = private constant {{.* } }}{
 // CHECK: @"$s8subclass1ACMf" = internal global [[A_METADATA:<{.* }>]] <{
 // CHECK-SAME:   void ([[A]]*)* @"$s8subclass1ACfD",
-// CHECK-SAME:   i8** @"$sBoWV",
+// CHECK-SAME:   i8** {{@"\$sBoWV"|null}},
 // CHECK-SAME:   i64 ptrtoint ([[OBJC_CLASS]]* @"$s8subclass1ACMm" to i64),
 // CHECK-SAME:   [[OBJC_CLASS]]* @"OBJC_CLASS_$_{{(_TtCs12_)?}}SwiftObject",
 // CHECK-SAME:   [[OPAQUE]]* @_objc_empty_cache,
@@ -25,7 +25,7 @@
 // CHECK: @_DATA__TtC8subclass1B = private constant {{.* } }}{
 // CHECK: @"$s8subclass1BCMf" = internal global <{ {{.*}} }> <{
 // CHECK-SAME:   void ([[B]]*)* @"$s8subclass1BCfD",
-// CHECK-SAME:   i8** @"$sBoWV",
+// CHECK-SAME:   i8** {{@"\$sBoWV"|null}},
 // CHECK-SAME:   i64 ptrtoint ([[OBJC_CLASS]]* @"$s8subclass1BCMm" to i64),
 // CHECK-SAME:   [[TYPE]]* {{.*}} @"$s8subclass1ACMf",
 // CHECK-SAME:   [[OPAQUE]]* @_objc_empty_cache,
diff --git a/test/IRGen/vtable.sil b/test/IRGen/vtable.sil
index cf1c42f..73847ab 100644
--- a/test/IRGen/vtable.sil
+++ b/test/IRGen/vtable.sil
@@ -20,7 +20,7 @@
 
 // CHECK-objc: @"$s6vtable1CCMf" = internal global [[C_METADATA_T:<{.*\* }>]] <{
 // CHECK-objc: void ([[C]]*)* @"$s6vtable1CCfD",
-// CHECK-objc: i8** @"$sBoWV",
+// CHECK-objc: i8** {{@"\$sBoWV"|null}},
 // CHECK-objc: i64 ptrtoint (%objc_class* @"$s6vtable1CCMm" to i64),
 // CHECK-objc: %objc_class* @"OBJC_CLASS_$_{{(_TtCs12_)?}}SwiftObject",
 // CHECK-objc: %swift.opaque* @_objc_empty_cache,
@@ -34,7 +34,7 @@
 
 // CHECK-native: @"$s6vtable1CCMf" = internal global [[C_METADATA_T:<{.*\* }>]] <{
 // CHECK-native: void ([[C]]*)* @"$s6vtable1CCfD",
-// CHECK-native: i8** @"$sBoWV",
+// CHECK-native: i8** {{@"\$sBoWV"|null}},
 // CHECK-native: i64 0,
 // CHECK-native: %swift.type* null,
 // CHECK-native: %swift.opaque* null,
diff --git a/test/IRGen/vtable_symbol_linkage.swift b/test/IRGen/vtable_symbol_linkage.swift
index 9191384..dea03b0 100644
--- a/test/IRGen/vtable_symbol_linkage.swift
+++ b/test/IRGen/vtable_symbol_linkage.swift
@@ -1,10 +1,10 @@
 // RUN: %empty-directory(%t)
 
-// RUN: %target-build-swift %S/Inputs/vtable_symbol_linkage_base.swift -emit-module -emit-module-path=%t/BaseModule.swiftmodule -emit-library -module-name BaseModule -o %t/BaseModule%{target-shared-library-suffix}
-// RUN: %target-build-swift -I %t %s %t/BaseModule%{target-shared-library-suffix} -o %t/a.out
+// RUN: %target-build-swift %S/Inputs/vtable_symbol_linkage_base.swift -emit-module -emit-module-path=%t/BaseModule.swiftmodule -emit-library -module-name BaseModule -o %t/%target-library-name(BaseModule)
+// RUN: %target-build-swift -I %t %s -o %t/a.out -L%t -lBaseModule
 
-// RUN: %target-build-swift %S/Inputs/vtable_symbol_linkage_base.swift -emit-module -emit-module-path=%t/BaseModule.swiftmodule -emit-library -module-name BaseModule -o %t/BaseModule%{target-shared-library-suffix} -Xfrontend -enable-resilience -Xfrontend -enable-class-resilience
-// RUN: %target-build-swift -I %t %s %t/BaseModule%{target-shared-library-suffix} -o %t/a.out -Xfrontend -enable-class-resilience
+// RUN: %target-build-swift %S/Inputs/vtable_symbol_linkage_base.swift -emit-module -emit-module-path=%t/BaseModule.swiftmodule -emit-library -module-name BaseModule -o %t/%target-library-name(BaseModule) -Xfrontend -enable-resilience -Xfrontend -enable-class-resilience
+// RUN: %target-build-swift -I %t %s -o %t/a.out -Xfrontend -enable-class-resilience -L%t -lBaseModule
 
 // Check if the program can be linked without undefined symbol errors.
 
diff --git a/test/Interpreter/convenience_init_peer_delegation.swift b/test/Interpreter/convenience_init_peer_delegation.swift
index 95a39bc..ae369ca 100644
--- a/test/Interpreter/convenience_init_peer_delegation.swift
+++ b/test/Interpreter/convenience_init_peer_delegation.swift
@@ -100,12 +100,13 @@
 
 /// Checks that `op` performs `base` allocations of Base and `sub` allocations
 /// of Sub.
+@inline(never)
 func check(base: Int = 0, sub: Int = 0,
            file: StaticString = #file, line: UInt = #line,
-           op: () -> Void) {
+           op: () -> AnyObject) {
   baseCounter = 0
   subCounter = 0
-  op()
+  _ = op()
   precondition(baseCounter == base,
                "expected \(base) Base instances, got \(baseCounter)",
                file: file, line: line)
@@ -114,48 +115,49 @@
                file: file, line: line)
 }
 
+
 // CHECK: START
 print("START")
 
 // Check that this whole setup works.
 // CHECK-NEXT: init(swift:) Base
-check(base: 1) { _ = Base(swift: ()) }
+check(base: 1) { Base(swift: ()) }
 // CHECK-NEXT: init(swift:) Sub
-check(sub: 1) { _ = Sub(swift: ()) }
+check(sub: 1) { Sub(swift: ()) }
 // CHECK-NEXT: init(objc:) Base
-check(base: 1) { _ = Base(objc: ()) }
+check(base: 1) { Base(objc: ()) }
 // CHECK-NEXT: init(objc:) Sub
-check(sub: 1) { _ = Sub(objc: ()) }
+check(sub: 1) { Sub(objc: ()) }
 
 // CHECK-NEXT: init(swiftToSwift:) Sub
 // CHECK-NEXT: init(swift:) Sub
-check(sub: 1) { _ = Sub(swiftToSwift: ()) }
+check(sub: 1) { Sub(swiftToSwift: ()) }
 // CHECK-NEXT: init(objcToSwift:) Sub
 // CHECK-NEXT: init(swift:) Sub
-check(sub: 2) { _ = Sub(objcToSwift: ()) }
+check(sub: 2) { Sub(objcToSwift: ()) }
 // CHECK-NEXT: init(swiftToObjC:) Sub
 // CHECK-NEXT: init(objc:) Sub
-check(sub: 1) { _ = Sub(swiftToObjC: ()) }
+check(sub: 1) { Sub(swiftToObjC: ()) }
 // CHECK-NEXT: init(objcToObjC:) Sub
 // CHECK-NEXT: init(objc:) Sub
-check(sub: 1) { _ = Sub(objcToObjC: ()) }
+check(sub: 1) { Sub(objcToObjC: ()) }
 
 // CHECK-NEXT: init(swiftToSwiftConvenience:) Sub
 // CHECK-NEXT: init(swiftToSwift:) Sub
 // CHECK-NEXT: init(swift:) Sub
-check(sub: 1) { _ = Sub(swiftToSwiftConvenience: ()) }
+check(sub: 1) { Sub(swiftToSwiftConvenience: ()) }
 // CHECK-NEXT: init(objcToSwiftConvenience:) Sub
 // CHECK-NEXT: init(swiftToSwift:) Sub
 // CHECK-NEXT: init(swift:) Sub
-check(sub: 2) { _ = Sub(objcToSwiftConvenience: ()) }
+check(sub: 2) { Sub(objcToSwiftConvenience: ()) }
 // CHECK-NEXT: init(swiftToObjCConvenience:) Sub
 // CHECK-NEXT: init(objcToObjC:) Sub
 // CHECK-NEXT: init(objc:) Sub
-check(sub: 1) { _ = Sub(swiftToObjCConvenience: ()) }
+check(sub: 1) { Sub(swiftToObjCConvenience: ()) }
 // CHECK-NEXT: init(objcToObjCConvenience:) Sub
 // CHECK-NEXT: init(objcToObjC:) Sub
 // CHECK-NEXT: init(objc:) Sub
-check(sub: 1) { _ = Sub(objcToObjCConvenience: ()) }
+check(sub: 1) { Sub(objcToObjCConvenience: ()) }
 
 // Force ObjC dispatch without conforming Sub or Base to the protocol,
 // because it's possible that `required` perturbs things and we want to test
@@ -164,21 +166,21 @@
                               to: ForceObjCDispatch.Type.self)
 
 // CHECK-NEXT: init(objc:) Sub
-check(sub: 1) { _ = SubAsObjC.init(objc: ()) }
+check(sub: 1) { SubAsObjC.init(objc: ()) }
 // CHECK-NEXT: init(objcToSwift:) Sub
 // CHECK-NEXT: init(swift:) Sub
-check(sub: 2) { _ = SubAsObjC.init(objcToSwift: ()) }
+check(sub: 2) { SubAsObjC.init(objcToSwift: ()) }
 // CHECK-NEXT: init(objcToObjC:) Sub
 // CHECK-NEXT: init(objc:) Sub
-check(sub: 1) { _ = SubAsObjC.init(objcToObjC: ()) }
+check(sub: 1) { SubAsObjC.init(objcToObjC: ()) }
 // CHECK-NEXT: init(objcToSwiftConvenience:) Sub
 // CHECK-NEXT: init(swiftToSwift:) Sub
 // CHECK-NEXT: init(swift:) Sub
-check(sub: 2) { _ = SubAsObjC.init(objcToSwiftConvenience: ()) }
+check(sub: 2) { SubAsObjC.init(objcToSwiftConvenience: ()) }
 // CHECK-NEXT: init(objcToObjCConvenience:) Sub
 // CHECK-NEXT: init(objcToObjC:) Sub
 // CHECK-NEXT: init(objc:) Sub
-check(sub: 1) { _ = SubAsObjC.init(objcToObjCConvenience: ()) }
+check(sub: 1) { SubAsObjC.init(objcToObjCConvenience: ()) }
 
 // CHECK-NEXT: END
 print("END")
diff --git a/test/Migrator/Inputs/CallExpr.json b/test/Migrator/Inputs/CallExpr.json
new file mode 100644
index 0000000..ec11dd5
--- /dev/null
+++ b/test/Migrator/Inputs/CallExpr.json
@@ -0,0 +1,24 @@
+[
+  {
+    "DiffItemKind": "CommonDiffItem",
+    "NodeKind": "Function",
+    "NodeAnnotation": "WrapOptional",
+    "ChildIndex": "0",
+    "LeftUsr": "s:6CitiesAAC1xABSi_tcfc",
+    "LeftComment": "",
+    "RightUsr": "",
+    "RightComment": "",
+    "ModuleName": "Cities"
+  },
+  {
+    "DiffItemKind": "CommonDiffItem",
+    "NodeKind": "Function",
+    "NodeAnnotation": "WrapOptional",
+    "ChildIndex": "0",
+    "LeftUsr": "s:6CitiesAAC5noosaSaySDySSABGSgGyF",
+    "LeftComment": "",
+    "RightUsr": "",
+    "RightComment": "",
+    "ModuleName": "Cities"
+  }
+]
diff --git a/test/Migrator/call_expr_result.swift b/test/Migrator/call_expr_result.swift
new file mode 100644
index 0000000..01f1c8b
--- /dev/null
+++ b/test/Migrator/call_expr_result.swift
@@ -0,0 +1,13 @@
+// REQUIRES: objc_interop
+// RUN: %empty-directory(%t.mod)
+// RUN: %target-swift-frontend -emit-module -o %t.mod/Cities.swiftmodule %S/Inputs/Cities.swift -module-name Cities -parse-as-library
+// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -disable-migrator-fixits -primary-file %s  -I %t.mod -api-diff-data-file %S/Inputs/CallExpr.json -emit-migrated-file-path %t/call_expr_result.swift.result -o /dev/null
+// RUN: diff -u %S/call_expr_result.swift.expected %t/call_expr_result.swift.result
+
+import Cities
+
+func foo() {
+  let c1 = Cities(x: 3)
+  _ = Cities.init(x: 3)
+  _ = c1.noosa()
+}
\ No newline at end of file
diff --git a/test/Migrator/call_expr_result.swift.expected b/test/Migrator/call_expr_result.swift.expected
new file mode 100644
index 0000000..4210d21
--- /dev/null
+++ b/test/Migrator/call_expr_result.swift.expected
@@ -0,0 +1,13 @@
+// REQUIRES: objc_interop
+// RUN: %empty-directory(%t.mod)
+// RUN: %target-swift-frontend -emit-module -o %t.mod/Cities.swiftmodule %S/Inputs/Cities.swift -module-name Cities -parse-as-library
+// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -disable-migrator-fixits -primary-file %s  -I %t.mod -api-diff-data-file %S/Inputs/CallExpr.json -emit-migrated-file-path %t/call_expr_result.swift.result -o /dev/null
+// RUN: diff -u %S/call_expr_result.swift.expected %t/call_expr_result.swift.result
+
+import Cities
+
+func foo() {
+  let c1 = Cities(x: 3)!
+  _ = Cities.init(x: 3)!
+  _ = c1.noosa()!
+}
\ No newline at end of file
diff --git a/test/Migrator/rename.swift b/test/Migrator/rename.swift
index 1f66e5b..2b9ca6e 100644
--- a/test/Migrator/rename.swift
+++ b/test/Migrator/rename.swift
@@ -1,5 +1,5 @@
 // REQUIRES: objc_interop
-// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -api-diff-data-file %S/Inputs/API.json -emit-migrated-file-path %t/rename.swift.result -emit-remap-file-path %t/rename.swift.remap -o /dev/null
+// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -api-diff-data-file %S/Inputs/API.json -emit-migrated-file-path %t/rename.swift.result -emit-remap-file-path %t/rename.swift.remap -o /dev/null -disable-migrator-fixits
 // RUN: diff -u %S/rename.swift.expected %t/rename.swift.result
 
 import Bar
diff --git a/test/Migrator/rename.swift.expected b/test/Migrator/rename.swift.expected
index a19c26d..7f0670e 100644
--- a/test/Migrator/rename.swift.expected
+++ b/test/Migrator/rename.swift.expected
@@ -1,5 +1,5 @@
 // REQUIRES: objc_interop
-// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -api-diff-data-file %S/Inputs/API.json -emit-migrated-file-path %t/rename.swift.result -emit-remap-file-path %t/rename.swift.remap -o /dev/null
+// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -api-diff-data-file %S/Inputs/API.json -emit-migrated-file-path %t/rename.swift.result -emit-remap-file-path %t/rename.swift.remap -o /dev/null -disable-migrator-fixits
 // RUN: diff -u %S/rename.swift.expected %t/rename.swift.result
 
 import Bar
@@ -16,7 +16,7 @@
   b.barNewInstanceFunc1(newlabel1: 0, newlabel2: 1, newlabel3: 2, newlabel4: 3)
   barGlobalFuncNewName(newlabel: 2)
   _ = NewEnum.enumElement
-  _ = PropertyUserInterface.newMethodPlus()
+  _ = PropertyUserInterface.newMethodPlus()!
   let _: BarBase.Nested
   _ = AwesomeWrapper.newName(is: 0, at: 1, for: 2)
 }
diff --git a/test/Migrator/stdlib_rename.swift b/test/Migrator/stdlib_rename.swift
index 20397f3..d5ae2b3 100644
--- a/test/Migrator/stdlib_rename.swift
+++ b/test/Migrator/stdlib_rename.swift
@@ -6,6 +6,7 @@
 
 func test1(_ a: [String], s: String) {
   _ = a.index(of: s)
+  _ = a.index(where: { _ in true })
 }
 func test2(_ s: String, c: Character) {
   _ = s.index(of: c)
diff --git a/test/Migrator/stdlib_rename.swift.expected b/test/Migrator/stdlib_rename.swift.expected
index f721bf8..04dadba 100644
--- a/test/Migrator/stdlib_rename.swift.expected
+++ b/test/Migrator/stdlib_rename.swift.expected
@@ -6,6 +6,7 @@
 
 func test1(_ a: [String], s: String) {
   _ = a.firstIndex(of: s)
+  _ = a.firstIndex(where: { _ in true })
 }
 func test2(_ s: String, c: Character) {
   _ = s.firstIndex(of: c)
diff --git a/test/Migrator/wrap_optional.swift.expected b/test/Migrator/wrap_optional.swift.expected
index 78fe2b5..1316b6d 100644
--- a/test/Migrator/wrap_optional.swift.expected
+++ b/test/Migrator/wrap_optional.swift.expected
@@ -7,7 +7,7 @@
 import Cities
 
 class MyCities : Cities {
-  override init?(x: Int?) { super.init(x: x) }
+  override init?(x: Int?) { super.init(x: x)! }
   override init?(y: Int) { super.init(y: y) }
   override func newMooloolaba(newX x: Cities?, newY y: Cities) {}
   override func toowoomba(x: [Cities?], y: [Cities?]) {}
diff --git a/test/ParseableInterface/ModuleCache/force-module-loading-mode-archs.swift b/test/ParseableInterface/ModuleCache/force-module-loading-mode-archs.swift
index 7e105c3..195b4c1 100644
--- a/test/ParseableInterface/ModuleCache/force-module-loading-mode-archs.swift
+++ b/test/ParseableInterface/ModuleCache/force-module-loading-mode-archs.swift
@@ -10,7 +10,7 @@
 
 // 2. Only interface is present.
 // RUN: %empty-directory(%t/Lib.swiftmodule)
-// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface
+// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.swiftmodule/%target-cpu.swiftinterface
 // RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-parseable %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
 // RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-serialized %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
 // RUN: not env SWIFT_FORCE_MODULE_LOADING=only-parseable %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
@@ -29,7 +29,7 @@
 // RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
 
 // 4. Both are present.
-// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface
+// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.swiftmodule/%target-cpu.swiftinterface
 // RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-parseable %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
 // RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-serialized %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
 // RUN: not env SWIFT_FORCE_MODULE_LOADING=only-parseable %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
@@ -59,12 +59,12 @@
 // RUN: %empty-directory(%t/Lib.swiftmodule)
 // RUN: touch %t/Lib.swiftmodule/garbage.swiftmodule
 // RUN: touch %t/Lib.swiftmodule/garbage.swiftinterface
-// RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-parseable %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=$(basename %target-swiftmodule-name .swiftmodule) %s
-// RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-serialized %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=$(basename %target-swiftmodule-name .swiftmodule) %s
+// RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-parseable %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%target-cpu %s
+// RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-serialized %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%target-cpu %s
 // RUN: not env SWIFT_FORCE_MODULE_LOADING=only-parseable %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
-// RUN: not env SWIFT_FORCE_MODULE_LOADING=only-serialized %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=$(basename %target-swiftmodule-name .swiftmodule) %s
+// RUN: not env SWIFT_FORCE_MODULE_LOADING=only-serialized %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -I %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%target-cpu %s
 // (default)
-// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=$(basename %target-swiftmodule-name .swiftmodule) %s
+// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -I %t %s 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%target-cpu %s
 
 // 8. Only the interface is present but for the wrong architecture.
 // (Diagnostics for the module only are tested elsewhere.)
diff --git a/test/ParseableInterface/ModuleCache/force-module-loading-mode-framework.swift b/test/ParseableInterface/ModuleCache/force-module-loading-mode-framework.swift
index 6e40bdd..b1f0d5c 100644
--- a/test/ParseableInterface/ModuleCache/force-module-loading-mode-framework.swift
+++ b/test/ParseableInterface/ModuleCache/force-module-loading-mode-framework.swift
@@ -10,7 +10,7 @@
 
 // 2. Only interface is present.
 // RUN: %empty-directory(%t/Lib.framework/Modules/Lib.swiftmodule)
-// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.framework/Modules/Lib.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface
+// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.framework/Modules/Lib.swiftmodule/%target-cpu.swiftinterface
 // RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-parseable %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
 // RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-serialized %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
 // RUN: not env SWIFT_FORCE_MODULE_LOADING=only-parseable %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
@@ -29,7 +29,7 @@
 // RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
 
 // 4. Both are present.
-// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.framework/Modules/Lib.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface
+// RUN: cp %S/Inputs/force-module-loading-mode/Lib.swiftinterface %t/Lib.framework/Modules/Lib.swiftmodule/%target-cpu.swiftinterface
 // RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-parseable %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
 // RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-serialized %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-SERIALIZED %s
 // RUN: not env SWIFT_FORCE_MODULE_LOADING=only-parseable %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=FROM-INTERFACE %s
@@ -59,12 +59,12 @@
 // RUN: %empty-directory(%t/Lib.framework/Modules/Lib.swiftmodule)
 // RUN: touch %t/Lib.framework/Modules/Lib.swiftmodule/garbage.swiftmodule
 // RUN: touch %t/Lib.framework/Modules/Lib.swiftmodule/garbage.swiftinterface
-// RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-parseable %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=$(basename %target-swiftmodule-name .swiftmodule) %s
-// RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-serialized %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=$(basename %target-swiftmodule-name .swiftmodule) %s
+// RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-parseable %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%target-cpu %s
+// RUN: not env SWIFT_FORCE_MODULE_LOADING=prefer-serialized %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%target-cpu %s
 // RUN: not env SWIFT_FORCE_MODULE_LOADING=only-parseable %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=NO-SUCH-MODULE %s
-// RUN: not env SWIFT_FORCE_MODULE_LOADING=only-serialized %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=$(basename %target-swiftmodule-name .swiftmodule) %s
+// RUN: not env SWIFT_FORCE_MODULE_LOADING=only-serialized %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP %s -F %t 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%target-cpu %s
 // (default)
-// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=$(basename %target-swiftmodule-name .swiftmodule) %s
+// RUN: not %target-swift-frontend -typecheck -parse-stdlib -module-cache-path %t/MCP -F %t %s 2>&1 | %FileCheck -check-prefix=WRONG-ARCH -DARCH=%target-cpu %s
 
 // 8. Only the interface is present but for the wrong architecture.
 // (Diagnostics for the module only are tested elsewhere.)
diff --git a/test/ParseableInterface/ModuleCache/prebuilt-module-cache-archs.swift b/test/ParseableInterface/ModuleCache/prebuilt-module-cache-archs.swift
index e8ce6e1..06b5aa7 100644
--- a/test/ParseableInterface/ModuleCache/prebuilt-module-cache-archs.swift
+++ b/test/ParseableInterface/ModuleCache/prebuilt-module-cache-archs.swift
@@ -1,6 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %empty-directory(%t/include/Lib.swiftmodule)
-// RUN: cp %S/Inputs/prebuilt-module-cache/Lib.swiftinterface %t/include/Lib.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface
+// RUN: cp %S/Inputs/prebuilt-module-cache/Lib.swiftinterface %t/include/Lib.swiftmodule/%target-cpu.swiftinterface
 
 // Baseline check: if the prebuilt cache path does not exist, everything should
 // still work.
diff --git a/test/ParseableInterface/ModuleCache/swiftdoc-next-to-swiftinterface.swift b/test/ParseableInterface/ModuleCache/swiftdoc-next-to-swiftinterface.swift
index 230014b..03c4dc2 100644
--- a/test/ParseableInterface/ModuleCache/swiftdoc-next-to-swiftinterface.swift
+++ b/test/ParseableInterface/ModuleCache/swiftdoc-next-to-swiftinterface.swift
@@ -10,7 +10,7 @@
 // Try again with architecture-specific subdirectories.
 // RUN: %empty-directory(%t)
 // RUN: %empty-directory(%t/Lib.swiftmodule)
-// RUN: %target-swift-frontend -emit-module -emit-parseable-module-interface-path %t/Lib.swiftmodule/$(basename %target-swiftmodule-name .swiftmodule).swiftinterface -emit-module-doc -parse-stdlib -o %t/Lib.swiftmodule/%target-swiftmodule-name -module-name Lib %s
+// RUN: %target-swift-frontend -emit-module -emit-parseable-module-interface-path %t/Lib.swiftmodule/%target-cpu.swiftinterface -emit-module-doc -parse-stdlib -o %t/Lib.swiftmodule/%target-swiftmodule-name -module-name Lib %s
 // RUN: %target-swift-ide-test -print-module -module-to-print=Lib -access-filter-public -I %t -source-filename=x > %t/from-module.txt
 // RUN: %FileCheck %s < %t/from-module.txt
 
diff --git a/test/Profiler/coverage_subscript_autoclosure.swift b/test/Profiler/coverage_subscript_autoclosure.swift
new file mode 100644
index 0000000..0e521cc
--- /dev/null
+++ b/test/Profiler/coverage_subscript_autoclosure.swift
@@ -0,0 +1,15 @@
+// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-testing -profile-generate -profile-coverage-mapping -emit-sil -module-name coverage_subscript_autoclosure %s | %FileCheck %s
+
+struct S {
+  subscript(i: Int, autoclosure: @autoclosure () ->  Int) -> Int {
+    // CHECK-LABEL: sil_coverage_map {{.*}}S.subscript.getter
+    get { // CHECK-NEXT: [[@LINE]]:9 -> [[@LINE+2]]:6 : 0
+      return 0
+    }
+
+    // CHECK-LABEL: sil_coverage_map {{.*}}S.subscript.setter
+    set { // CHECK-NEXT: [[@LINE]]:9 -> [[@LINE+2]]:6 : 0
+
+    }
+  }
+}
diff --git a/test/SILOptimizer/existential_transform_soletype.swift b/test/SILOptimizer/existential_transform_soletype.swift
new file mode 100644
index 0000000..074f0c6
--- /dev/null
+++ b/test/SILOptimizer/existential_transform_soletype.swift
@@ -0,0 +1,52 @@
+// RUN: %target-swift-frontend -O -wmo -sil-existential-specializer -Xllvm -sil-disable-pass=GenericSpecializer -Xllvm -sil-disable-pass=FunctionSignatureOpts -Xllvm -sil-disable-pass=SILCombine -emit-sil -sil-verify-all %s | %FileCheck %s
+
+internal protocol SPP {
+  func bar()  -> Int32
+}
+internal class SCC: SPP {
+  @inline(never) func bar() -> Int32 {
+   return 5
+  }
+}
+
+@inline(never) internal func opt2(b:SPP) -> Int32{
+ return b.bar()
+}
+
+@inline(never) internal func opt1(b:SPP) -> Int32{
+ return opt2(b:b)
+}
+
+// CHECK-LABEL: sil hidden [noinline] @$s30existential_transform_soletype4opt11bs5Int32VAA3SPP_p_tF : $@convention(thin) (@in_guaranteed SPP) -> Int32 {
+// CHECK: bb0(%0 : $*SPP):
+// CHECK:   debug_value_addr
+// CHECK:   function_ref @$s30existential_transform_soletype4opt21bs5Int32VAA3SPP_p_tFTf4e_n : $@convention(thin) <τ_0_0 where τ_0_0 : SPP> (@in_guaranteed τ_0_0) -> Int32 // user: %4
+// CHECK:   open_existential_addr
+// CHECK:   apply
+// CHECK:   return
+// CHECK-LABEL: } // end sil function '$s30existential_transform_soletype4opt11bs5Int32VAA3SPP_p_tF'
+
+// CHECK-LABEL: sil shared [noinline] @$s30existential_transform_soletype4opt21bs5Int32VAA3SPP_p_tFTf4e_n : $@convention(thin) <τ_0_0 where τ_0_0 : SPP> (@in_guaranteed τ_0_0) -> Int32 {
+// CHECK: bb0(%0 : $*τ_0_0):
+// CHECK:   alloc_stack
+// CHECK:   init_existential_addr
+// CHECK:   copy_addr
+// CHECK:   debug_value_addr
+// CHECK:   open_existential_addr
+// CHECK:   witness_method 
+// CHECK:   apply
+// CHECK:   dealloc_stack
+// CHECK:   return
+// CHECK-LABEL: } // end sil function '$s30existential_transform_soletype4opt21bs5Int32VAA3SPP_p_tFTf4e_n'
+
+
+@_optimize(none) func foo(number:Int32)->Int32 {
+  var b:SPP
+  if number < 5 {
+    b = SCC()
+  } else {
+    b = SCC()
+  }
+  let x = opt1(b:b)
+  return x
+}
diff --git a/test/SILOptimizer/pointer_conversion.swift b/test/SILOptimizer/pointer_conversion.swift
index 1b0d1af..5752c64 100644
--- a/test/SILOptimizer/pointer_conversion.swift
+++ b/test/SILOptimizer/pointer_conversion.swift
@@ -84,17 +84,17 @@
 
 // CHECK-LABEL: sil @$s18pointer_conversion21arrayLiteralPromotionyyF
 public func arrayLiteralPromotion() {
-  takesConstRawPointer([41,42,43,44])
+  takesConstRawPointer([-41,-42,-43,-44])
   
   // Stack allocate the array.
   // TODO: When stdlib checks are enabled, this becomes heap allocated... :-(
   // CHECK: alloc_ref {{.*}}[tail_elems $Int * {{.*}} : $Builtin.Word] $_ContiguousArrayStorage<Int>
   
   // Store the elements.
-  // CHECK: [[ELT:%.+]] = integer_literal $Builtin.Int{{.*}}, 41
-  // CHECK: [[ELT:%.+]] = integer_literal $Builtin.Int{{.*}}, 42
-  // CHECK: [[ELT:%.+]] = integer_literal $Builtin.Int{{.*}}, 43
-  // CHECK: [[ELT:%.+]] = integer_literal $Builtin.Int{{.*}}, 44
+  // CHECK: [[ELT:%.+]] = integer_literal $Builtin.Int{{.*}}, -41
+  // CHECK: [[ELT:%.+]] = integer_literal $Builtin.Int{{.*}}, -42
+  // CHECK: [[ELT:%.+]] = integer_literal $Builtin.Int{{.*}}, -43
+  // CHECK: [[ELT:%.+]] = integer_literal $Builtin.Int{{.*}}, -44
   
   // Call the function.
   // CHECK: [[PTR:%.+]] = mark_dependence
diff --git a/test/api-digester/Outputs/stability-stdlib-abi.swift.expected b/test/api-digester/Outputs/stability-stdlib-abi.swift.expected
index e6df12d..f8a2ab1 100644
--- a/test/api-digester/Outputs/stability-stdlib-abi.swift.expected
+++ b/test/api-digester/Outputs/stability-stdlib-abi.swift.expected
@@ -28,3 +28,46 @@
 
 Var _StringObject._countAndFlags is no longer a stored property
 Var _StringObject._countAndFlagsBits is added to a non-resilient type
+
+Class _DictionaryStorage has changed its super class from _RawDictionaryStorage to __RawDictionaryStorage
+Class _EmptyDictionarySingleton has been renamed to Class __EmptyDictionarySingleton
+Class _EmptyDictionarySingleton has changed its super class from _RawDictionaryStorage to __RawDictionaryStorage
+Class _EmptySetSingleton has been renamed to Class __EmptySetSingleton
+Class _EmptySetSingleton has changed its super class from _RawSetStorage to __RawSetStorage
+Class _RawDictionaryStorage has been renamed to Class __RawDictionaryStorage
+Class _RawSetStorage has been renamed to Class __RawSetStorage
+Class _SetStorage has changed its super class from _RawSetStorage to __RawSetStorage
+Constructor Dictionary._Variant.init(cocoa:) has parameter 0 type change from _CocoaDictionary to __CocoaDictionary
+Constructor Dictionary.init(_cocoa:) has parameter 0 type change from _CocoaDictionary to __CocoaDictionary
+Constructor Set._Variant.init(cocoa:) has parameter 0 type change from _CocoaSet to __CocoaSet
+Constructor Set.init(_cocoa:) has parameter 0 type change from _CocoaSet to __CocoaSet
+Constructor _CocoaDictionary.init(_:) has return type change from _CocoaDictionary to __CocoaDictionary
+Constructor _CocoaSet.init(_:) has return type change from _CocoaSet to __CocoaSet
+Constructor _NativeDictionary.init(_:) has parameter 0 type change from _CocoaDictionary to __CocoaDictionary
+Constructor _NativeDictionary.init(_:) has parameter 0 type change from _RawDictionaryStorage to __RawDictionaryStorage
+Constructor _NativeDictionary.init(_:capacity:) has parameter 0 type change from _CocoaDictionary to __CocoaDictionary
+Constructor _NativeSet.init(_:) has parameter 0 type change from _CocoaSet to __CocoaSet
+Constructor _NativeSet.init(_:) has parameter 0 type change from _RawSetStorage to __RawSetStorage
+Constructor _NativeSet.init(_:capacity:) has parameter 0 type change from _CocoaSet to __CocoaSet
+Func Set._Variant._migrateToNative(_:removing:) has parameter 0 type change from _CocoaSet to __CocoaSet
+Func _CocoaDictionary.isEqual(to:) has parameter 0 type change from _CocoaDictionary to __CocoaDictionary
+Func _CocoaSet.isEqual(to:) has parameter 0 type change from _CocoaSet to __CocoaSet
+Func _DictionaryStorage.convert(_:capacity:) has parameter 0 type change from _CocoaDictionary to __CocoaDictionary
+Func _DictionaryStorage.copy(original:) has parameter 0 type change from _RawDictionaryStorage to __RawDictionaryStorage
+Func _DictionaryStorage.resize(original:capacity:move:) has parameter 0 type change from _RawDictionaryStorage to __RawDictionaryStorage
+Func _NativeDictionary.isEqual(to:) has parameter 0 type change from _CocoaDictionary to __CocoaDictionary
+Func _NativeSet.isEqual(to:) has parameter 0 type change from _CocoaSet to __CocoaSet
+Func _SetStorage.convert(_:capacity:) has parameter 0 type change from _CocoaSet to __CocoaSet
+Func _SetStorage.copy(original:) has parameter 0 type change from _RawSetStorage to __RawSetStorage
+Func _SetStorage.resize(original:capacity:move:) has parameter 0 type change from _RawSetStorage to __RawSetStorage
+Struct _CocoaDictionary has been renamed to Struct __CocoaDictionary
+Struct _CocoaSet has been renamed to Struct __CocoaSet
+Var Dictionary._Variant.asCocoa has declared type change from _CocoaDictionary to __CocoaDictionary
+Var Dictionary._Variant.object has declared type change from _BridgeStorage<_RawDictionaryStorage> to _BridgeStorage<__RawDictionaryStorage>
+Var Set._Variant.asCocoa has declared type change from _CocoaSet to __CocoaSet
+Var Set._Variant.object has declared type change from _BridgeStorage<_RawSetStorage> to _BridgeStorage<__RawSetStorage>
+Var _CocoaDictionary.Index.dictionary has declared type change from _CocoaDictionary to __CocoaDictionary
+Var _NativeDictionary._storage has declared type change from _RawDictionaryStorage to __RawDictionaryStorage
+Var _NativeSet._storage has declared type change from _RawSetStorage to __RawSetStorage
+Var _RawDictionaryStorage.empty has declared type change from _EmptyDictionarySingleton to __EmptyDictionarySingleton
+Var _RawSetStorage.empty has declared type change from _EmptySetSingleton to __EmptySetSingleton
diff --git a/test/stdlib/CastTraps.swift.gyb b/test/stdlib/CastTraps.swift.gyb
index b0d1ce3..e560887 100644
--- a/test/stdlib/CastTraps.swift.gyb
+++ b/test/stdlib/CastTraps.swift.gyb
@@ -5,7 +5,7 @@
 // FIXME: Casting.cpp has dozens of places to fail a cast. This test does not
 // attempt to enumerate them all.
 
-// XFAIL: linux
+// REQUIRES: objc_interop
 
 import StdlibUnittest
 
diff --git a/test/stdlib/Error.swift b/test/stdlib/Error.swift
index 561985b..6aabba3 100644
--- a/test/stdlib/Error.swift
+++ b/test/stdlib/Error.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-build-swift -o %t/Error -DPTR_SIZE_%target-ptrsize -module-name main %s
+// RUN: %target-build-swift -o %t/Error -DPTR_SIZE_%target-ptrsize -module-name main %/s
 // RUN: %target-run %t/Error
 // REQUIRES: executable_test
 
diff --git a/test/stdlib/FloatConstants.swift b/test/stdlib/FloatConstants.swift
index 5d40927..17e7009 100644
--- a/test/stdlib/FloatConstants.swift
+++ b/test/stdlib/FloatConstants.swift
@@ -4,6 +4,8 @@
 import Darwin
 #elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android)
 import Glibc
+#elseif os(Windows)
+import MSVCRT
 #endif
 
 _ = FLT_RADIX // expected-warning {{is deprecated}}
diff --git a/test/stdlib/FloatingPointIR.swift b/test/stdlib/FloatingPointIR.swift
index 7273801..9fadab6 100644
--- a/test/stdlib/FloatingPointIR.swift
+++ b/test/stdlib/FloatingPointIR.swift
@@ -4,9 +4,6 @@
 
 var globalFloat32 : Float32 = 0.0
 var globalFloat64 : Float64 = 0.0
-#if arch(i386) || arch(x86_64)
-var globalFloat80 : Float80 = 0.0
-#endif
 
 @inline(never)
 func acceptFloat32(_ a: Float32) {
@@ -18,28 +15,16 @@
   globalFloat64 = a
 }
 
-#if arch(i386) || arch(x86_64)
-@inline(never)
-func acceptFloat80(_ a: Float80) {
-  globalFloat80 = a
-}
-#endif
-
 func testConstantFoldFloatLiterals() {
   acceptFloat32(1.0)
   acceptFloat64(1.0)
-#if arch(i386) || arch(x86_64)
-  acceptFloat80(1.0)
-#endif
 }
 
 // i386: call swiftcc void @"$s15FloatingPointIR13acceptFloat32yySfF{{.*}}"(float 1.000000e+00)
 // i386: call swiftcc void @"$s15FloatingPointIR13acceptFloat64yySdF{{.*}}"(double 1.000000e+00)
-// i386: call swiftcc void @"$s15FloatingPointIR13acceptFloat80yys0E0VF{{.*}}"(x86_fp80 0xK3FFF8000000000000000)
 
 // x86_64: call swiftcc void @"$s15FloatingPointIR13acceptFloat32yySfF{{.*}}"(float 1.000000e+00)
 // x86_64: call swiftcc void @"$s15FloatingPointIR13acceptFloat64yySdF{{.*}}"(double 1.000000e+00)
-// x86_64: call swiftcc void @"$s15FloatingPointIR13acceptFloat80yys0E0VF{{.*}}"(x86_fp80 0xK3FFF8000000000000000)
 
 // armv7: call swiftcc void @"$s15FloatingPointIR13acceptFloat32yySfF{{.*}}"(float 1.000000e+00)
 // armv7: call swiftcc void @"$s15FloatingPointIR13acceptFloat64yySdF{{.*}}"(double 1.000000e+00)
diff --git a/test/stdlib/FloatingPointIR_FP80.swift b/test/stdlib/FloatingPointIR_FP80.swift
new file mode 100644
index 0000000..a5f0344
--- /dev/null
+++ b/test/stdlib/FloatingPointIR_FP80.swift
@@ -0,0 +1,20 @@
+// RUN: %target-build-swift -emit-ir %s | %FileCheck -check-prefix=%target-cpu %s
+// RUN: %target-build-swift -O -emit-ir %s | %FileCheck -check-prefix=%target-cpu %s
+// RUN: %target-build-swift -Ounchecked -emit-ir %s | %FileCheck -check-prefix=%target-cpu %s
+
+// REQUIRES: CPU=i386 || CPU=x86_64
+// UNSUPPORTED: OS=windows-msvc
+
+var globalFloat80 : Float80 = 0.0
+
+@inline(never)
+func acceptFloat80(_ a: Float80) {
+  globalFloat80 = a
+}
+
+func testConstantFoldFloatLiterals() {
+  acceptFloat80(1.0)
+}
+
+// i386: call swiftcc void @"$s20FloatingPointIR_FP8013acceptFloat80yys0F0VF{{.*}}"(x86_fp80 0xK3FFF8000000000000000)
+// x86_64: call swiftcc void @"$s20FloatingPointIR_FP8013acceptFloat80yys0F0VF{{.*}}"(x86_fp80 0xK3FFF8000000000000000)
diff --git a/test/stdlib/Inputs/DictionaryKeyValueTypesObjC.swift b/test/stdlib/Inputs/DictionaryKeyValueTypesObjC.swift
index 35e87fd..d367e89 100644
--- a/test/stdlib/Inputs/DictionaryKeyValueTypesObjC.swift
+++ b/test/stdlib/Inputs/DictionaryKeyValueTypesObjC.swift
@@ -33,7 +33,7 @@
   let className: NSString = NSStringFromClass(type(of: d)) as NSString
   return [
     "_SwiftDeferredNSDictionary",
-    "_EmptyDictionarySingleton",
+    "__EmptyDictionarySingleton",
     "_DictionaryStorage"].contains {
     className.range(of: $0).length > 0
   }
diff --git a/test/stdlib/MathConstants.swift b/test/stdlib/MathConstants.swift
index 2ecc54d..0fcf96d 100644
--- a/test/stdlib/MathConstants.swift
+++ b/test/stdlib/MathConstants.swift
@@ -4,6 +4,8 @@
 import Darwin
 #elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android)
 import Glibc
+#elseif os(Windows)
+import MSVCRT
 #endif
 
 _ = M_PI // expected-warning {{is deprecated}}
diff --git a/test/stdlib/Mirror.swift b/test/stdlib/Mirror.swift
index c762cf0..45bdaf2 100644
--- a/test/stdlib/Mirror.swift
+++ b/test/stdlib/Mirror.swift
@@ -21,7 +21,9 @@
 // RUN: fi
 // RUN: %target-codesign %t/Mirror
 // RUN: %target-run %t/Mirror
+
 // REQUIRES: executable_test
+// REQUIRES: shell
 
 import StdlibUnittest
 
diff --git a/test/stdlib/Nil.swift b/test/stdlib/Nil.swift
index 84025f8..66c311c 100644
--- a/test/stdlib/Nil.swift
+++ b/test/stdlib/Nil.swift
@@ -2,7 +2,7 @@
 // REQUIRES: executable_test
 
 // FIXME: rdar://problem/19648117 Needs splitting objc parts out
-// XFAIL: linux
+// REQUIRES: objc_interop
 
 import Foundation
 
diff --git a/test/stdlib/NumericParsing.swift.gyb b/test/stdlib/NumericParsing.swift.gyb
index d52d148..fe0239e 100644
--- a/test/stdlib/NumericParsing.swift.gyb
+++ b/test/stdlib/NumericParsing.swift.gyb
@@ -134,7 +134,7 @@
 % for Self in 'Float', 'Double', 'Float80':
 
 % if Self == 'Float80':
-#if arch(i386) || arch(x86_64)
+#if !os(Windows) && (arch(i386) || arch(x86_64))
 % end
 
 tests.test("${Self}/Basics") {
diff --git a/test/stdlib/POSIX.swift b/test/stdlib/POSIX.swift
index eaa42aa..6f454df 100644
--- a/test/stdlib/POSIX.swift
+++ b/test/stdlib/POSIX.swift
@@ -1,5 +1,6 @@
 // RUN: %target-run-simple-swift %t
 // REQUIRES: executable_test
+// UNSUPPORTED: OS=windows-msvc
 
 import StdlibUnittest
 #if os(Linux) || os(Android)
diff --git a/test/stdlib/PrintFloat.swift.gyb b/test/stdlib/PrintFloat.swift.gyb
index 90a1d28..fa85587 100644
--- a/test/stdlib/PrintFloat.swift.gyb
+++ b/test/stdlib/PrintFloat.swift.gyb
@@ -9,8 +9,10 @@
 import StdlibUnittest
 #if os(Linux) || os(FreeBSD) || os(PS4) || os(Android)
   import Glibc
-#else
+#elseif os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
   import Darwin
+#elseif os(Windows)
+  import MSVCRT
 #endif
 
 // It takes about an hour to run the Float formatter over all 2 billion
diff --git a/test/stdlib/Runtime.swift.gyb b/test/stdlib/Runtime.swift.gyb
index 7471b88..e1b7df2 100644
--- a/test/stdlib/Runtime.swift.gyb
+++ b/test/stdlib/Runtime.swift.gyb
@@ -14,6 +14,9 @@
 import Darwin
 #elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android)
 import Glibc
+#elseif os(Windows)
+import MSVCRT
+import WinSDK
 #endif
 
 @_silgen_name("swift_demangle")
@@ -566,14 +569,27 @@
   #else
     _UnimplementedError()
   #endif
+#elseif os(Windows)
+  let hStdlibCore: HMODULE = GetModuleHandleA("swiftCore.dll")!
 #else
   _UnimplementedError()
 #endif
 
+#if os(Windows)
+  let offsetof_SwiftError_typeMetadata: UnsafeRawPointer =
+      unsafeBitCast(GetProcAddress(hStdlibCore,
+                                   "_swift_lldb_offsetof_SwiftError_typeMetadata")!,
+                    to: UnsafeRawPointer.self)
+  let sizeof_SwiftError: UnsafeRawPointer =
+      unsafeBitCast(GetProcAddress(hStdlibCore,
+                                   "_swift_lldb_sizeof_SwiftError")!,
+                    to: UnsafeRawPointer.self)
+#else
   let offsetof_SwiftError_typeMetadata =
     dlsym(RTLD_DEFAULT, "_swift_lldb_offsetof_SwiftError_typeMetadata")!
   let sizeof_SwiftError =
     dlsym(RTLD_DEFAULT, "_swift_lldb_sizeof_SwiftError")!
+#endif
 #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
 #if arch(i386) || arch(arm)
   expectEqual(20, offsetof_SwiftError_typeMetadata.load(as: UInt.self))
@@ -582,7 +598,7 @@
   expectEqual(40, offsetof_SwiftError_typeMetadata.load(as: UInt.self))
   expectEqual(72, sizeof_SwiftError.load(as: UInt.self))
 #endif
-#elseif os(Linux) || os(Android)
+#elseif os(Linux) || os(Android) || os(Windows)
   expectEqual(16, offsetof_SwiftError_typeMetadata.load(as: UInt.self))
   expectEqual(32, sizeof_SwiftError.load(as: UInt.self))
 #else
diff --git a/test/stdlib/StringDiagnostics.swift b/test/stdlib/StringDiagnostics.swift
index 383b333..2014160 100644
--- a/test/stdlib/StringDiagnostics.swift
+++ b/test/stdlib/StringDiagnostics.swift
@@ -1,6 +1,6 @@
 // RUN: %target-typecheck-verify-swift
 
-// XFAIL: linux
+// REQUIRES: objc_interop
 
 import Foundation
 
diff --git a/test/stdlib/VarArgs.swift b/test/stdlib/VarArgs.swift
index 8abb1f5..735bff4 100644
--- a/test/stdlib/VarArgs.swift
+++ b/test/stdlib/VarArgs.swift
@@ -6,9 +6,16 @@
 #if _runtime(_ObjC)
 import Darwin
 import CoreGraphics
-#else
+#elseif os(Linux) || os(FreeBSD) || os(Android) || os(Haiku) || os(PS4)
 import Glibc
 typealias CGFloat = Double
+#elseif os(Windows)
+import MSVCRT
+#if arch(x86_64) || arch(arm64)
+typealias CGFloat = Double
+#else
+typealias CGFloat = Float
+#endif
 #endif
 
 func my_printf(_ format: String, _ arguments: CVarArg...) {
diff --git a/test/stdlib/WeakMirror.swift b/test/stdlib/WeakMirror.swift
index eb6e8ae..02e88fd 100644
--- a/test/stdlib/WeakMirror.swift
+++ b/test/stdlib/WeakMirror.swift
@@ -20,7 +20,9 @@
 // RUN: fi
 // RUN: %target-codesign %t/Mirror
 // RUN: %target-run %t/Mirror
+
 // REQUIRES: executable_test
+// REQUIRES: shell
 
 import StdlibUnittest
 
diff --git a/test/stdlib/mmap.swift b/test/stdlib/mmap.swift
index 5c26719..63099cf 100644
--- a/test/stdlib/mmap.swift
+++ b/test/stdlib/mmap.swift
@@ -1,5 +1,6 @@
 // RUN: %target-run-simple-swift %t
 // REQUIRES: executable_test
+// UNSUPPORTED: OS=windows-msvc
 
 import StdlibUnittest
 #if os(Linux) || os(Android)
diff --git a/test/stdlib/simd.swift.gyb b/test/stdlib/simd.swift.gyb
index 84bedf3..19953ae 100644
--- a/test/stdlib/simd.swift.gyb
+++ b/test/stdlib/simd.swift.gyb
@@ -2,7 +2,7 @@
 // REQUIRES: executable_test
 
 // FIXME: No simd module on linux rdar://problem/20795411
-// XFAIL: linux
+// XFAIL: linux, windows
 
 import simd
 import StdlibUnittest
diff --git a/test/stdlib/simd_diagnostics.swift b/test/stdlib/simd_diagnostics.swift
index fa17b0b..2aa1be0 100644
--- a/test/stdlib/simd_diagnostics.swift
+++ b/test/stdlib/simd_diagnostics.swift
@@ -1,7 +1,7 @@
 // RUN: %target-typecheck-verify-swift
 
 // FIXME: No simd module on linux rdar://problem/20795411
-// XFAIL: linux
+// XFAIL: linux, windows
 
 import simd
 
diff --git a/test/stdlib/tgmath.swift.gyb b/test/stdlib/tgmath.swift.gyb
index 3651248..0bec7b7 100644
--- a/test/stdlib/tgmath.swift.gyb
+++ b/test/stdlib/tgmath.swift.gyb
@@ -17,10 +17,12 @@
 // RUN: %line-directive %t/tgmath.swift -- %target-run %t/a.out
 // REQUIRES: executable_test
 
-#if canImport(Darwin)
+#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
   import Darwin.C.tgmath
-#else
+#elseif os(Linux) || os(android) || os(FreeBSD) || os(Haiku) || os(PS4)
   import Glibc
+#elseif os(Windows)
+  import MSVCRT
 #endif
 
 #if (arch(i386) || arch(x86_64)) && !os(Windows)
@@ -77,7 +79,9 @@
 %end
   static func _remquo(_ x: Self, _ y: Self) -> (Self, Int)
   static func _fma(_ x: Self, _ y: Self, _ z: Self) -> Self
+#if !os(Windows)
   static func _lgamma(_ x: Self) -> (Self, Int)
+#endif
   static func _modf(_ x: Self) -> (Self, Self)
   static func _scalbn(_ x: Self, _ n: Int) -> Self
   static func _frexp(_ x: Self) -> (Self, Int)
@@ -116,8 +120,10 @@
     expectEqualWithTolerance(0.4041169094348222983238250859191217675, Self._erf(0.375))
     expectEqualWithTolerance(0.5958830905651777016761749140808782324, Self._erfc(0.375))
     expectEqualWithTolerance(2.3704361844166009086464735041766525098, Self._tgamma(0.375))
+#if !os(Windows)
     expectEqualWithTolerance( -0.11775527074107877445136203331798850, Self._lgamma(1.375).0, ulps: 16)
     expectEqual(1, Self._lgamma(1.375).1)
+#endif
     expectEqual(1, Self._ceil(0.375))
     expectEqual(0, Self._floor(0.375))
     expectEqual(0, Self._nearbyint(0.375))
@@ -181,7 +187,9 @@
 %end
   static func _remquo(_ x: ${T}, _ y: ${T}) -> (${T}, Int) { return remquo(x, y) }
   static func _fma(_ x: ${T}, _ y: ${T}, _ z: ${T}) -> ${T} { return fma(x, y, z) }
+#if !os(Windows)
   static func _lgamma(_ x: ${T}) -> (${T}, Int) { return lgamma(x) }
+#endif
   static func _modf(_ x: ${T}) -> (${T}, ${T}) { return modf(x) }
   static func _scalbn(_ x: ${T}, _ n: Int) -> ${T} { return scalbn(x, n) }
   static func _frexp(_ x: ${T}) -> (${T}, Int) { return frexp(x) }
diff --git a/test/stdlib/tgmath_optimized.swift b/test/stdlib/tgmath_optimized.swift
index 5d20836..349b0dc 100644
--- a/test/stdlib/tgmath_optimized.swift
+++ b/test/stdlib/tgmath_optimized.swift
@@ -6,8 +6,10 @@
 
 #if os(Linux) || os(FreeBSD) || os(PS4) || os(Android)
   import Glibc
-#else
+#elseif os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
   import Darwin
+#elseif os(Windows)
+  import MSVCRT
 #endif
 import StdlibUnittest
 
diff --git a/tools/SourceKit/tools/swift-lang/SwiftLang.swift b/tools/SourceKit/tools/swift-lang/SwiftLang.swift
index 75b9980..eb07fa7 100644
--- a/tools/SourceKit/tools/swift-lang/SwiftLang.swift
+++ b/tools/SourceKit/tools/swift-lang/SwiftLang.swift
@@ -15,14 +15,14 @@
 import Foundation
 
 enum SourceKitdError: Error, CustomStringConvertible {
-  case EditorOpenError(message: String)
-  case EditorCloseError(message: String)
+  case editorOpenError(message: String)
+  case editorCloseError(message: String)
 
   var description: String {
     switch self {
-    case .EditorOpenError(let message):
+    case .editorOpenError(let message):
       return "cannot open document: \(message)"
-    case .EditorCloseError(let message):
+    case .editorCloseError(let message):
       return "cannot close document: \(message)"
     }
   }
@@ -161,14 +161,14 @@
     // FIXME: SourceKitd error handling.
     let Resp = Service.sendSyn(request: Request)
     if Resp.isError {
-      throw SourceKitdError.EditorOpenError(message: Resp.description)
+      throw SourceKitdError.editorOpenError(message: Resp.description)
     }
 
     let CloseReq = SourceKitdRequest(uid: .request_EditorClose)
     CloseReq.addParameter(.key_Name, value: content.name)
     let CloseResp = Service.sendSyn(request: CloseReq)
     if CloseResp.isError {
-      throw SourceKitdError.EditorCloseError(message: CloseResp.description)
+      throw SourceKitdError.editorCloseError(message: CloseResp.description)
     }
     return try format.makeTree(Resp.value)
   }
diff --git a/utils/WindowsSDKVFSOverlay.yaml.in b/utils/WindowsSDKVFSOverlay.yaml.in
index e9e2a00..4149db5 100644
--- a/utils/WindowsSDKVFSOverlay.yaml.in
+++ b/utils/WindowsSDKVFSOverlay.yaml.in
@@ -23,9 +23,27 @@
   - name: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um"
     type: directory
     contents:
+      - name: commctrl.h
+        type: file
+        external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/CommCtrl.h"
+      - name: docobj.h
+        type: file
+        external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/DocObj.h"
+      - name: exdisp.h
+        type: file
+        external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ExDisp.h"
+      - name: isguids.h
+        type: file
+        external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/IsGuids.h"
+      - name: knownfolders.h
+        type: file
+        external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/KnownFolders.h"
       - name: oaidl.h
         type: file
         external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/OAIdl.h"
+      - name: ocidl.h
+        type: file
+        external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/OCIdl.h"
       - name: objidl.h
         type: file
         external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ObjIdl.h"
@@ -47,6 +65,24 @@
       - name: psapi.h
         type: file
         external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/Psapi.h"
+      - name: shldisp.h
+        type: file
+        external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ShlDisp.h"
+      - name: shlguid.h
+        type: file
+        external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ShlGuid.h"
+      - name: shlobj.h
+        type: file
+        external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ShlObj.h"
+      - name: shlobj_core.h
+        type: file
+        external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ShlObj_core.h"
+      - name: shobjidl.h
+        type: file
+        external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ShObjIdl.h"
+      - name: shobjidl_core.h
+        type: file
+        external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ShObjIdl_core.h"
       - name: unknwn.h
         type: file
         external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/Unknwn.h"
diff --git a/utils/build-script b/utils/build-script
index 1b950f6..b87da65 100755
--- a/utils/build-script
+++ b/utils/build-script
@@ -421,6 +421,9 @@
                 'WATCHOS_DEPLOYMENT_TARGET']:
             os.environ.pop(v, None)
 
+        # Set NINJA_STATUS to format ninja output
+        os.environ['NINJA_STATUS'] = '[%f/%t][%p][%es] '
+
     def build_ninja(self):
         if not os.path.exists(self.workspace.source_dir("ninja")):
             diagnostics.fatal(
diff --git a/utils/build-script-impl b/utils/build-script-impl
index 08a9acd..6357370 100755
--- a/utils/build-script-impl
+++ b/utils/build-script-impl
@@ -1872,6 +1872,8 @@
         --swiftc-exec="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
         --swift-build-exec="${SWIFT_BUILD}"
         --swift-test-exec="${SWIFT_TEST}"
+        --syntax-parser-header-dir="${SWIFT_SOURCE_DIR}/include/swift-c/SyntaxParser"
+        --syntax-parser-lib-dir="$(build_directory ${host} swift)/lib"
         --sourcekitd-dir="$(build_directory ${host} swift)/lib"
         --swiftsyntax-dir="$(build_directory ${host} swiftsyntax)/${swiftsyntax_config}"
         --config="${config}")
diff --git a/validation-test/stdlib/StringNormalization.swift b/validation-test/stdlib/StringNormalization.swift
index 488d8d5..c6c249c 100644
--- a/validation-test/stdlib/StringNormalization.swift
+++ b/validation-test/stdlib/StringNormalization.swift
@@ -22,6 +22,7 @@
 // RUN: %target-run %t/a.out %S/Inputs/NormalizationTest.txt
 // REQUIRES: executable_test
 // REQUIRES: objc_interop
+// REQUIRES: optimized_stdlib
 
 import Swift
 import StdlibUnittest