Merge pull request #12308 from graydon/warn-on-failure-to-open-stats-dir-file

[Stats] Warn on failure-to-write stats / trace files.
diff --git a/docs/HighLevelSILOptimizations.rst b/docs/HighLevelSILOptimizations.rst
index 03a2393..26e78d9 100644
--- a/docs/HighLevelSILOptimizations.rst
+++ b/docs/HighLevelSILOptimizations.rst
@@ -117,15 +117,13 @@
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 The Swift compiler can copy code from the standard library into the
-application. This allows the optimizer to inline calls from stdlib and improve
-the performance of code that uses common operators such as '++' or basic
-containers such as Array. However, importing code from the standard library can
-increase the binary size. Marking functions with @_semantics("stdlib_binary_only")
-will prevent the copying of the marked function from the standard library into the
-user program.
+application for functions marked @_inlineable. This allows the optimizer to
+inline calls from the stdlib and improve the performance of code that uses
+common operators such as '+=' or basic containers such as Array. However,
+importing code from the standard library can increase the binary size.
 
-Notice that this annotation is similar to the resilient annotation that will
-disallow the cloning of code into the user application.
+To prevent copying of functions from the standard library into the user
+program, make sure the function in question is not marked @_inlineable.
 
 Array
 ~~~~~
diff --git a/docs/Lexicon.rst b/docs/Lexicon.rst
index 07de796..602d79f 100644
--- a/docs/Lexicon.rst
+++ b/docs/Lexicon.rst
@@ -344,12 +344,6 @@
     "Swift Intermediate Language". A high-level IR used by the Swift compiler
     for flow-sensitive diagnostics, optimization, and LLVM IR generation.
 
-  -sil-serialize-all
-    A mode where all functions in a library are made available for inlining by
-    any client, regardless of access control. Also called "magic performance
-    mode" as a reminder of how this drastically changes compilation. Not
-    guaranteed to work on arbitrary code.
-
   SR
     An issue reported on `bugs.swift.org <https://bugs.swift.org>`_. A
     backronym for "Swift Report"; really the name is derived from LLVM's
diff --git a/include/swift/ABI/System.h b/include/swift/ABI/System.h
index ad3a986..47bd2e4 100644
--- a/include/swift/ABI/System.h
+++ b/include/swift/ABI/System.h
@@ -14,128 +14,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SWIFT_ABI_SYSTEM_H
-#define SWIFT_ABI_SYSTEM_H
+#ifndef __SWIFT_ABI_SYSTEM_H__
+#define __SWIFT_ABI_SYSTEM_H__
 
-// In general, these macros are expected to expand to host-independent
-// integer constant expressions.  This allows the same data to feed
-// both the compiler and runtime implementation.
+#include "../../../stdlib/public/SwiftShims/System.h"
 
-/******************************* Default Rules ********************************/
-
-/// The least valid pointer value for an actual pointer (as opposed to
-/// Objective-C pointers, which may be tagged pointers and are covered
-/// separately).  Values up to this are "extra inhabitants" of the
-/// pointer representation, and payloaded enum types can take
-/// advantage of that as they see fit.
-///
-/// By default, we assume that there's at least an unmapped page at
-/// the bottom of the address space.  4K is a reasonably likely page
-/// size.
-///
-/// The minimum possible value for this macro is 1; we always assume
-/// that the null representation is available.
-#define SWIFT_ABI_DEFAULT_LEAST_VALID_POINTER 4096
-
-/// The bitmask of spare bits in a function pointer.
-#define SWIFT_ABI_DEFAULT_FUNCTION_SPARE_BITS_MASK 0
-
-/// The bitmask of spare bits in a Swift heap object pointer.  A Swift
-/// heap object allocation will never set any of these bits.
-#define SWIFT_ABI_DEFAULT_SWIFT_SPARE_BITS_MASK 0
-
-/// The bitmask of reserved bits in an Objective-C object pointer.
-/// By default we assume the ObjC runtime doesn't use tagged pointers.
-#define SWIFT_ABI_DEFAULT_OBJC_RESERVED_BITS_MASK 0
-
-/// The number of low bits in an Objective-C object pointer that
-/// are reserved by the Objective-C runtime.
-#define SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS 0
-
-/// The ObjC runtime will not use pointer values for which
-/// ``pointer & SWIFT_ABI_XXX_OBJC_RESERVED_BITS_MASK == 0 && 
-/// pointer & SWIFT_ABI_XXX_SWIFT_SPARE_BITS_MASK != 0``.
-
-// Weak references use a marker to tell when they are controlled by
-// the ObjC runtime and when they are controlled by the Swift runtime.
-// Non-ObjC platforms don't use this marker.
-#define SWIFT_ABI_DEFAULT_OBJC_WEAK_REFERENCE_MARKER_MASK 0
-#define SWIFT_ABI_DEFAULT_OBJC_WEAK_REFERENCE_MARKER_VALUE 0
-
-/*********************************** i386 *************************************/
-
-// Heap objects are pointer-aligned, so the low two bits are unused.
-#define SWIFT_ABI_I386_SWIFT_SPARE_BITS_MASK 0x00000003U
-
-// ObjC weak reference discriminator is the LSB.
-#define SWIFT_ABI_I386_OBJC_WEAK_REFERENCE_MARKER_MASK  \
-  (SWIFT_ABI_DEFAULT_OBJC_RESERVED_BITS_MASK |          \
-   1<<SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS)
-#define SWIFT_ABI_I386_OBJC_WEAK_REFERENCE_MARKER_VALUE \
-  (1<<SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS)
-
-/*********************************** arm **************************************/
-
-// Heap objects are pointer-aligned, so the low two bits are unused.
-#define SWIFT_ABI_ARM_SWIFT_SPARE_BITS_MASK 0x00000003U
-
-// ObjC weak reference discriminator is the LSB.
-#define SWIFT_ABI_ARM_OBJC_WEAK_REFERENCE_MARKER_MASK  \
-  (SWIFT_ABI_DEFAULT_OBJC_RESERVED_BITS_MASK |          \
-   1<<SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS)
-#define SWIFT_ABI_ARM_OBJC_WEAK_REFERENCE_MARKER_VALUE \
-  (1<<SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS)
-
-/*********************************** x86-64 ***********************************/
-
-/// Darwin reserves the low 4GB of address space.
-#define SWIFT_ABI_DARWIN_X86_64_LEAST_VALID_POINTER (4ULL*1024*1024*1024)
-
-// Only the bottom 56 bits are used, and heap objects are eight-byte-aligned.
-#define SWIFT_ABI_X86_64_SWIFT_SPARE_BITS_MASK 0xFF00000000000007ULL
-
-// Objective-C reserves the high and low bits for tagged pointers.
-// Systems exist which use either bit.
-#define SWIFT_ABI_X86_64_OBJC_RESERVED_BITS_MASK 0x8000000000000001ULL
-#define SWIFT_ABI_X86_64_OBJC_NUM_RESERVED_LOW_BITS 1
-
-// ObjC weak reference discriminator is the two bits
-// reserved for ObjC tagged pointers plus one more low bit.
-#define SWIFT_ABI_X86_64_OBJC_WEAK_REFERENCE_MARKER_MASK  \
-  (SWIFT_ABI_X86_64_OBJC_RESERVED_BITS_MASK |          \
-   1<<SWIFT_ABI_X86_64_OBJC_NUM_RESERVED_LOW_BITS)
-#define SWIFT_ABI_X86_64_OBJC_WEAK_REFERENCE_MARKER_VALUE \
-  (1<<SWIFT_ABI_X86_64_OBJC_NUM_RESERVED_LOW_BITS)
-
-/*********************************** arm64 ************************************/
-
-/// Darwin reserves the low 4GB of address space.
-#define SWIFT_ABI_DARWIN_ARM64_LEAST_VALID_POINTER (4ULL*1024*1024*1024)
-
-// TBI guarantees the top byte of pointers is unused.
-// Heap objects are eight-byte aligned.
-#define SWIFT_ABI_ARM64_SWIFT_SPARE_BITS_MASK 0xFF00000000000007ULL
-
-// Objective-C reserves just the high bit for tagged pointers.
-#define SWIFT_ABI_ARM64_OBJC_RESERVED_BITS_MASK 0x8000000000000000ULL
-#define SWIFT_ABI_ARM64_OBJC_NUM_RESERVED_LOW_BITS 0
-
-// ObjC weak reference discriminator is the high bit
-// reserved for ObjC tagged pointers plus the LSB.
-#define SWIFT_ABI_ARM64_OBJC_WEAK_REFERENCE_MARKER_MASK  \
-  (SWIFT_ABI_ARM64_OBJC_RESERVED_BITS_MASK |          \
-   1<<SWIFT_ABI_ARM64_OBJC_NUM_RESERVED_LOW_BITS)
-#define SWIFT_ABI_ARM64_OBJC_WEAK_REFERENCE_MARKER_VALUE \
-  (1<<SWIFT_ABI_ARM64_OBJC_NUM_RESERVED_LOW_BITS)
-
-/*********************************** powerpc64 ********************************/
-
-// Heap objects are pointer-aligned, so the low three bits are unused.
-#define SWIFT_ABI_POWERPC64_SWIFT_SPARE_BITS_MASK 0x0000000000000007ULL
-
-/*********************************** s390x ************************************/
-
-// Top byte of pointers is unused, and heap objects are eight-byte aligned.
-#define SWIFT_ABI_S390X_SWIFT_SPARE_BITS_MASK 0x0000000000000007ULL
-
-#endif /* SWIFT_ABI_SYSTEM_H */
+#endif // __SWIFT_ABI_SYSTEM_H__
diff --git a/include/swift/AST/AnyFunctionRef.h b/include/swift/AST/AnyFunctionRef.h
index 2d5e1fb..80d0fda 100644
--- a/include/swift/AST/AnyFunctionRef.h
+++ b/include/swift/AST/AnyFunctionRef.h
@@ -116,18 +116,9 @@
   /// known not to escape from that function.  In this case, captures can be
   /// more efficient.
   bool isKnownNoEscape() const {
-    if (auto afd = TheFunction.dyn_cast<AbstractFunctionDecl *>()) {
-      // As a hack, assume defer bodies are noescape.
-      if (auto fd = dyn_cast<FuncDecl>(afd))
-        return fd->isDeferBody();
-      return false;
-    }
-
-
-    auto *CE = TheFunction.get<AbstractClosureExpr *>();
-    if (!CE->getType() || CE->getType()->hasError())
-      return false;
-    return CE->getType()->castTo<FunctionType>()->isNoEscape();
+    if (hasType() && !getType()->hasError())
+      return getType()->castTo<AnyFunctionType>()->isNoEscape();
+    return false;
   }
 
   bool isObjC() const {
diff --git a/include/swift/AST/Module.h b/include/swift/AST/Module.h
index 72c6545..116afec 100644
--- a/include/swift/AST/Module.h
+++ b/include/swift/AST/Module.h
@@ -112,13 +112,7 @@
   /// Non-inlineable function bodies: resilient
   ///
   /// This is the behavior with -enable-resilience.
-  Resilient,
-
-  /// Public nominal types: fragile
-  /// Non-inlineable function bodies: fragile
-  ///
-  /// This is the behavior with -sil-serialize-all.
-  Fragile
+  Resilient
 };
 
 /// The minimum unit of compilation.
diff --git a/include/swift/AST/SILOptions.h b/include/swift/AST/SILOptions.h
index acefc7f..1831973 100644
--- a/include/swift/AST/SILOptions.h
+++ b/include/swift/AST/SILOptions.h
@@ -150,11 +150,6 @@
   /// \brief Enable large loadable types IRGen pass.
   bool EnableLargeLoadableTypes = true;
 
-  /// Enables the "fully fragile" resilience strategy.
-  ///
-  /// \see ResilienceStrategy::Fragile
-  bool SILSerializeAll = false;
-
   /// If set, SIL witness tables will be serialized.
   ///
   /// It is supposed to be used only for compiling overlays.
diff --git a/include/swift/Driver/ToolChain.h b/include/swift/Driver/ToolChain.h
index 74c29a5..1b79835 100644
--- a/include/swift/Driver/ToolChain.h
+++ b/include/swift/Driver/ToolChain.h
@@ -167,6 +167,8 @@
                                     const OutputInfo &OI) const;
 
   /// Return the default language type to use for the given extension.
+  /// If the extension is empty or is otherwise not recognized, return
+  /// the invalid type \c TY_INVALID.
   virtual types::ID lookupTypeForExtension(StringRef Ext) const;
 
   /// Check whether a clang library with a given name exists.
diff --git a/include/swift/Driver/Types.def b/include/swift/Driver/Types.def
index 98cb9b3..14c69b4 100644
--- a/include/swift/Driver/Types.def
+++ b/include/swift/Driver/Types.def
@@ -60,10 +60,7 @@
 TYPE("imported-modules", ImportedModules,   "importedmodules", "")
 TYPE("tbd",             TBD,                "tbd",             "")
 TYPE("module-trace",    ModuleTrace,        "trace.json",      "")
-
-// BEGIN APPLE-ONLY OUTPUT TYPES
 TYPE("index-data",      IndexData,          "",                "")
-// END APPLE-ONLY OUTPUT TYPES
 
 // Misc types
 TYPE("pcm",             ClangModuleFile,    "pcm",             "")
diff --git a/include/swift/Driver/Types.h b/include/swift/Driver/Types.h
index 0110af0..c93ca97 100644
--- a/include/swift/Driver/Types.h
+++ b/include/swift/Driver/Types.h
@@ -36,6 +36,8 @@
   StringRef getTypeTempSuffix(ID Id);
 
   /// Lookup the type to use for the file extension \p Ext.
+  /// If the extension is empty or is otherwise not recognized, return
+  /// the invalid type \c TY_INVALID.
   ID lookupTypeForExtension(StringRef Ext);
 
   /// Lookup the type to use for the name \p Name.
diff --git a/include/swift/IRGen/Linking.h b/include/swift/IRGen/Linking.h
index 7d06a03..6631236 100644
--- a/include/swift/IRGen/Linking.h
+++ b/include/swift/IRGen/Linking.h
@@ -567,11 +567,6 @@
   ///
   bool isAvailableExternally(IRGenModule &IGM) const;
 
-  /// Returns true if this function or global variable may be inlined into
-  /// another module.
-  ///
-  bool isFragile(ForDefinition_t isDefinition) const;
-
   const ValueDecl *getDecl() const {
     assert(isDeclKind(getKind()));
     return reinterpret_cast<ValueDecl*>(Pointer);
@@ -686,7 +681,6 @@
   static LinkInfo get(const UniversalLinkageInfo &linkInfo,
                       StringRef name,
                       SILLinkage linkage,
-                      bool isFragile,
                       bool isSILOnly,
                       ForDefinition_t isDefinition,
                       bool isWeakImported);
diff --git a/include/swift/Option/FrontendOptions.td b/include/swift/Option/FrontendOptions.td
index 5732bb8..441dfc3 100644
--- a/include/swift/Option/FrontendOptions.td
+++ b/include/swift/Option/FrontendOptions.td
@@ -372,9 +372,6 @@
 def sil_link_all : Flag<["-"], "sil-link-all">,
   HelpText<"Link all SIL functions">;
 
-def sil_serialize_all : Flag<["-"], "sil-serialize-all">,
-  HelpText<"Serialize all generated SIL">;
-
 def sil_serialize_witness_tables : Flag<["-"], "sil-serialize-witness-tables">,
   HelpText<"Serialize eligible SIL witness tables">;
 
diff --git a/include/swift/Remote/MetadataReader.h b/include/swift/Remote/MetadataReader.h
index fe7ad64..c5aad6d 100644
--- a/include/swift/Remote/MetadataReader.h
+++ b/include/swift/Remote/MetadataReader.h
@@ -690,6 +690,8 @@
 
     switch (Meta->getKind()) {
     case MetadataKind::Class:
+      if (!cast<TargetClassMetadata<Runtime>>(Meta)->isTypeMetadata())
+        return BuiltType();
       return readNominalTypeFromMetadata(Meta, skipArtificialSubclasses);
     case MetadataKind::Struct:
       return readNominalTypeFromMetadata(Meta);
diff --git a/include/swift/Runtime/Metadata.h b/include/swift/Runtime/Metadata.h
index d3202bd..8df1c4f 100644
--- a/include/swift/Runtime/Metadata.h
+++ b/include/swift/Runtime/Metadata.h
@@ -719,87 +719,7 @@
     using type = R;
   };
 }
-  
-namespace heap_object_abi {
-  
-// The extra inhabitants and spare bits of heap object pointers.
-// These must align with the values in IRGen's SwiftTargetInfo.cpp.
-#if defined(__x86_64__)
 
-# ifdef __APPLE__
-static const uintptr_t LeastValidPointerValue =
-  SWIFT_ABI_DARWIN_X86_64_LEAST_VALID_POINTER;
-# else
-static const uintptr_t LeastValidPointerValue =
-  SWIFT_ABI_DEFAULT_LEAST_VALID_POINTER;
-# endif
-static const uintptr_t SwiftSpareBitsMask =
-  SWIFT_ABI_X86_64_SWIFT_SPARE_BITS_MASK;
-static const uintptr_t ObjCReservedBitsMask =
-  SWIFT_ABI_X86_64_OBJC_RESERVED_BITS_MASK;
-static const unsigned ObjCReservedLowBits =
-  SWIFT_ABI_X86_64_OBJC_NUM_RESERVED_LOW_BITS;
-
-#elif defined(__arm64__)
-
-# ifdef __APPLE__
-static const uintptr_t LeastValidPointerValue =
-  SWIFT_ABI_DARWIN_ARM64_LEAST_VALID_POINTER;
-# else
-static const uintptr_t LeastValidPointerValue =
-  SWIFT_ABI_DEFAULT_LEAST_VALID_POINTER;
-# endif
-static const uintptr_t SwiftSpareBitsMask =
-  SWIFT_ABI_ARM64_SWIFT_SPARE_BITS_MASK;
-static const uintptr_t ObjCReservedBitsMask =
-  SWIFT_ABI_ARM64_OBJC_RESERVED_BITS_MASK;
-static const unsigned ObjCReservedLowBits =
-  SWIFT_ABI_ARM64_OBJC_NUM_RESERVED_LOW_BITS;
-
-#elif defined(__powerpc64__)
-
-static const uintptr_t LeastValidPointerValue =
-  SWIFT_ABI_DEFAULT_LEAST_VALID_POINTER;
-static const uintptr_t SwiftSpareBitsMask =
-  SWIFT_ABI_POWERPC64_SWIFT_SPARE_BITS_MASK;
-static const uintptr_t ObjCReservedBitsMask =
-  SWIFT_ABI_DEFAULT_OBJC_RESERVED_BITS_MASK;
-static const unsigned ObjCReservedLowBits =
-  SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS;
-
-#elif defined(__s390x__)
-
-static const uintptr_t LeastValidPointerValue =
-  SWIFT_ABI_DEFAULT_LEAST_VALID_POINTER;
-static const uintptr_t SwiftSpareBitsMask =
-  SWIFT_ABI_S390X_SWIFT_SPARE_BITS_MASK;
-static const uintptr_t ObjCReservedBitsMask =
-  SWIFT_ABI_DEFAULT_OBJC_RESERVED_BITS_MASK;
-static const unsigned ObjCReservedLowBits =
-  SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS;
-
-#else
-
-static const uintptr_t LeastValidPointerValue =
-  SWIFT_ABI_DEFAULT_LEAST_VALID_POINTER;
-static const uintptr_t SwiftSpareBitsMask =
-# if __i386__
-  SWIFT_ABI_I386_SWIFT_SPARE_BITS_MASK
-# elif __arm__
-  SWIFT_ABI_ARM_SWIFT_SPARE_BITS_MASK
-# else
-  SWIFT_ABI_DEFAULT_SWIFT_SPARE_BITS_MASK
-# endif
-  ;
-static const uintptr_t ObjCReservedBitsMask =
-  SWIFT_ABI_DEFAULT_OBJC_RESERVED_BITS_MASK;
-static const unsigned ObjCReservedLowBits =
-  SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS;
-
-#endif
-
-}
-  
 template <typename Runtime> struct TargetNominalTypeDescriptor;
 template <typename Runtime> struct TargetGenericMetadata;
 template <typename Runtime> struct TargetClassMetadata;
diff --git a/include/swift/SIL/SILModule.h b/include/swift/SIL/SILModule.h
index 1c68b4b..0d29a30 100644
--- a/include/swift/SIL/SILModule.h
+++ b/include/swift/SIL/SILModule.h
@@ -322,9 +322,6 @@
     return wholeModule;
   }
 
-  /// Returns true if everything in this SILModule is being serialized.
-  bool isWholeModuleSerialized() const { return Options.SILSerializeAll; }
-
   /// Returns true if it is the OnoneSupport module.
   bool isOnoneSupportModule() const;
 
diff --git a/lib/AST/ASTVerifier.cpp b/lib/AST/ASTVerifier.cpp
index f5d6f86..69262a9 100644
--- a/lib/AST/ASTVerifier.cpp
+++ b/lib/AST/ASTVerifier.cpp
@@ -924,6 +924,8 @@
       verifyCheckedBase(S);
     }
     void verifyChecked(DeferStmt *S) {
+      auto FT = S->getTempDecl()->getInterfaceType()->castTo<AnyFunctionType>();
+      assert(FT->isNoEscape() && "Defer statements must not escape");
       verifyCheckedBase(S);
     }
 
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index b0b242f..2d049de 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -1459,7 +1459,6 @@
   switch (getDeclContext()->getParentModule()->getResilienceStrategy()) {
   case ResilienceStrategy::Resilient:
     return false;
-  case ResilienceStrategy::Fragile:
   case ResilienceStrategy::Default:
     return true;
   }
@@ -2217,7 +2216,6 @@
   switch (getParentModule()->getResilienceStrategy()) {
   case ResilienceStrategy::Resilient:
     return false;
-  case ResilienceStrategy::Fragile:
   case ResilienceStrategy::Default:
     return true;
   }
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 265bbea..d920cec 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -926,9 +926,6 @@
 void Driver::buildInputs(const ToolChain &TC,
                          const DerivedArgList &Args,
                          InputFileList &Inputs) const {
-  types::ID InputType = types::TY_Nothing;
-  Arg *InputTypeArg = nullptr;
-
   llvm::StringMap<StringRef> SourceFileNames;
 
   for (Arg *A : Args) {
@@ -936,29 +933,19 @@
       StringRef Value = A->getValue();
       types::ID Ty = types::TY_INVALID;
 
-      if (InputType == types::TY_Nothing) {
-        // If there was an explicit arg for this, claim it.
-        if (InputTypeArg)
-          InputTypeArg->claim();
-
-        // stdin must be handled specially.
-        if (Value.equals("-")) {
-          // By default, treat stdin as Swift input.
-          // FIXME: should we limit this inference to specific modes?
-          Ty = types::TY_Swift;
-        } else {
-          // Otherwise lookup by extension.
-          Ty = TC.lookupTypeForExtension(llvm::sys::path::extension(Value));
-
-          if (Ty == types::TY_INVALID) {
-            // FIXME: should we adjust this inference in certain modes?
-            Ty = types::TY_Object;
-          }
-        }
+      // stdin must be handled specially.
+      if (Value.equals("-")) {
+        // By default, treat stdin as Swift input.
+        Ty = types::TY_Swift;
       } else {
-        assert(InputTypeArg && "InputType set w/o InputTypeArg");
-        InputTypeArg->claim();
-        Ty = InputType;
+        // Otherwise lookup by extension.
+        Ty = TC.lookupTypeForExtension(llvm::sys::path::extension(Value));
+
+        if (Ty == types::TY_INVALID) {
+          // By default, treat inputs with no extension, or with an
+          // extension that isn't recognized, as object files.
+          Ty = types::TY_Object;
+        }
       }
 
       if (checkInputExistence(*this, Args, Diags, Value))
@@ -973,8 +960,6 @@
         }
       }
     }
-
-    // FIXME: add -x support (or equivalent)
   }
 }
 
@@ -1158,12 +1143,10 @@
       OI.CompilerMode = OutputInfo::Mode::SingleCompile;
       break;
 
-    // BEGIN APPLE-ONLY OUTPUT ACTIONS
     case options::OPT_index_file:
       OI.CompilerMode = OutputInfo::Mode::SingleCompile;
       OI.CompilerOutputType = types::TY_IndexData;
       break;
-    // END APPLE-ONLY OUTPUT ACTIONS
 
     case options::OPT_update_code:
       OI.CompilerOutputType = types::TY_Remapping;
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 968bf8c..83bfba4 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -234,13 +234,9 @@
     case types::TY_ImportedModules:
       FrontendModeOption = "-emit-imported-modules";
       break;
-
-    // BEGIN APPLE-ONLY OUTPUT TYPES
     case types::TY_IndexData:
       FrontendModeOption = "-typecheck";
       break;
-    // END APPLE-ONLY OUTPUT TYPES
-
     case types::TY_Remapping:
       FrontendModeOption = "-update-code";
       break;
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 5eb4627..bd730c2 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -1373,7 +1373,6 @@
   if (Args.hasArg(OPT_sil_merge_partial_modules))
     Opts.MergePartialModules = true;
 
-  Opts.SILSerializeAll |= Args.hasArg(OPT_sil_serialize_all);
   Opts.SILSerializeWitnessTables |=
     Args.hasArg(OPT_sil_serialize_witness_tables);
   Opts.SILSerializeVTables |=
diff --git a/lib/Frontend/Frontend.cpp b/lib/Frontend/Frontend.cpp
index 2feb3e3..12454e2 100644
--- a/lib/Frontend/Frontend.cpp
+++ b/lib/Frontend/Frontend.cpp
@@ -258,8 +258,6 @@
 
     if (Invocation.getFrontendOptions().EnableResilience)
       MainModule->setResilienceStrategy(ResilienceStrategy::Resilient);
-    else if (Invocation.getSILOptions().SILSerializeAll)
-      MainModule->setResilienceStrategy(ResilienceStrategy::Fragile);
   }
   return MainModule;
 }
diff --git a/lib/FrontendTool/FrontendTool.cpp b/lib/FrontendTool/FrontendTool.cpp
index 3998777..ff2cffc 100644
--- a/lib/FrontendTool/FrontendTool.cpp
+++ b/lib/FrontendTool/FrontendTool.cpp
@@ -925,8 +925,6 @@
       serializationOpts.OutputPath = opts.ModuleOutputPath.c_str();
       serializationOpts.DocOutputPath = opts.ModuleDocOutputPath.c_str();
       serializationOpts.GroupInfoPath = opts.GroupInfoPath.c_str();
-      serializationOpts.SerializeAllSIL =
-          Invocation.getSILOptions().SILSerializeAll;
       if (opts.SerializeBridgingHeader)
         serializationOpts.ImportedHeader = opts.ImplicitObjCHeaderPath;
       serializationOpts.ModuleLinkName = opts.ModuleLinkName;
diff --git a/lib/IRGen/GenDecl.cpp b/lib/IRGen/GenDecl.cpp
index 4d13753..23fbb29 100644
--- a/lib/IRGen/GenDecl.cpp
+++ b/lib/IRGen/GenDecl.cpp
@@ -1314,44 +1314,11 @@
   llvm_unreachable("bad link entity kind");
 }
 
-bool LinkEntity::isFragile(ForDefinition_t isDefinition) const {
-  switch (getKind()) {
-    case Kind::SILFunction:
-      return getSILFunction()->isSerialized();
-      
-    case Kind::SILGlobalVariable:
-      return getSILGlobalVariable()->isSerialized();
-      
-    case Kind::ReflectionAssociatedTypeDescriptor:
-    case Kind::ReflectionSuperclassDescriptor:
-    case Kind::AssociatedTypeMetadataAccessFunction:
-    case Kind::AssociatedTypeWitnessTableAccessFunction:
-    case Kind::GenericProtocolWitnessTableCache:
-    case Kind::GenericProtocolWitnessTableInstantiationFunction:
-    case Kind::ObjCClassRef:
-      return false;
-
-    default:
-      break;
-  }
-  if (isProtocolConformanceKind(getKind())) {
-    auto conformance = getProtocolConformance();
-
-    auto conformanceModule = conformance->getDeclContext()->getParentModule();
-    auto isCompletelySerialized = conformanceModule->getResilienceStrategy() ==
-                                  ResilienceStrategy::Fragile;
-
-    // The conformance is fragile if it is in a -sil-serialize-all module.
-    return isCompletelySerialized;
-  }
-  return false;
-}
-
 static std::tuple<llvm::GlobalValue::LinkageTypes,
                   llvm::GlobalValue::VisibilityTypes,
                   llvm::GlobalValue::DLLStorageClassTypes>
 getIRLinkage(const UniversalLinkageInfo &info, SILLinkage linkage,
-             bool isFragile, bool isSILOnly, ForDefinition_t isDefinition,
+             bool isSILOnly, ForDefinition_t isDefinition,
              bool isWeakImported) {
 #define RESULT(LINKAGE, VISIBILITY, DLL_STORAGE)                               \
   std::make_tuple(llvm::GlobalValue::LINKAGE##Linkage,                         \
@@ -1372,29 +1339,6 @@
       info.UseDLLStorage ? llvm::GlobalValue::DLLImportStorageClass
                          : llvm::GlobalValue::DefaultStorageClass;
 
-  if (isFragile) {
-    // Fragile functions/globals must be visible from outside, regardless of
-    // their access level. If a caller is also fragile and inlined into another
-    // module it must be able to access this (not-inlined) function/global.
-    switch (linkage) {
-    case SILLinkage::Hidden:
-    case SILLinkage::Private:
-      linkage = SILLinkage::Public;
-      break;
-
-    case SILLinkage::HiddenExternal:
-    case SILLinkage::PrivateExternal:
-      linkage = SILLinkage::PublicExternal;
-      break;
-
-    case SILLinkage::Public:
-    case SILLinkage::Shared:
-    case SILLinkage::PublicExternal:
-    case SILLinkage::SharedExternal:
-      break;
-    }
-  }
-
   switch (linkage) {
   case SILLinkage::Public:
     // Don't code-gen transparent functions. Internal linkage will enable llvm
@@ -1453,8 +1397,7 @@
     return std::make_tuple(isDefinition
                                ? llvm::GlobalValue::AvailableExternallyLinkage
                                : llvm::GlobalValue::ExternalLinkage,
-                           isFragile ? llvm::GlobalValue::DefaultVisibility
-                                     : llvm::GlobalValue::HiddenVisibility,
+                           llvm::GlobalValue::HiddenVisibility,
                            ImportedStorage);
 
   }
@@ -1472,7 +1415,7 @@
   UniversalLinkageInfo linkInfo(IGM);
   auto linkage =
       getIRLinkage(linkInfo, entity.getLinkage(ForDefinition),
-                   entity.isFragile(ForDefinition), entity.isSILOnly(),
+                   entity.isSILOnly(),
                    ForDefinition, entity.isWeakImported(IGM.getSwiftModule()));
   global->setLinkage(std::get<0>(linkage));
   global->setVisibility(std::get<1>(linkage));
@@ -1504,7 +1447,7 @@
 
   std::tie(result.Linkage, result.Visibility, result.DLLStorageClass) =
       getIRLinkage(linkInfo, entity.getLinkage(isDefinition),
-                   entity.isFragile(isDefinition), entity.isSILOnly(),
+                   entity.isSILOnly(),
                    isDefinition, entity.isWeakImported(swiftModule));
 
   result.ForDefinition = isDefinition;
@@ -1515,20 +1458,19 @@
 LinkInfo LinkInfo::get(const UniversalLinkageInfo &linkInfo,
                        StringRef name,
                        SILLinkage linkage,
-                       bool isFragile,
                        bool isSILOnly,
                        ForDefinition_t isDefinition,
                        bool isWeakImported) {
   LinkInfo result;
-  
+
   result.Name += name;
   std::tie(result.Linkage, result.Visibility, result.DLLStorageClass) =
-    getIRLinkage(linkInfo, linkage, isFragile, isSILOnly,
+    getIRLinkage(linkInfo, linkage, isSILOnly,
                  isDefinition, isWeakImported);
   result.ForDefinition = isDefinition;
   return result;
 }
-                       
+
 static bool isPointerTo(llvm::Type *ptrTy, llvm::Type *objTy) {
   return cast<llvm::PointerType>(ptrTy)->getElementType() == objTy;
 }
diff --git a/lib/IRGen/GenKeyPath.cpp b/lib/IRGen/GenKeyPath.cpp
index 95c8d0f..868de2b 100644
--- a/lib/IRGen/GenKeyPath.cpp
+++ b/lib/IRGen/GenKeyPath.cpp
@@ -330,7 +330,6 @@
     
     auto linkInfo = LinkInfo::get(IGM, "swift_keyPathGenericWitnessTable",
                                   SILLinkage::PublicExternal,
-                                  /*fragile*/ false,
                                   /*sil only*/ false,
                                   NotForDefinition,
                                   /*weak imported*/ false);
diff --git a/lib/SIL/Linker.cpp b/lib/SIL/Linker.cpp
index 64e2687..ba0962f 100644
--- a/lib/SIL/Linker.cpp
+++ b/lib/SIL/Linker.cpp
@@ -27,26 +27,6 @@
 STATISTIC(NumFuncLinked, "Number of SIL functions linked");
 
 //===----------------------------------------------------------------------===//
-//                                  Utility
-//===----------------------------------------------------------------------===//
-
-/// \return True if the function \p F should be imported into the current
-/// module.
-static bool shouldImportFunction(SILFunction *F) {
-  // Skip functions that are marked with the 'no import' tag. These
-  // are functions that we don't want to copy from the module.
-  if (F->hasSemanticsAttr("stdlib_binary_only")) {
-    // If we are importing a function declaration mark it as external since we
-    // are not importing the body.
-    if (F->isExternalDeclaration())
-      F->setLinkage(SILLinkage::PublicExternal);
-    return false;
-  }
-
-  return true;
-}
-
-//===----------------------------------------------------------------------===//
 //                               Linker Helpers
 //===----------------------------------------------------------------------===//
 
@@ -55,9 +35,6 @@
   if (Mode == LinkingMode::LinkNone)
     return false;
 
-  if (!shouldImportFunction(F))
-    return false;
-
   // If F is a declaration, first deserialize it.
   if (F->isExternalDeclaration()) {
     auto *NewFn = Loader->lookupSILFunction(F);
@@ -334,9 +311,6 @@
   while (!Worklist.empty()) {
     auto *Fn = Worklist.pop_back_val();
 
-    if (!shouldImportFunction(Fn))
-      continue;
-
     DEBUG(llvm::dbgs() << "Process imports in function: "
                        << Fn->getName() << "\n");
 
@@ -346,9 +320,6 @@
         if (visit(&I)) {
           for (auto *F : FunctionDeserializationWorklist) {
 
-            if (!shouldImportFunction(F))
-              continue;
-
             DEBUG(llvm::dbgs() << "Imported function: "
                                << F->getName() << "\n");
             F->setBare(IsBare);
diff --git a/lib/SIL/SIL.cpp b/lib/SIL/SIL.cpp
index 090173b..97546d5 100644
--- a/lib/SIL/SIL.cpp
+++ b/lib/SIL/SIL.cpp
@@ -54,11 +54,6 @@
   case AccessLevel::Open:
     return FormalLinkage::PublicUnique;
   case AccessLevel::Internal:
-    // If we're serializing all function bodies, type metadata for internal
-    // types needs to be public too.
-    if (D->getDeclContext()->getParentModule()->getResilienceStrategy()
-        == ResilienceStrategy::Fragile)
-      return FormalLinkage::PublicUnique;
     return FormalLinkage::HiddenUnique;
   case AccessLevel::FilePrivate:
   case AccessLevel::Private:
diff --git a/lib/SILGen/SILGen.cpp b/lib/SILGen/SILGen.cpp
index aaa8b13..bb4e271 100644
--- a/lib/SILGen/SILGen.cpp
+++ b/lib/SILGen/SILGen.cpp
@@ -461,9 +461,6 @@
       if (isAvailableExternally(F->getLinkage())) {
         F->setLinkage(constant.getLinkage(ForDefinition));
       }
-      if (isMakeModuleFragile()) {
-        F->setSerialized(IsSerialized);
-      }
     }
     return F;
   }
@@ -523,13 +520,6 @@
 
   assert(F && "SILFunction should have been defined");
 
-  if (isMakeModuleFragile()) {
-    SILLinkage linkage = constant.getLinkage(forDefinition);
-    if (linkage != SILLinkage::PublicExternal) {
-      F->setSerialized(IsSerialized);
-    }
-  }
-
   emittedFunctions[constant] = F;
 
   // If we delayed emitting this function previously, we need it now.
@@ -994,9 +984,7 @@
       M.createFunction(SILLinkage::Private,
                        funcName, initSILType, nullptr,
                        SILLocation(binding), IsNotBare, IsNotTransparent,
-                       isMakeModuleFragile()
-                           ? IsSerialized
-                           : IsNotSerialized);
+                       IsNotSerialized);
   f->setDebugScope(new (M) SILDebugScope(RegularLocation(binding), f));
   SILGenFunction(*this, *f).emitLazyGlobalInitializer(binding, pbdEntry);
   f->verify();
diff --git a/lib/SILGen/SILGen.h b/lib/SILGen/SILGen.h
index f6f5701..acf14b0 100644
--- a/lib/SILGen/SILGen.h
+++ b/lib/SILGen/SILGen.h
@@ -121,13 +121,9 @@
   NormalProtocolConformance *lastEmittedConformance = nullptr;
 
   SILFunction *emitTopLevelFunction(SILLocation Loc);
-  
+
   size_t anonymousSymbolCounter = 0;
-  
-  /// If true, all functions and globals are made fragile. Currently only used
-  /// for compiling the stdlib.
-  bool isMakeModuleFragile() const { return M.getOptions().SILSerializeAll; }
-  
+
   Optional<SILDeclRef> StringToNSStringFn;
   Optional<SILDeclRef> NSStringToStringFn;
   Optional<SILDeclRef> ArrayToNSArrayFn;
diff --git a/lib/SILGen/SILGenGlobalVariable.cpp b/lib/SILGen/SILGenGlobalVariable.cpp
index fce4b4a..eb1f9ae 100644
--- a/lib/SILGen/SILGenGlobalVariable.cpp
+++ b/lib/SILGen/SILGenGlobalVariable.cpp
@@ -46,10 +46,7 @@
   SILLinkage link = getSILLinkage(getDeclLinkage(gDecl), forDef);
   SILType silTy = M.Types.getLoweredTypeOfGlobal(gDecl);
 
-  auto *silGlobal = SILGlobalVariable::create(M, link,
-                                              isMakeModuleFragile()
-                                                ? IsSerialized
-                                                : IsNotSerialized,
+  auto *silGlobal = SILGlobalVariable::create(M, link, IsNotSerialized,
                                               mangledName, silTy,
                                               None, gDecl);
   silGlobal->setDeclaration(!forDef);
@@ -223,9 +220,7 @@
   // TODO: include the module in the onceToken's name mangling.
   // Then we can make it fragile.
   auto onceToken = SILGlobalVariable::create(M, SILLinkage::Private,
-                                             isMakeModuleFragile()
-                                               ? IsSerialized
-                                               : IsNotSerialized,
+                                             IsNotSerialized,
                                              onceTokenBuffer, onceSILTy);
   onceToken->setDeclaration(false);
 
diff --git a/lib/SILGen/SILGenType.cpp b/lib/SILGen/SILGenType.cpp
index 936dafd..b9a549d 100644
--- a/lib/SILGen/SILGenType.cpp
+++ b/lib/SILGen/SILGenType.cpp
@@ -374,11 +374,6 @@
 
     Serialized = IsNotSerialized;
 
-    // Serialize the witness table if we're serializing everything with
-    // -sil-serialize-all....
-    if (SGM.isMakeModuleFragile())
-      Serialized = IsSerialized;
-
     // ... or if the conformance itself thinks it should be.
     if (SILWitnessTable::conformanceIsSerialized(
             Conformance, SGM.M.getSwiftModule()->getResilienceStrategy(),
@@ -482,9 +477,7 @@
     if (witnessSerialized &&
         fixmeWitnessHasLinkageThatNeedsToBePublic(witnessLinkage)) {
       witnessLinkage = SILLinkage::Public;
-      witnessSerialized = (SGM.isMakeModuleFragile()
-                           ? IsSerialized
-                           : IsNotSerialized);
+      witnessSerialized = IsNotSerialized;
     } else {
       // This is the "real" rule; the above case should go away once we
       // figure out what's going on.
diff --git a/lib/SILOptimizer/IPO/GlobalOpt.cpp b/lib/SILOptimizer/IPO/GlobalOpt.cpp
index d55d583..423922d 100644
--- a/lib/SILOptimizer/IPO/GlobalOpt.cpp
+++ b/lib/SILOptimizer/IPO/GlobalOpt.cpp
@@ -1353,11 +1353,9 @@
   if (!FD)
     return;
 
-  std::string Mangled = SILDeclRef(FD, SILDeclRef::Kind::Func).mangle();
-  SILFunction *replacementFunc = Module->findFunction(Mangled,
-                                                    SILLinkage::PublicExternal);
-  if (!replacementFunc)
-    return;
+  SILDeclRef declRef(FD, SILDeclRef::Kind::Func);
+  SILFunction *replacementFunc = Module->getOrCreateFunction(
+      FindStringCall->getLoc(), declRef, NotForDefinition);
 
   SILFunctionType *FTy = replacementFunc->getLoweredFunctionType();
   if (FTy->getNumParameters() != 3)
@@ -1367,6 +1365,7 @@
   NominalTypeDecl *cacheDecl = cacheType.getNominalOrBoundGenericNominal();
   if (!cacheDecl)
     return;
+
   SILType wordTy = cacheType.getFieldType(
                             cacheDecl->getStoredProperties().front(), *Module);
 
diff --git a/lib/SILOptimizer/Utils/Local.cpp b/lib/SILOptimizer/Utils/Local.cpp
index 00e2707..3c0bbbb 100644
--- a/lib/SILOptimizer/Utils/Local.cpp
+++ b/lib/SILOptimizer/Utils/Local.cpp
@@ -423,11 +423,7 @@
     return SILLinkage::Private;
   }
 
-  // Treat stdlib_binary_only specially. We don't serialize the body of
-  // stdlib_binary_only functions so we can't mark them as Shared (making
-  // their visibility in the dylib hidden).
-  return F->hasSemanticsAttr("stdlib_binary_only") ? SILLinkage::Public
-                                                   : SILLinkage::Shared;
+  return SILLinkage::Shared;
 }
 
 /// Remove all instructions in the body of \p BB in safe manner by using
diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp
index cb440be..bbae4f6 100644
--- a/lib/Sema/CSApply.cpp
+++ b/lib/Sema/CSApply.cpp
@@ -4071,9 +4071,14 @@
           
           auto dc = subscript->getInnermostDeclContext();
           SmallVector<Substitution, 4> subs;
+          SubstitutionMap subMap;
+          auto indexType = subscript->getIndicesInterfaceType();
+
           if (auto sig = dc->getGenericSignatureOfContext()) {
             // Compute substitutions to refer to the member.
             solution.computeSubstitutions(sig, locator, subs);
+            subMap = sig->getSubstitutionMap(subs);
+            indexType = indexType.subst(subMap);
           }
           
           auto resolvedTy = foundDecl->openedType->castTo<AnyFunctionType>()
@@ -4082,9 +4087,13 @@
           
           auto ref = ConcreteDeclRef(cs.getASTContext(), subscript, subs);
           
+          // Coerce the indices to the type the subscript expects.
+          auto indexExpr = coerceToType(origComponent.getIndexExpr(),
+                                        indexType,
+                                        locator);
+          
           component = KeyPathExpr::Component
-            ::forSubscriptWithPrebuiltIndexExpr(ref,
-                                            origComponent.getIndexExpr(),
+            ::forSubscriptWithPrebuiltIndexExpr(ref, indexExpr,
                                             origComponent.getSubscriptLabels(),
                                             resolvedTy,
                                             origComponent.getLoc(),
diff --git a/lib/Sema/TypeCheckGeneric.cpp b/lib/Sema/TypeCheckGeneric.cpp
index 7423c6c..21e9a12 100644
--- a/lib/Sema/TypeCheckGeneric.cpp
+++ b/lib/Sema/TypeCheckGeneric.cpp
@@ -873,8 +873,12 @@
 
     // 'throws' only applies to the innermost function.
     AnyFunctionType::ExtInfo info;
-    if (i == 0 && func->hasThrows())
-      info = info.withThrows();
+    if (i == 0) {
+      info = info.withThrows(func->hasThrows());
+      // Defer bodies must not escape.
+      if (auto fd = dyn_cast<FuncDecl>(func))
+        info = info.withNoEscape(fd->isDeferBody());
+    }
     
     assert(std::all_of(argTy.begin(), argTy.end(), [](const AnyFunctionType::Param &aty){
       return !aty.getType()->hasArchetype();
diff --git a/lib/Serialization/SerializeSIL.cpp b/lib/Serialization/SerializeSIL.cpp
index 84d0cf4..08c7717 100644
--- a/lib/Serialization/SerializeSIL.cpp
+++ b/lib/Serialization/SerializeSIL.cpp
@@ -2072,6 +2072,11 @@
 }
 
 void SILSerializer::writeSILVTable(const SILVTable &vt) {
+  // Do not emit vtables for non-public classes unless everything has to be
+  // serialized.
+  if (!ShouldSerializeAll &&
+      vt.getClass()->getEffectiveAccess() < swift::AccessLevel::Public)
+    return;
   VTableList[vt.getClass()->getName()] = NextVTableID++;
   VTableOffset.push_back(Out.GetCurrentBitNo());
   VTableLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[VTableLayout::Code],
@@ -2079,6 +2084,12 @@
 
   for (auto &entry : vt.getEntries()) {
     SmallVector<ValueID, 4> ListOfValues;
+    // Do not emit entries which are not public or serialized, unless everything
+    // has to be serialized.
+    if (!ShouldSerializeAll && entry.Implementation &&
+        !entry.Implementation->isPossiblyUsedExternally() &&
+        !entry.Implementation->isSerialized())
+      continue;
     handleSILDeclRef(S, entry.Method, ListOfValues);
     addReferencedSILFunction(entry.Implementation, true);
     // Each entry is a pair of SILDeclRef and SILFunction.
@@ -2283,7 +2294,8 @@
 
   // Write out fragile WitnessTables.
   for (const SILWitnessTable &wt : SILMod->getWitnessTables()) {
-    if ((ShouldSerializeAll || wt.isSerialized()) &&
+    if ((ShouldSerializeAll || SILMod->getOptions().SILSerializeWitnessTables ||
+         wt.isSerialized()) &&
         wt.getConformance()->getDeclContext()->isChildContextOf(assocDC))
       writeSILWitnessTable(wt);
   }
diff --git a/lib/Serialization/SerializedModuleLoader.cpp b/lib/Serialization/SerializedModuleLoader.cpp
index 09aa5f8..dfe6aa3 100644
--- a/lib/Serialization/SerializedModuleLoader.cpp
+++ b/lib/Serialization/SerializedModuleLoader.cpp
@@ -497,10 +497,6 @@
   if (isSIB()) {
     collectLinkLibrariesFromImports(callback);
   } else {
-    if (File.getAssociatedModule()->getResilienceStrategy()
-        == ResilienceStrategy::Fragile) {
-      collectLinkLibrariesFromImports(callback);
-    }
     File.collectLinkLibraries(callback);
   }
 }
diff --git a/stdlib/private/StdlibCollectionUnittest/CMakeLists.txt b/stdlib/private/StdlibCollectionUnittest/CMakeLists.txt
index db93305..55686cf 100644
--- a/stdlib/private/StdlibCollectionUnittest/CMakeLists.txt
+++ b/stdlib/private/StdlibCollectionUnittest/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(swift_stdlib_unittest_compile_flags)
 if(SWIFT_SERIALIZE_STDLIB_UNITTEST)
-  list(APPEND swift_stdlib_unittest_compile_flags "-Xfrontend" "-sil-serialize-all")
+  list(APPEND swift_stdlib_unittest_compile_flags "-Xfrontend" "-sil-serialize-witness-tables" "-Xfrontend" "-sil-serialize-vtables")
 endif()
 
 # TODO: support this on non-POSIX platforms.  It cannot be currently as it
diff --git a/stdlib/private/StdlibUnicodeUnittest/CMakeLists.txt b/stdlib/private/StdlibUnicodeUnittest/CMakeLists.txt
index a085944..4e30ef7 100644
--- a/stdlib/private/StdlibUnicodeUnittest/CMakeLists.txt
+++ b/stdlib/private/StdlibUnicodeUnittest/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(swift_stdlib_unittest_compile_flags)
 if(SWIFT_SERIALIZE_STDLIB_UNITTEST)
-  list(APPEND swift_stdlib_unittest_compile_flags "-Xfrontend" "-sil-serialize-all")
+  list(APPEND swift_stdlib_unittest_compile_flags "-Xfrontend" "-sil-serialize-witness-tables" "-Xfrontend" "-sil-serialize-vtables")
 endif()
 
 # TODO: support this on non-POSIX platforms.  It cannot be currently as it
diff --git a/stdlib/private/StdlibUnittest/CMakeLists.txt b/stdlib/private/StdlibUnittest/CMakeLists.txt
index 4db41c5..64cf737 100644
--- a/stdlib/private/StdlibUnittest/CMakeLists.txt
+++ b/stdlib/private/StdlibUnittest/CMakeLists.txt
@@ -5,7 +5,7 @@
   list(APPEND swift_stdlib_unittest_compile_flags "-DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER")
 endif()
 if(SWIFT_SERIALIZE_STDLIB_UNITTEST)
-  list(APPEND swift_stdlib_unittest_compile_flags "-Xfrontend" "-sil-serialize-all")
+  list(APPEND swift_stdlib_unittest_compile_flags "-Xfrontend" "-sil-serialize-witness-tables" "-Xfrontend" "-sil-serialize-vtables")
 endif()
 
 is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" IS_BUILD_TYPE_OPTIMIZED)
diff --git a/stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb b/stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb
index 51fe010..b8c9f03 100644
--- a/stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb
+++ b/stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb
@@ -627,7 +627,7 @@
 #endif
 
 // Avoid serializing references to objc_setUncaughtExceptionHandler in SIL.
-@inline(never) @_semantics("stdlib_binary_only")
+@inline(never)
 func _childProcess() {
   _stdlib_installTrapInterceptor()
 
diff --git a/stdlib/public/SwiftShims/CMakeLists.txt b/stdlib/public/SwiftShims/CMakeLists.txt
index 032b677..c719ede 100644
--- a/stdlib/public/SwiftShims/CMakeLists.txt
+++ b/stdlib/public/SwiftShims/CMakeLists.txt
@@ -12,6 +12,7 @@
   SwiftStdbool.h
   SwiftStddef.h
   SwiftStdint.h
+  System.h
   UnicodeShims.h
   Visibility.h
 
diff --git a/stdlib/public/SwiftShims/HeapObject.h b/stdlib/public/SwiftShims/HeapObject.h
index 4c93a7e..29b78b9 100644
--- a/stdlib/public/SwiftShims/HeapObject.h
+++ b/stdlib/public/SwiftShims/HeapObject.h
@@ -13,6 +13,7 @@
 #define SWIFT_STDLIB_SHIMS_HEAPOBJECT_H
 
 #include "RefCount.h"
+#include "System.h"
 
 #define SWIFT_ABI_HEAP_OBJECT_HEADER_SIZE_64 16
 // TODO: Should be 8
@@ -53,7 +54,7 @@
     : metadata(newMetadata)
     , refCounts(InlineRefCounts::Initialized)
   { }
-#endif
+#endif // __cplusplus
 };
 
 #ifdef __cplusplus
@@ -88,6 +89,107 @@
               "HeapObject must be pointer-aligned");
 
 } // end namespace swift
+#endif // __cplusplus
+
+/// Global bit masks
+
+// TODO(<rdar://problem/34837179>): Convert each macro below to static consts
+// when static consts are visible to SIL.
+
+// The extra inhabitants and spare bits of heap object pointers.
+// These must align with the values in IRGen's SwiftTargetInfo.cpp.
+#if defined(__x86_64__)
+
+#ifdef __APPLE__
+#define _swift_abi_LeastValidPointerValue                                      \
+  (__swift_uintptr_t) SWIFT_ABI_DARWIN_X86_64_LEAST_VALID_POINTER
+#else
+#define _swift_abi_LeastValidPointerValue                                      \
+  (__swift_uintptr_t) SWIFT_ABI_DEFAULT_LEAST_VALID_POINTER
+#endif
+#define _swift_abi_SwiftSpareBitsMask                                          \
+  (__swift_uintptr_t) SWIFT_ABI_X86_64_SWIFT_SPARE_BITS_MASK
+#define _swift_abi_ObjCReservedBitsMask                                        \
+  (__swift_uintptr_t) SWIFT_ABI_X86_64_OBJC_RESERVED_BITS_MASK
+#define _swift_abi_ObjCReservedLowBits                                         \
+  (unsigned) SWIFT_ABI_X86_64_OBJC_NUM_RESERVED_LOW_BITS
+
+#elif defined(__arm64__)
+
+#ifdef __APPLE__
+#define _swift_abi_LeastValidPointerValue                                      \
+  (__swift_uintptr_t) SWIFT_ABI_DARWIN_ARM64_LEAST_VALID_POINTER
+#else
+#define _swift_abi_LeastValidPointerValue                                      \
+  (__swift_uintptr_t) SWIFT_ABI_DEFAULT_LEAST_VALID_POINTER
+#endif
+#define _swift_abi_SwiftSpareBitsMask                                          \
+  (__swift_uintptr_t) SWIFT_ABI_ARM64_SWIFT_SPARE_BITS_MASK
+#define _swift_abi_ObjCReservedBitsMask                                        \
+  (__swift_uintptr_t) SWIFT_ABI_ARM64_OBJC_RESERVED_BITS_MASK
+#define _swift_abi_ObjCReservedLowBits                                         \
+  (unsigned) SWIFT_ABI_ARM64_OBJC_NUM_RESERVED_LOW_BITS
+
+#elif defined(__powerpc64__)
+
+#define _swift_abi_LeastValidPointerValue                                      \
+  (__swift_uintptr_t) SWIFT_ABI_DEFAULT_LEAST_VALID_POINTER
+#define _swift_abi_SwiftSpareBitsMask                                          \
+  (__swift_uintptr_t) SWIFT_ABI_POWERPC64_SWIFT_SPARE_BITS_MASK
+#define _swift_abi_ObjCReservedBitsMask                                        \
+  (__swift_uintptr_t) SWIFT_ABI_DEFAULT_OBJC_RESERVED_BITS_MASK
+#define _swift_abi_ObjCReservedLowBits                                         \
+  (unsigned) SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS
+
+#elif defined(__s390x__)
+
+#define _swift_abi_LeastValidPointerValue                                      \
+  (__swift_uintptr_t) SWIFT_ABI_DEFAULT_LEAST_VALID_POINTER
+#define _swift_abi_SwiftSpareBitsMask                                          \
+  (__swift_uintptr_t) SWIFT_ABI_S390X_SWIFT_SPARE_BITS_MASK
+#define _swift_abi_ObjCReservedBitsMask                                        \
+  (__swift_uintptr_t) SWIFT_ABI_DEFAULT_OBJC_RESERVED_BITS_MASK
+#define _swift_abi_ObjCReservedLowBits                                         \
+  (unsigned) SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS
+
+#else
+
+#define _swift_abi_LeastValidPointerValue                                      \
+  (__swift_uintptr_t) SWIFT_ABI_DEFAULT_LEAST_VALID_POINTER
+
+#if __i386__
+#define _swift_abi_SwiftSpareBitsMask                                          \
+  (__swift_uintptr_t) SWIFT_ABI_I386_SWIFT_SPARE_BITS_MASK
+#elif __arm__
+#define _swift_abi_SwiftSpareBitsMask                                          \
+  (__swift_uintptr_t) SWIFT_ABI_ARM_SWIFT_SPARE_BITS_MASK
+#else
+#define _swift_abi_SwiftSpareBitsMask                                          \
+  (__swift_uintptr_t) SWIFT_ABI_DEFAULT_SWIFT_SPARE_BITS_MASK
 #endif
 
+#define _swift_abi_ObjCReservedBitsMask                                        \
+  (__swift_uintptr_t) SWIFT_ABI_DEFAULT_OBJC_RESERVED_BITS_MASK
+#define _swift_abi_ObjCReservedLowBits                                         \
+  (unsigned) SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS
 #endif
+
+/// Corresponding namespaced decls
+#ifdef __cplusplus
+namespace heap_object_abi {
+static const __swift_uintptr_t LeastValidPointerValue =
+    _swift_abi_LeastValidPointerValue;
+static const __swift_uintptr_t SwiftSpareBitsMask =
+    _swift_abi_SwiftSpareBitsMask;
+static const __swift_uintptr_t ObjCReservedBitsMask =
+    _swift_abi_ObjCReservedBitsMask;
+static const unsigned ObjCReservedLowBits = _swift_abi_ObjCReservedLowBits;
+} // heap_object_abi
+#endif // __cplusplus
+
+/// BridgeObject masks
+
+#define _swift_BridgeObject_TaggedPointerBits _swift_abi_ObjCReservedBitsMask
+
+
+#endif // SWIFT_STDLIB_SHIMS_HEAPOBJECT_H
diff --git a/stdlib/public/SwiftShims/System.h b/stdlib/public/SwiftShims/System.h
new file mode 100644
index 0000000..7e7275f
--- /dev/null
+++ b/stdlib/public/SwiftShims/System.h
@@ -0,0 +1,141 @@
+//===--- System.h - Swift ABI system-specific constants ---------*- C++ -*-===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+//
+// Here are some fun facts about the target platforms we support!
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SWIFT_ABI_SYSTEM_H
+#define SWIFT_ABI_SYSTEM_H
+
+// In general, these macros are expected to expand to host-independent
+// integer constant expressions.  This allows the same data to feed
+// both the compiler and runtime implementation.
+
+/******************************* Default Rules ********************************/
+
+/// The least valid pointer value for an actual pointer (as opposed to
+/// Objective-C pointers, which may be tagged pointers and are covered
+/// separately).  Values up to this are "extra inhabitants" of the
+/// pointer representation, and payloaded enum types can take
+/// advantage of that as they see fit.
+///
+/// By default, we assume that there's at least an unmapped page at
+/// the bottom of the address space.  4K is a reasonably likely page
+/// size.
+///
+/// The minimum possible value for this macro is 1; we always assume
+/// that the null representation is available.
+#define SWIFT_ABI_DEFAULT_LEAST_VALID_POINTER 4096
+
+/// The bitmask of spare bits in a function pointer.
+#define SWIFT_ABI_DEFAULT_FUNCTION_SPARE_BITS_MASK 0
+
+/// The bitmask of spare bits in a Swift heap object pointer.  A Swift
+/// heap object allocation will never set any of these bits.
+#define SWIFT_ABI_DEFAULT_SWIFT_SPARE_BITS_MASK 0
+
+/// The bitmask of reserved bits in an Objective-C object pointer.
+/// By default we assume the ObjC runtime doesn't use tagged pointers.
+#define SWIFT_ABI_DEFAULT_OBJC_RESERVED_BITS_MASK 0
+
+/// The number of low bits in an Objective-C object pointer that
+/// are reserved by the Objective-C runtime.
+#define SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS 0
+
+/// The ObjC runtime will not use pointer values for which
+/// ``pointer & SWIFT_ABI_XXX_OBJC_RESERVED_BITS_MASK == 0 && 
+/// pointer & SWIFT_ABI_XXX_SWIFT_SPARE_BITS_MASK != 0``.
+
+// Weak references use a marker to tell when they are controlled by
+// the ObjC runtime and when they are controlled by the Swift runtime.
+// Non-ObjC platforms don't use this marker.
+#define SWIFT_ABI_DEFAULT_OBJC_WEAK_REFERENCE_MARKER_MASK 0
+#define SWIFT_ABI_DEFAULT_OBJC_WEAK_REFERENCE_MARKER_VALUE 0
+
+/*********************************** i386 *************************************/
+
+// Heap objects are pointer-aligned, so the low two bits are unused.
+#define SWIFT_ABI_I386_SWIFT_SPARE_BITS_MASK 0x00000003U
+
+// ObjC weak reference discriminator is the LSB.
+#define SWIFT_ABI_I386_OBJC_WEAK_REFERENCE_MARKER_MASK  \
+  (SWIFT_ABI_DEFAULT_OBJC_RESERVED_BITS_MASK |          \
+   1<<SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS)
+#define SWIFT_ABI_I386_OBJC_WEAK_REFERENCE_MARKER_VALUE \
+  (1<<SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS)
+
+/*********************************** arm **************************************/
+
+// Heap objects are pointer-aligned, so the low two bits are unused.
+#define SWIFT_ABI_ARM_SWIFT_SPARE_BITS_MASK 0x00000003U
+
+// ObjC weak reference discriminator is the LSB.
+#define SWIFT_ABI_ARM_OBJC_WEAK_REFERENCE_MARKER_MASK  \
+  (SWIFT_ABI_DEFAULT_OBJC_RESERVED_BITS_MASK |          \
+   1<<SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS)
+#define SWIFT_ABI_ARM_OBJC_WEAK_REFERENCE_MARKER_VALUE \
+  (1<<SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS)
+
+/*********************************** x86-64 ***********************************/
+
+/// Darwin reserves the low 4GB of address space.
+#define SWIFT_ABI_DARWIN_X86_64_LEAST_VALID_POINTER 0x100000000ULL
+
+// Only the bottom 56 bits are used, and heap objects are eight-byte-aligned.
+#define SWIFT_ABI_X86_64_SWIFT_SPARE_BITS_MASK 0xFF00000000000007ULL
+
+// Objective-C reserves the high and low bits for tagged pointers.
+// Systems exist which use either bit.
+#define SWIFT_ABI_X86_64_OBJC_RESERVED_BITS_MASK 0x8000000000000001ULL
+#define SWIFT_ABI_X86_64_OBJC_NUM_RESERVED_LOW_BITS 1
+
+// ObjC weak reference discriminator is the two bits
+// reserved for ObjC tagged pointers plus one more low bit.
+#define SWIFT_ABI_X86_64_OBJC_WEAK_REFERENCE_MARKER_MASK  \
+  (SWIFT_ABI_X86_64_OBJC_RESERVED_BITS_MASK |          \
+   1<<SWIFT_ABI_X86_64_OBJC_NUM_RESERVED_LOW_BITS)
+#define SWIFT_ABI_X86_64_OBJC_WEAK_REFERENCE_MARKER_VALUE \
+  (1<<SWIFT_ABI_X86_64_OBJC_NUM_RESERVED_LOW_BITS)
+
+/*********************************** arm64 ************************************/
+
+/// Darwin reserves the low 4GB of address space.
+#define SWIFT_ABI_DARWIN_ARM64_LEAST_VALID_POINTER 0x100000000ULL
+
+// TBI guarantees the top byte of pointers is unused.
+// Heap objects are eight-byte aligned.
+#define SWIFT_ABI_ARM64_SWIFT_SPARE_BITS_MASK 0xFF00000000000007ULL
+
+// Objective-C reserves just the high bit for tagged pointers.
+#define SWIFT_ABI_ARM64_OBJC_RESERVED_BITS_MASK 0x8000000000000000ULL
+#define SWIFT_ABI_ARM64_OBJC_NUM_RESERVED_LOW_BITS 0
+
+// ObjC weak reference discriminator is the high bit
+// reserved for ObjC tagged pointers plus the LSB.
+#define SWIFT_ABI_ARM64_OBJC_WEAK_REFERENCE_MARKER_MASK  \
+  (SWIFT_ABI_ARM64_OBJC_RESERVED_BITS_MASK |          \
+   1<<SWIFT_ABI_ARM64_OBJC_NUM_RESERVED_LOW_BITS)
+#define SWIFT_ABI_ARM64_OBJC_WEAK_REFERENCE_MARKER_VALUE \
+  (1<<SWIFT_ABI_ARM64_OBJC_NUM_RESERVED_LOW_BITS)
+
+/*********************************** powerpc64 ********************************/
+
+// Heap objects are pointer-aligned, so the low three bits are unused.
+#define SWIFT_ABI_POWERPC64_SWIFT_SPARE_BITS_MASK 0x0000000000000007ULL
+
+/*********************************** s390x ************************************/
+
+// Top byte of pointers is unused, and heap objects are eight-byte aligned.
+#define SWIFT_ABI_S390X_SWIFT_SPARE_BITS_MASK 0x0000000000000007ULL
+
+#endif /* SWIFT_ABI_SYSTEM_H */
diff --git a/stdlib/public/SwiftShims/module.modulemap b/stdlib/public/SwiftShims/module.modulemap
index 5b48587..4666fa4 100644
--- a/stdlib/public/SwiftShims/module.modulemap
+++ b/stdlib/public/SwiftShims/module.modulemap
@@ -12,6 +12,7 @@
   header "SwiftStdbool.h"
   header "SwiftStddef.h"
   header "SwiftStdint.h"
+  header "System.h"
   header "UnicodeShims.h"
   header "Visibility.h"
   export *
diff --git a/stdlib/public/core/AssertCommon.swift b/stdlib/public/core/AssertCommon.swift
index 98525ce..0dc9a28 100644
--- a/stdlib/public/core/AssertCommon.swift
+++ b/stdlib/public/core/AssertCommon.swift
@@ -82,10 +82,8 @@
 ///
 /// This function should not be inlined because it is cold and inlining just
 /// bloats code.
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
+@_versioned // FIXME(sil-serialize-all)
 @inline(never)
-@_semantics("stdlib_binary_only")
 internal func _assertionFailure(
   _ prefix: StaticString, _ message: StaticString,
   file: StaticString, line: UInt,
@@ -114,10 +112,8 @@
 ///
 /// This function should not be inlined because it is cold and inlining just
 /// bloats code.
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
+@_versioned // FIXME(sil-serialize-all)
 @inline(never)
-@_semantics("stdlib_binary_only")
 internal func _assertionFailure(
   _ prefix: StaticString, _ message: String,
   file: StaticString, line: UInt,
@@ -146,10 +142,8 @@
 ///
 /// This function should not be inlined because it is cold and it inlining just
 /// bloats code.
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
+@_versioned // FIXME(sil-serialize-all)
 @inline(never)
-@_semantics("stdlib_binary_only")
 @_semantics("arc.programtermination_point")
 internal func _fatalErrorMessage(
   _ prefix: StaticString, _ message: StaticString,
diff --git a/stdlib/public/core/Builtin.swift b/stdlib/public/core/Builtin.swift
index 1f43104..72e2592 100644
--- a/stdlib/public/core/Builtin.swift
+++ b/stdlib/public/core/Builtin.swift
@@ -348,111 +348,44 @@
 
 //===--- Builtin.BridgeObject ---------------------------------------------===//
 
-#if arch(i386) || arch(arm)
+// TODO(<rdar://problem/34837023>): Get rid of superfluous UInt constructor
+// calls
+
+@_inlineable // FIXME(sil-serialize-all)
+@_versioned
+internal var _objCTaggedPointerBits: UInt {
+  @inline(__always) get { return UInt(_swift_BridgeObject_TaggedPointerBits) }
+}
 @_inlineable // FIXME(sil-serialize-all)
 @_versioned
 internal var _objectPointerSpareBits: UInt {
-    @inline(__always) get { return 0x0000_0003 }
+    @inline(__always) get {
+      return UInt(_swift_abi_SwiftSpareBitsMask) & ~_objCTaggedPointerBits
+    }
 }
 @_inlineable // FIXME(sil-serialize-all)
 @_versioned
+internal var _objectPointerLowSpareBitShift: UInt {
+    @inline(__always) get {
+      _sanityCheck(_swift_abi_ObjCReservedLowBits < 2,
+        "num bits now differs from num-shift-amount, new platform?")
+      return UInt(_swift_abi_ObjCReservedLowBits)
+    }
+}
+
+#if arch(i386) || arch(arm) || arch(powerpc64) || arch(powerpc64le) || arch(
+  s390x)
+@_inlineable // FIXME(sil-serialize-all)
+@_versioned
 internal var _objectPointerIsObjCBit: UInt {
     @inline(__always) get { return 0x0000_0002 }
 }
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objectPointerLowSpareBitShift: UInt {
-    @inline(__always) get { return 0 }
-}
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objCTaggedPointerBits: UInt {
-  @inline(__always) get { return 0 }
-}
-#elseif arch(x86_64)
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objectPointerSpareBits: UInt {
-  @inline(__always) get { return 0x7F00_0000_0000_0006 }
-}
+#else
 @_inlineable // FIXME(sil-serialize-all)
 @_versioned
 internal var _objectPointerIsObjCBit: UInt {
   @inline(__always) get { return 0x4000_0000_0000_0000 }
 }
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objectPointerLowSpareBitShift: UInt {
-  @inline(__always) get { return 1 }
-}
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objCTaggedPointerBits: UInt {
-  @inline(__always) get { return 0x8000_0000_0000_0001 }
-}
-#elseif arch(arm64)
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objectPointerSpareBits: UInt {
-  @inline(__always) get { return 0x7F00_0000_0000_0007 }
-}
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objectPointerIsObjCBit: UInt {
-  @inline(__always) get { return 0x4000_0000_0000_0000 }
-}
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objectPointerLowSpareBitShift: UInt {
-    @inline(__always) get { return 0 }
-}
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objCTaggedPointerBits: UInt {
-    @inline(__always) get { return 0x8000_0000_0000_0000 }
-}
-#elseif arch(powerpc64) || arch(powerpc64le)
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objectPointerSpareBits: UInt {
-  @inline(__always) get { return 0x0000_0000_0000_0007 }
-}
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objectPointerIsObjCBit: UInt {
-  @inline(__always) get { return 0x0000_0000_0000_0002 }
-}
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objectPointerLowSpareBitShift: UInt {
-    @inline(__always) get { return 0 }
-}
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objCTaggedPointerBits: UInt {
-    @inline(__always) get { return 0 }
-}
-#elseif arch(s390x)
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objectPointerSpareBits: UInt {
-  @inline(__always) get { return 0x0000_0000_0000_0007 }
-}
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objectPointerIsObjCBit: UInt {
-  @inline(__always) get { return 0x0000_0000_0000_0002 }
-}
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objectPointerLowSpareBitShift: UInt {
-  @inline(__always) get { return 0 }
-}
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-internal var _objCTaggedPointerBits: UInt {
-  @inline(__always) get { return 0 }
-}
 #endif
 
 /// Extract the raw bits of `x`.
diff --git a/stdlib/public/core/DebuggerSupport.swift b/stdlib/public/core/DebuggerSupport.swift
index 971e27f..e4eac6d 100644
--- a/stdlib/public/core/DebuggerSupport.swift
+++ b/stdlib/public/core/DebuggerSupport.swift
@@ -305,10 +305,8 @@
   }
 
   // LLDB uses this function in expressions, and if it is inlined the resulting
-  // LLVM IR is enormous.  As a result, to improve LLDB performance we have made
-  // this stdlib_binary_only, which prevents inlining.
-  @_inlineable // FIXME(sil-serialize-all)
-  @_semantics("stdlib_binary_only")
+  // LLVM IR is enormous.  As a result, to improve LLDB performance we are not
+  // making it @_inlineable.
   public static func stringForPrintObject(_ value: Any) -> String {
     var maxItemCounter = Int.max
     var refs = Set<ObjectIdentifier>()
diff --git a/stdlib/public/core/HashedCollections.swift.gyb b/stdlib/public/core/HashedCollections.swift.gyb
index dd31cb1..36f88c8 100644
--- a/stdlib/public/core/HashedCollections.swift.gyb
+++ b/stdlib/public/core/HashedCollections.swift.gyb
@@ -2868,9 +2868,7 @@
 ///
 /// - Precondition: `SwiftKey` and `SwiftValue` are bridged to Objective-C,
 ///   and at least one of them requires non-trivial bridging.
-@_inlineable // FIXME(sil-serialize-all)
 @inline(never)
-@_semantics("stdlib_binary_only")
 public func _dictionaryBridgeToObjectiveC<
   SwiftKey, SwiftValue, ObjCKey, ObjCValue
 >(
diff --git a/stdlib/public/core/OutputStream.swift b/stdlib/public/core/OutputStream.swift
index 1bcde5a..6c5fc23 100644
--- a/stdlib/public/core/OutputStream.swift
+++ b/stdlib/public/core/OutputStream.swift
@@ -343,11 +343,9 @@
   }
 }
 
-@_inlineable // FIXME(sil-serialize-all)
 @_versioned
 @inline(never)
 @_semantics("optimize.sil.specialize.generic.never")
-@_semantics("stdlib_binary_only")
 internal func _print_unlocked<T, TargetStream : TextOutputStream>(
   _ value: T, _ target: inout TargetStream
 ) {
diff --git a/stdlib/public/core/Print.swift b/stdlib/public/core/Print.swift
index 41e3546..d9e3935 100644
--- a/stdlib/public/core/Print.swift
+++ b/stdlib/public/core/Print.swift
@@ -49,9 +49,7 @@
 ///     space (`" "`).
 ///   - terminator: The string to print after all items have been printed. The
 ///     default is a newline (`"\n"`).
-@_inlineable // FIXME(sil-serialize-all)
 @inline(never)
-@_semantics("stdlib_binary_only")
 public func print(
   _ items: Any...,
   separator: String = " ",
@@ -110,9 +108,7 @@
 ///     space (`" "`).
 ///   - terminator: The string to print after all items have been printed. The
 ///     default is a newline (`"\n"`).
-@_inlineable // FIXME(sil-serialize-all)
 @inline(never)
-@_semantics("stdlib_binary_only")
 public func debugPrint(
   _ items: Any...,
   separator: String = " ",
@@ -228,10 +224,8 @@
     items, separator: separator, terminator: terminator, to: &output)
 }
 
-@_inlineable // FIXME(sil-serialize-all)
 @_versioned
 @inline(never)
-@_semantics("stdlib_binary_only")
 internal func _print<Target : TextOutputStream>(
   _ items: [Any],
   separator: String = " ",
@@ -249,10 +243,8 @@
   output.write(terminator)
 }
 
-@_inlineable // FIXME(sil-serialize-all)
 @_versioned
 @inline(never)
-@_semantics("stdlib_binary_only")
 internal func _debugPrint<Target : TextOutputStream>(
   _ items: [Any],
   separator: String = " ",
diff --git a/stdlib/public/core/REPL.swift b/stdlib/public/core/REPL.swift
index 160a7c6..6b965f0 100644
--- a/stdlib/public/core/REPL.swift
+++ b/stdlib/public/core/REPL.swift
@@ -18,9 +18,7 @@
 }
 
 /// Print the debug representation of `value`, followed by a newline.
-@_inlineable // FIXME(sil-serialize-all)
 @inline(never)
-@_semantics("stdlib_binary_only")
 public // COMPILER_INTRINSIC
 func _replDebugPrintln<T>(_ value: T) {
   debugPrint(value)
diff --git a/stdlib/public/core/StringBridge.swift b/stdlib/public/core/StringBridge.swift
index 6faf030..50d74dd 100644
--- a/stdlib/public/core/StringBridge.swift
+++ b/stdlib/public/core/StringBridge.swift
@@ -47,9 +47,8 @@
 
 /// Bridges `source` to `Swift.String`, assuming that `source` has non-ASCII
 /// characters (does not apply ASCII optimizations).
-@_inlineable // FIXME(sil-serialize-all)
 @_versioned // FIXME(sil-serialize-all)
-@inline(never) @_semantics("stdlib_binary_only") // Hide the CF dependency
+@inline(never) // Hide the CF dependency
 func _cocoaStringToSwiftString_NonASCII(
   _ source: _CocoaString
 ) -> String {
@@ -70,9 +69,8 @@
 
 /// Produces a `_StringBuffer` from a given subrange of a source
 /// `_CocoaString`, having the given minimum capacity.
-@_inlineable // FIXME(sil-serialize-all)
 @_versioned // FIXME(sil-serialize-all)
-@inline(never) @_semantics("stdlib_binary_only") // Hide the CF dependency
+@inline(never) // Hide the CF dependency
 internal func _cocoaStringToContiguous(
   source: _CocoaString, range: Range<Int>, minimumCapacity: Int
 ) -> _StringBuffer {
@@ -94,9 +92,8 @@
 
 /// Reads the entire contents of a _CocoaString into contiguous
 /// storage of sufficient capacity.
-@_inlineable // FIXME(sil-serialize-all)
 @_versioned // FIXME(sil-serialize-all)
-@inline(never) @_semantics("stdlib_binary_only") // Hide the CF dependency
+@inline(never) // Hide the CF dependency
 internal func _cocoaStringReadAll(
   _ source: _CocoaString, _ destination: UnsafeMutablePointer<UTF16.CodeUnit>
 ) {
@@ -105,9 +102,8 @@
       location: 0, length: _swift_stdlib_CFStringGetLength(source)), destination)
 }
 
-@_inlineable // FIXME(sil-serialize-all)
 @_versioned // FIXME(sil-serialize-all)
-@inline(never) @_semantics("stdlib_binary_only") // Hide the CF dependency
+@inline(never) // Hide the CF dependency
 internal func _cocoaStringSlice(
   _ target: _StringCore, _ bounds: Range<Int>
 ) -> _StringCore {
@@ -126,9 +122,8 @@
   return String(_cocoaString: cfResult)._core
 }
 
-@_inlineable // FIXME(sil-serialize-all)
-@_versioned
-@inline(never) @_semantics("stdlib_binary_only") // Hide the CF dependency
+@_versioned // FIXME(sil-serialize-all)
+@inline(never) // Hide the CF dependency
 internal func _cocoaStringSubscript(
   _ target: _StringCore, _ position: Int
 ) -> UTF16.CodeUnit {
@@ -151,8 +146,7 @@
 }
 
 extension String {
-  @_inlineable // FIXME(sil-serialize-all)
-  @inline(never) @_semantics("stdlib_binary_only") // Hide the CF dependency
+  @inline(never) // Hide the CF dependency
   public // SPI(Foundation)
   init(_cocoaString: AnyObject) {
     if let wrapped = _cocoaString as? _NSContiguousString {
@@ -374,8 +368,7 @@
     return _NSContiguousString(_core)
   }
 
-  @_inlineable // FIXME(sil-serialize-all)
-  @inline(never) @_semantics("stdlib_binary_only") // Hide the CF dependency
+  @inline(never) // Hide the CF dependency
   public func _bridgeToObjectiveCImpl() -> AnyObject {
     return _stdlib_binary_bridgeToObjectiveCImpl()
   }
diff --git a/stdlib/public/core/StringComparable.swift b/stdlib/public/core/StringComparable.swift
index 0f4eea4..fb9f39f 100644
--- a/stdlib/public/core/StringComparable.swift
+++ b/stdlib/public/core/StringComparable.swift
@@ -77,9 +77,7 @@
 #endif
 
   /// Compares two strings with the Unicode Collation Algorithm.
-  @_inlineable // FIXME(sil-serialize-all)
-  @inline(never)
-  @_semantics("stdlib_binary_only") // Hide the CF/ICU dependency
+  @inline(never) // Hide the CF/ICU dependency
   public  // @testable
   func _compareDeterministicUnicodeCollation(_ rhs: String) -> Int {
     // Note: this operation should be consistent with equality comparison of
diff --git a/stdlib/public/core/StringHashable.swift b/stdlib/public/core/StringHashable.swift
index b70a5e3..9ce23b8 100644
--- a/stdlib/public/core/StringHashable.swift
+++ b/stdlib/public/core/StringHashable.swift
@@ -82,10 +82,8 @@
   }
 }
 
-// FIXME: cannot be marked @_inlineable. See <rdar://problem/34438258>
-// @_inlineable // FIXME(sil-serialize-all)
 @_versioned // FIXME(sil-serialize-all)
-@inline(never) @_semantics("stdlib_binary_only") // Hide the CF dependency
+@inline(never) // Hide the CF dependency
 internal func _hashString(_ string: String) -> Int {
   let core = string._core
 #if _runtime(_ObjC)
diff --git a/stdlib/public/core/StringSwitch.swift b/stdlib/public/core/StringSwitch.swift
index f9a8783..b1e90c8 100644
--- a/stdlib/public/core/StringSwitch.swift
+++ b/stdlib/public/core/StringSwitch.swift
@@ -16,8 +16,6 @@
 
 /// The compiler intrinsic which is called to lookup a string in a table
 /// of static string case values.
-@_inlineable // FIXME(sil-serialize-all)
-@_semantics("stdlib_binary_only")
 @_semantics("findStringSwitchCase")
 public // COMPILER_INTRINSIC
 func _findStringSwitchCase(
@@ -68,8 +66,6 @@
 /// in \p cache. Consecutive calls use the cache for faster lookup.
 /// The \p cases array must not change between subsequent calls with the
 /// same \p cache.
-@_inlineable // FIXME(sil-serialize-all)
-@_semantics("stdlib_binary_only")
 @_semantics("findStringSwitchCaseWithCache")
 public // COMPILER_INTRINSIC
 func _findStringSwitchCaseWithCache(
diff --git a/test/Driver/emit-sib-single-file.swift b/test/Driver/emit-sib-single-file.swift
index ad84496..7b7f8d9 100644
--- a/test/Driver/emit-sib-single-file.swift
+++ b/test/Driver/emit-sib-single-file.swift
@@ -18,6 +18,8 @@
 // CHECK: Hello World
 // CHECK: Hello Bob, today is Tuesday.
 
+@_inlineable
+@_versioned
 func greet(_ name: String, _ day: String) -> String {
   return "Hello \(name), today is \(day)."
 }
diff --git a/test/IRGen/sil_linkage.sil b/test/IRGen/sil_linkage.sil
index 2b5a586..b32a9ba 100644
--- a/test/IRGen/sil_linkage.sil
+++ b/test/IRGen/sil_linkage.sil
@@ -5,13 +5,13 @@
 // CHECK: define{{( protected)?}} swiftcc void @public_fragile_function_test() {{.*}} {
 // CHECK: define{{( protected)?}} internal swiftcc void @public_transparent_fragile_function_test() {{.*}} {
 // CHECK: define{{( protected)?}} swiftcc void @public_transparent_function_test() {{.*}} {
-// CHECK: define{{( protected)?}} swiftcc void @hidden_fragile_function_test() {{.*}} {
+// CHECK: define{{( hidden)?}} swiftcc void @hidden_fragile_function_test() {{.*}} {
 // CHECK: define linkonce_odr hidden swiftcc void @shared_fragile_function_test() {{.*}} {
-// CHECK: define{{( protected)?}} swiftcc void @private_fragile_function_test() {{.*}} {
+// CHECK: define{{( internal)?}} swiftcc void @private_fragile_function_test() {{.*}} {
 // CHECK: define available_externally swiftcc void @public_external_fragile_function_def_test() {{.*}} {
-// CHECK: define{{( protected)?}} available_externally swiftcc void @hidden_external_fragile_function_def_test() {{.*}} {
+// CHECK: define{{( protected)?}} available_externally{{ (hidden)?}} swiftcc void @hidden_external_fragile_function_def_test() {{.*}} {
 // CHECK: define linkonce_odr hidden swiftcc void @shared_external_fragile_function_def_test() {{.*}} {
-// CHECK: define{{( protected)?}} available_externally swiftcc void @private_external_fragile_function_def_test() {{.*}} {
+// CHECK: define{{( protected)?}} available_externally{{ (hidden)?}} swiftcc void @private_external_fragile_function_def_test() {{.*}} {
 // CHECK: define{{( protected)?}} swiftcc void @public_resilient_function_test() {{.*}} {
 // CHECK: define hidden swiftcc void @hidden_resilient_function_test() {{.*}} {
 // CHECK: define linkonce_odr hidden swiftcc void @shared_resilient_function_test() {{.*}} {
diff --git a/test/IRGen/sil_witness_tables_external_witnesstable.swift b/test/IRGen/sil_witness_tables_external_witnesstable.swift
index 3437d4f..33d737a 100644
--- a/test/IRGen/sil_witness_tables_external_witnesstable.swift
+++ b/test/IRGen/sil_witness_tables_external_witnesstable.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-module %S/Inputs/sil_witness_tables_external_input.swift -o %t/Swift.swiftmodule -parse-stdlib -parse-as-library -module-name Swift -sil-serialize-all -module-link-name swiftCore
+// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-module %S/Inputs/sil_witness_tables_external_input.swift -o %t/Swift.swiftmodule -parse-stdlib -parse-as-library -module-name Swift -sil-serialize-witness-tables -sil-serialize-vtables -module-link-name swiftCore
 // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -I %t -primary-file %s -emit-ir | %FileCheck %s
 
 import Swift
diff --git a/test/SIL/Serialization/Inputs/def_generic.swift b/test/SIL/Serialization/Inputs/def_generic.swift
index c55dc44..1fd5815 100644
--- a/test/SIL/Serialization/Inputs/def_generic.swift
+++ b/test/SIL/Serialization/Inputs/def_generic.swift
@@ -1,6 +1,12 @@
-class A<T> {
+public class A<T> {
   typealias Element = T
+  @_versioned
+  @_inlineable
   func convertFromArrayLiteral(_ elements: Element...) -> A {
     return A()
   }
+
+  @_versioned
+  @_inlineable
+  init() {}
 }
diff --git a/test/SIL/Serialization/Inputs/def_generic_marker.swift b/test/SIL/Serialization/Inputs/def_generic_marker.swift
index 086523b..fd195dd 100644
--- a/test/SIL/Serialization/Inputs/def_generic_marker.swift
+++ b/test/SIL/Serialization/Inputs/def_generic_marker.swift
@@ -13,6 +13,7 @@
   > (_ seq: S)
 }
 
+@_inlineable
 public func test<
   EC1 : mmCollectionType,
   EC2 : mmCollectionType
diff --git a/test/SIL/Serialization/Inputs/function_param_convention_input.sil b/test/SIL/Serialization/Inputs/function_param_convention_input.sil
index e1943e3..68bf46f 100644
--- a/test/SIL/Serialization/Inputs/function_param_convention_input.sil
+++ b/test/SIL/Serialization/Inputs/function_param_convention_input.sil
@@ -3,7 +3,7 @@
 
 // Make sure that we can deserialize an apply with various parameter calling
 // conventions.
-sil @foo : $@convention(thin) (@in X, @inout X, @in_guaranteed X, @owned X, X, @guaranteed X) -> @out X {
+sil [serialized] @foo : $@convention(thin) (@in X, @inout X, @in_guaranteed X, @owned X, X, @guaranteed X) -> @out X {
 bb0(%0 : $*X, %1 : $*X, %2 : $*X, %3 : $*X, %4 : $X, %5 : $X, %6 : $X):
   %9999 = tuple()
   return %9999 : $()
diff --git a/test/SIL/Serialization/Inputs/nontransparent.swift b/test/SIL/Serialization/Inputs/nontransparent.swift
index b19debc..314e0de 100644
--- a/test/SIL/Serialization/Inputs/nontransparent.swift
+++ b/test/SIL/Serialization/Inputs/nontransparent.swift
@@ -6,21 +6,27 @@
 }
 
 public struct B {
+  @_inlineable
   public func amIConfused() {}
+  @_inlineable
+  public init() {}
 }
 
 public struct A {
   public var b : B
 
+  @_inlineable
   public init() {
     b = B()
   }
 
+  @_inlineable
   public func isBConfused() {
     b.amIConfused()
   }
 }
 
+@_inlineable
 public func doSomething() -> A {
   var a = A()
   return a
diff --git a/test/SIL/Serialization/Inputs/shared_function_serialization_input.swift b/test/SIL/Serialization/Inputs/shared_function_serialization_input.swift
index 0f3d42d..1a00437 100644
--- a/test/SIL/Serialization/Inputs/shared_function_serialization_input.swift
+++ b/test/SIL/Serialization/Inputs/shared_function_serialization_input.swift
@@ -1,11 +1,14 @@
 
 public struct X {
+  @_inlineable
   public init() { }
 }
 
+@_inlineable
 @inline(never)
 public func the_thing<T>(t t : T) { }
 
+@_inlineable
 @inline(never)
 public func the_thing_it_does(x x : X) {
   the_thing(t: x)
diff --git a/test/SIL/Serialization/Inputs/specializer_input.swift b/test/SIL/Serialization/Inputs/specializer_input.swift
index 29a1a60..c55d1a6 100644
--- a/test/SIL/Serialization/Inputs/specializer_input.swift
+++ b/test/SIL/Serialization/Inputs/specializer_input.swift
@@ -2,8 +2,10 @@
 public typealias Int = Builtin.Int32
 
 public struct Container<V> {
+  @_inlineable
   @inline(never)
   public func doSomething() {}
+  @_inlineable
   @inline(never)
   public init() {}
 }
diff --git a/test/SIL/Serialization/Inputs/vtable_deserialization_input.swift b/test/SIL/Serialization/Inputs/vtable_deserialization_input.swift
index c6f7e9f..2370e6b 100644
--- a/test/SIL/Serialization/Inputs/vtable_deserialization_input.swift
+++ b/test/SIL/Serialization/Inputs/vtable_deserialization_input.swift
@@ -7,12 +7,15 @@
 func unknown() -> ()
 
 public class Y : P {
+  @_inlineable
   public func doAnotherThing() {
     unknown()
   }
 
+  @_inlineable
   public func doSomething() {
     doAnotherThing()
   }
+  @_inlineable
   public init() {}
 }
diff --git a/test/SIL/Serialization/basic.sil b/test/SIL/Serialization/basic.sil
index 9ac3d90..53d4603 100644
--- a/test/SIL/Serialization/basic.sil
+++ b/test/SIL/Serialization/basic.sil
@@ -7,17 +7,17 @@
 
 import Builtin
 
-// CHECK-LABEL: sil @test_unchecked_ownership_conversion : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
+// CHECK-LABEL: sil [serialized] @test_unchecked_ownership_conversion : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
 // CHECK: unchecked_ownership_conversion {{%.*}} : $Builtin.NativeObject, @guaranteed to @owned
-sil @test_unchecked_ownership_conversion : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
+sil [serialized] @test_unchecked_ownership_conversion : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
 bb0(%0 : $Builtin.NativeObject):
   unchecked_ownership_conversion %0 : $Builtin.NativeObject, @guaranteed to @owned
   return undef : $()
 }
 
-// CHECK-LABEL: sil @test_end_lifetime : $@convention(thin) (@owned Builtin.NativeObject) -> () {
+// CHECK-LABEL: sil [serialized] @test_end_lifetime : $@convention(thin) (@owned Builtin.NativeObject) -> () {
 // CHECK: end_lifetime {{%.*}} : $Builtin.NativeObject
-sil @test_end_lifetime : $@convention(thin) (@owned Builtin.NativeObject) -> () {
+sil [serialized] @test_end_lifetime : $@convention(thin) (@owned Builtin.NativeObject) -> () {
 bb0(%0 : $Builtin.NativeObject):
   end_lifetime %0 : $Builtin.NativeObject
   return undef : $()
diff --git a/test/SIL/Serialization/borrow.sil b/test/SIL/Serialization/borrow.sil
index 8c45976..150bd63 100644
--- a/test/SIL/Serialization/borrow.sil
+++ b/test/SIL/Serialization/borrow.sil
@@ -10,7 +10,7 @@
 import Builtin
 
 // We do not verify here, but just make sure that all of the combinations parse and print correctly.
-// CHECK-LABEL: sil @borrow_test : $@convention(thin) (@in Builtin.NativeObject, Builtin.NativeObject) -> () {
+// CHECK-LABEL: sil [serialized] @borrow_test : $@convention(thin) (@in Builtin.NativeObject, Builtin.NativeObject) -> () {
 // CHECK: bb0([[ARG1:%[0-9]+]] : $*Builtin.NativeObject, [[ARG2:%[0-9]+]] : $Builtin.NativeObject):
 // CHECK: begin_borrow [[ARG2]]
 // CHECK: [[MEM:%.*]] = alloc_stack $Builtin.NativeObject
@@ -19,7 +19,7 @@
 // CHECK: end_borrow [[ARG2]] from [[ARG1]] : $Builtin.NativeObject, $*Builtin.NativeObject
 // CHECK: end_borrow [[ARG1]] from [[ARG1]] : $*Builtin.NativeObject, $*Builtin.NativeObject
 // CHECK: end_borrow [[ARG2]] from [[ARG2]] : $Builtin.NativeObject, $Builtin.NativeObject
-sil @borrow_test : $@convention(thin) (@in Builtin.NativeObject, Builtin.NativeObject) -> () {
+sil [serialized] @borrow_test : $@convention(thin) (@in Builtin.NativeObject, Builtin.NativeObject) -> () {
 bb0(%0 : $*Builtin.NativeObject, %1 : $Builtin.NativeObject):
   %2 = begin_borrow %1 : $Builtin.NativeObject
   end_borrow %2 from %1 : $Builtin.NativeObject, $Builtin.NativeObject
diff --git a/test/SIL/Serialization/borrow_argument.sil b/test/SIL/Serialization/borrow_argument.sil
index b134fa2..f880601 100644
--- a/test/SIL/Serialization/borrow_argument.sil
+++ b/test/SIL/Serialization/borrow_argument.sil
@@ -9,10 +9,10 @@
 
 import Builtin
 
-// CHECK-LABEL: sil @borrow_argument_test : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
+// CHECK-LABEL: sil [serialized] @borrow_argument_test : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
 // CHECK: bb1([[PHIBBARG:%.*]] : @guaranteed $Builtin.NativeObject):
 // CHECK: end_borrow_argument [[PHIBBARG]] : $Builtin.NativeObject
-sil @borrow_argument_test : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
+sil [serialized] @borrow_argument_test : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
 bb0(%0 : @guaranteed $Builtin.NativeObject):
   br bb1(%0 : $Builtin.NativeObject)
 
diff --git a/test/SIL/Serialization/boxes.sil b/test/SIL/Serialization/boxes.sil
index 3a03fb7..db95f6a 100644
--- a/test/SIL/Serialization/boxes.sil
+++ b/test/SIL/Serialization/boxes.sil
@@ -16,8 +16,8 @@
 
 // TODO: Transform boxes by transforming their arguments, not as single-field,
 // so that they work as parameters in generic SIL functions.
-// CHECK-LABEL: sil hidden @box_type_parsing : $@convention(thin) (
-sil hidden @box_type_parsing : $@convention(thin) (
+// CHECK-LABEL: sil hidden [serialized] @box_type_parsing : $@convention(thin) (
+sil hidden [serialized] @box_type_parsing : $@convention(thin) (
   // CHECK: <τ_0_0> { var τ_0_0 } <F>,
   <B>{ var B }<F>,
   // CHECK: <τ_0_0 where τ_0_0 : P> { let τ_0_0 } <G>,
@@ -38,8 +38,8 @@
   unreachable
 }
 
-// CHECK-LABEL: sil hidden @box_type_parsing_in_generic_function : $@convention(thin) <F, G where G : P> (
-sil hidden @box_type_parsing_in_generic_function : $@convention(thin) <F, G: P> (
+// CHECK-LABEL: sil hidden [serialized] @box_type_parsing_in_generic_function : $@convention(thin) <F, G where G : P> (
+sil hidden [serialized] @box_type_parsing_in_generic_function : $@convention(thin) <F, G: P> (
   // CHECK: <τ_0_0> { var τ_0_0 } <F>,
   <B>{ var B }<F>,
   // CHECK: <τ_0_0 where τ_0_0 : P> { let τ_0_0 } <G>,
@@ -60,8 +60,8 @@
   unreachable
 }
 
-// CHECK-LABEL: sil hidden @same_generic_param_name_in_multiple_box_signatures : $@convention(thin) (
-sil hidden @same_generic_param_name_in_multiple_box_signatures : $@convention(thin) (
+// CHECK-LABEL: sil hidden [serialized] @same_generic_param_name_in_multiple_box_signatures : $@convention(thin) (
+sil hidden [serialized] @same_generic_param_name_in_multiple_box_signatures : $@convention(thin) (
   // CHECK: <τ_0_0> { var τ_0_0 } <Int>,
   <A> { var A } <Int>,
   // CHECK: <τ_0_0> { var τ_0_0 } <String>
@@ -72,8 +72,8 @@
   unreachable
 }
 
-// CHECK-LABEL: sil hidden @same_generic_param_name_in_outer_scope : $@convention(thin) <A> (
-sil hidden @same_generic_param_name_in_outer_scope : $@convention(thin) <A> (
+// CHECK-LABEL: sil hidden [serialized] @same_generic_param_name_in_outer_scope : $@convention(thin) <A> (
+sil hidden [serialized] @same_generic_param_name_in_outer_scope : $@convention(thin) <A> (
   // CHECK: <τ_0_0> { var τ_0_0 } <A>
   <A> { var A } <A>
 // CHECK: ) -> ()
@@ -82,20 +82,20 @@
   unreachable
 }
 
-// CHECK-LABEL: sil hidden @box_ownership : $@convention(thin) (@owned { var Int }, @guaranteed <τ_0_0> { let τ_0_0 } <Int>) -> ()
-sil hidden @box_ownership : $@convention(thin) (@owned { var Int }, @guaranteed <T> { let T } <Int>) -> () {
+// CHECK-LABEL: sil hidden [serialized] @box_ownership : $@convention(thin) (@owned { var Int }, @guaranteed <τ_0_0> { let τ_0_0 } <Int>) -> ()
+sil hidden [serialized ]@box_ownership : $@convention(thin) (@owned { var Int }, @guaranteed <T> { let T } <Int>) -> () {
 entry(%0 : ${ var Int }, %1 : $<T> { let T } <Int>):
   unreachable
 }
 
-// CHECK-LABEL: sil hidden @address_of_box
-sil hidden @address_of_box : $@convention(thin) (@in { var Int }, @in <T> { let T } <Int>) -> () {
+// CHECK-LABEL: sil hidden [serialized] @address_of_box
+sil hidden [serialized] @address_of_box : $@convention(thin) (@in { var Int }, @in <T> { let T } <Int>) -> () {
 // CHECK: %0 : $*{ var Int }, %1 : $*<τ_0_0> { let τ_0_0 } <Int>
 entry(%0 : $*{ var Int }, %1 : $*<T> { let T } <Int>):
   unreachable
 }
 
-sil @serialize_all : $@convention(thin) () -> () {
+sil [serialized] @serialize_all : $@convention(thin) () -> () {
 entry:
   %0 = function_ref @box_type_parsing : $@convention(thin) (<B>{ var B }<F>, <C: P>{ let C }<G>, <D: P>{ var D }<Q>, { let Int }, { var Int, let String }, {}, <X, Y, Z>{ var X, let Z }<Int, String, Optional<Double>>) -> ()
   %1 = function_ref @box_type_parsing_in_generic_function : $@convention(thin) <F, G: P> (<B>{ var B }<F>, <C: P>{ let C }<G>, <D: P>{ var D }<Q>, { let Int }, { var Int, let String }, {}, <X, Y, Z>{ var X, let Z }<Int, String, Optional<Double>>) -> ()
diff --git a/test/SIL/Serialization/copy_value_destroy_value.sil b/test/SIL/Serialization/copy_value_destroy_value.sil
index 0891225..0833b3b 100644
--- a/test/SIL/Serialization/copy_value_destroy_value.sil
+++ b/test/SIL/Serialization/copy_value_destroy_value.sil
@@ -10,24 +10,24 @@
 import Builtin
 
 
-// CHECK-LABEL: sil @test_copy_unowned_value : $@convention(thin) (@owned @sil_unowned Builtin.NativeObject) -> @owned Builtin.NativeObject {
+// CHECK-LABEL: sil [serialized] @test_copy_unowned_value : $@convention(thin) (@owned @sil_unowned Builtin.NativeObject) -> @owned Builtin.NativeObject {
 // CHECK: bb0([[T0:%[0-9]+]] : $@sil_unowned Builtin.NativeObject):
 // CHECK-NEXT: [[COPY_RESULT:%.*]] = copy_unowned_value [[T0]] : $@sil_unowned Builtin.NativeObject
 // CHECK-NEXT: destroy_value [[T0]] : $@sil_unowned Builtin.NativeObject
 // CHECK-NEXT: return [[COPY_RESULT]] : $Builtin.NativeObject
-sil @test_copy_unowned_value : $@convention(thin) (@owned @sil_unowned Builtin.NativeObject) -> @owned Builtin.NativeObject {
+sil [serialized] @test_copy_unowned_value : $@convention(thin) (@owned @sil_unowned Builtin.NativeObject) -> @owned Builtin.NativeObject {
 bb0(%0 : $@sil_unowned Builtin.NativeObject):
   %1 = copy_unowned_value %0 : $@sil_unowned Builtin.NativeObject
   destroy_value %0 : $@sil_unowned Builtin.NativeObject
   return %1 : $Builtin.NativeObject
 }
 
-// CHECK-LABEL: sil @test : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
+// CHECK-LABEL: sil [serialized] @test : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
 // CHECK: bb0([[ARG1:%[0-9]+]] : $Builtin.NativeObject):
 // CHECK: [[COPY_VALUE_RESULT:%[0-9]+]] = copy_value [[ARG1]] : $Builtin.NativeObject
 // CHECK: destroy_value [[ARG1]]
 // CHECK: return [[COPY_VALUE_RESULT]]
-sil @test : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
+sil [serialized] @test : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
 bb0(%0 : $Builtin.NativeObject):
   %1 = copy_value %0 : $Builtin.NativeObject
   destroy_value %0 : $Builtin.NativeObject
diff --git a/test/SIL/Serialization/deserialize_generic.sil b/test/SIL/Serialization/deserialize_generic.sil
index 9aacd80..45b841b 100644
--- a/test/SIL/Serialization/deserialize_generic.sil
+++ b/test/SIL/Serialization/deserialize_generic.sil
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module -sil-serialize-all -o %t %S/Inputs/def_generic.swift
+// RUN: %target-swift-frontend -emit-module -sil-serialize-witness-tables -sil-serialize-vtables -o %t %S/Inputs/def_generic.swift
 // RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -linker -I %t %s | %FileCheck %s
 
 // Make sure that SILFunctionType with GenericSignature can match up with
diff --git a/test/SIL/Serialization/deserialize_generic_marker.sil b/test/SIL/Serialization/deserialize_generic_marker.sil
index 0ae91fa..dfbcf0c 100644
--- a/test/SIL/Serialization/deserialize_generic_marker.sil
+++ b/test/SIL/Serialization/deserialize_generic_marker.sil
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module -sil-serialize-all -o %t %S/Inputs/def_generic_marker.swift
+// RUN: %target-swift-frontend -emit-module -sil-serialize-witness-tables -sil-serialize-vtables -o %t %S/Inputs/def_generic_marker.swift
 // RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -linker -I %t %s | %FileCheck %s
 
 // Make sure that SILFunctionType with GenericSignature can match up with
diff --git a/test/SIL/Serialization/function_param_convention.sil b/test/SIL/Serialization/function_param_convention.sil
index 90da2d9..9d6c7f7 100644
--- a/test/SIL/Serialization/function_param_convention.sil
+++ b/test/SIL/Serialization/function_param_convention.sil
@@ -1,12 +1,12 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -parse-sil -sil-inline-threshold 0 %S/Inputs/function_param_convention_input.sil -o %t/FunctionInput.swiftmodule -emit-module -parse-as-library -parse-stdlib -module-name FunctionInput -sil-serialize-all -O
+// RUN: %target-swift-frontend -parse-sil -sil-inline-threshold 0 %S/Inputs/function_param_convention_input.sil -o %t/FunctionInput.swiftmodule -emit-module -parse-as-library -parse-stdlib -module-name FunctionInput -sil-serialize-witness-tables -sil-serialize-vtables -O
 // RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -I %t -linker %s -o - | %FileCheck %s
 
 import Swift
 import FunctionInput
 
 // Make sure we can deserialize a SIL function with these various attributes.
-// CHECK: sil public_external @foo : $@convention(thin) (@in X, @inout X, @in_guaranteed X, @owned X, X, @guaranteed X) -> @out X {
+// CHECK: sil public_external [serialized] @foo : $@convention(thin) (@in X, @inout X, @in_guaranteed X, @owned X, X, @guaranteed X) -> @out X {
 
 sil @foo : $@convention(thin) (@in X, @inout X, @in_guaranteed X, @owned X, X, @guaranteed X) -> @out X
 
diff --git a/test/SIL/Serialization/init_existential_inst_deserializes_witness_tables.swift b/test/SIL/Serialization/init_existential_inst_deserializes_witness_tables.swift
index 60dd798..0a98465 100644
--- a/test/SIL/Serialization/init_existential_inst_deserializes_witness_tables.swift
+++ b/test/SIL/Serialization/init_existential_inst_deserializes_witness_tables.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -sil-inline-threshold 0 %S/Inputs/init_existential_inst_deserializes_witness_tables_input.swift -o %t/Swift.swiftmodule -emit-module -parse-as-library -parse-stdlib -module-link-name swiftCore -module-name Swift -sil-serialize-all -O
+// RUN: %target-swift-frontend -sil-inline-threshold 0 %S/Inputs/init_existential_inst_deserializes_witness_tables_input.swift -o %t/Swift.swiftmodule -emit-module -parse-as-library -parse-stdlib -module-link-name swiftCore -module-name Swift -sil-serialize-witness-tables -O
 // RUN: %target-swift-frontend -I %t -O %s -emit-sil -o - | %FileCheck %s
 
 // CHECK: sil_witness_table public_external [serialized] X: P module Swift {
diff --git a/test/SIL/Serialization/keypath.sil b/test/SIL/Serialization/keypath.sil
index 53989c9..b38d742 100644
--- a/test/SIL/Serialization/keypath.sil
+++ b/test/SIL/Serialization/keypath.sil
@@ -41,8 +41,8 @@
   var z: C
 }
 
-// CHECK-LABEL: sil shared @stored_properties
-sil shared @stored_properties : $@convention(thin) () -> () {
+// CHECK-LABEL: sil shared [serialized] @stored_properties
+sil shared [serialized] @stored_properties : $@convention(thin) () -> () {
 entry:
   // CHECK: keypath $WritableKeyPath<S, Int>, (root $S; stored_property #S.x : $Int)
   %a = keypath $WritableKeyPath<S, Int>, (root $S; stored_property #S.x : $Int)
@@ -56,8 +56,8 @@
   return undef : $()
 }
 
-// CHECK-LABEL: sil shared @stored_properties_generic
-sil shared @stored_properties_generic : $@convention(thin) <D: P, E: Q, F: R> () -> () {
+// CHECK-LABEL: sil shared [serialized] @stored_properties_generic
+sil shared [serialized] @stored_properties_generic : $@convention(thin) <D: P, E: Q, F: R> () -> () {
 entry:
   // CHECK: keypath $WritableKeyPath<Gen<D, E, F>, D>, <τ_0_0, τ_0_1, τ_0_2 where {{.*}}> (root $Gen<τ_0_0, τ_0_1, τ_0_2>; stored_property #Gen.x : $τ_0_0) <D, E, F>
   %a = keypath $WritableKeyPath<Gen<D,E,F>, D>, <G: P, H: Q, I: R> (root $Gen<G, H, I>; stored_property #Gen.x : $G) <D, E, F>
@@ -83,8 +83,8 @@
 sil @gen_subs_eq : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (UnsafeRawPointer, UnsafeRawPointer) -> Bool
 sil @gen_subs_hash : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (UnsafeRawPointer) -> Int
 
-// CHECK-LABEL: sil shared @computed_properties
-sil shared @computed_properties : $@convention(thin) () -> () {
+// CHECK-LABEL: sil shared [serialized] @computed_properties
+sil shared [serialized] @computed_properties : $@convention(thin) () -> () {
 entry:
   // CHECK: keypath $KeyPath<S, Int>, (root $S; gettable_property $Int, id @id_a : $@convention(thin) () -> (), getter @get_s_int : $@convention(thin) (@in S) -> @out Int)
   %a = keypath $KeyPath<S, Int>, (root $S; gettable_property $Int, id @id_a : $@convention(thin) () -> (), getter @get_s_int : $@convention(thin) (@in S) -> @out Int)
@@ -101,8 +101,8 @@
 sil @get_gen_a : $@convention(thin) <X1: P, Y1: Q, Z1: R> (@in Gen<X1, Y1, Z1>) -> @out X1
 sil @set_gen_a : $@convention(thin) <X2: P, Y2: Q, Z2: R> (@in X2, @in Gen<X2, Y2, Z2>) -> ()
 
-// CHECK-LABEL: sil shared @computed_properties_generic
-sil shared @computed_properties_generic : $@convention(thin) <D: P, E: Q, F: R> () -> () {
+// CHECK-LABEL: sil shared [serialized] @computed_properties_generic
+sil shared [serialized] @computed_properties_generic : $@convention(thin) <D: P, E: Q, F: R> () -> () {
 entry:
   // CHECK: keypath $KeyPath<Gen<D, E, F>, D>, <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : P, τ_0_1 : Q, τ_0_2 : R> (root $Gen<τ_0_0, τ_0_1, τ_0_2>; settable_property $τ_0_0, id @id_a : $@convention(thin) () -> (), getter @get_gen_a : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : P, τ_0_1 : Q, τ_0_2 : R> (@in Gen<τ_0_0, τ_0_1, τ_0_2>) -> @out τ_0_0, setter @set_gen_a : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : P, τ_0_1 : Q, τ_0_2 : R> (@in τ_0_0, @in Gen<τ_0_0, τ_0_1, τ_0_2>) -> ()) <D, E, F>
   %a = keypath $KeyPath<Gen<D, E, F>, D>, <G: P, H: Q, I: R> (root $Gen<G, H, I>; settable_property $G, id @id_a : $@convention(thin) () -> (), getter @get_gen_a : $@convention(thin) <X3: P, Y3: Q, Z3: R> (@in Gen<X3, Y3, Z3>) -> @out X3, setter @set_gen_a : $@convention(thin) <X4: P, Y4: Q, Z4: R> (@in X4, @in Gen<X4, Y4, Z4>) -> ()) <D, E, F>
@@ -110,8 +110,8 @@
   return undef : $()
 }
 
-// CHECK-LABEL: sil shared @optional
-sil shared @optional : $@convention(thin) () -> () {
+// CHECK-LABEL: sil shared [serialized] @optional
+sil shared [serialized] @optional : $@convention(thin) () -> () {
 entry:
   // CHECK: keypath $KeyPath<Optional<Int>, Optional<Int>>, (root $Optional<Int>; optional_chain : $Int; optional_wrap : $Optional<Int>)
   %a = keypath $KeyPath<Optional<Int>, Optional<Int>>, (root $Optional<Int>; optional_chain : $Int; optional_wrap : $Optional<Int>)
@@ -121,8 +121,8 @@
   return undef : $()
 }
 
-// CHECK-LABEL: sil shared @indexes
-sil shared @indexes : $@convention(thin) (S, C) -> () {
+// CHECK-LABEL: sil shared [serialized] @indexes
+sil shared [serialized] @indexes : $@convention(thin) (S, C) -> () {
 // CHECK: bb0([[S:%.*]] : $S, [[C:%.*]] : $C):
 entry(%s : $S, %c : $C):
   // CHECK: keypath $KeyPath<S, Int>, (root $S; settable_property $Int, id @id_a : $@convention(thin) () -> (), getter @get_s_int_subs : $@convention(thin) (@in S, UnsafeRawPointer) -> @out Int, setter @set_s_int_subs : $@convention(thin) (@in Int, @in S, UnsafeRawPointer) -> (), indices [%$0 : $S : $S, %$1 : $C : $C], indices_equals @subs_eq : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @subs_hash : $@convention(thin) (UnsafeRawPointer) -> Int) ([[S]], [[C]])
@@ -140,7 +140,7 @@
   return undef : $()
 }
 
-sil @serialize_all : $@convention(thin) () -> () {
+sil [serialized] @serialize_all : $@convention(thin) () -> () {
 entry:
   %0 = function_ref @stored_properties : $@convention(thin) () -> ()
   %1 = function_ref @stored_properties_generic : $@convention(thin) <D: P, E: Q, F: R> () -> ()
diff --git a/test/SIL/Serialization/literals.sil b/test/SIL/Serialization/literals.sil
index 40ba997..9191fee 100644
--- a/test/SIL/Serialization/literals.sil
+++ b/test/SIL/Serialization/literals.sil
@@ -7,7 +7,7 @@
 
 sil_stage canonical
 
-sil @test : $@convention(thin) () -> () {
+sil [serialized] @test : $@convention(thin) () -> () {
 bb0:
 // CHECK: string_literal utf8 "\u{0B}"
   %1 = string_literal utf8 "\u{0B}"
diff --git a/test/SIL/Serialization/opaque_values_serialize.sil b/test/SIL/Serialization/opaque_values_serialize.sil
index bb7ea3a..ecb09fa 100644
--- a/test/SIL/Serialization/opaque_values_serialize.sil
+++ b/test/SIL/Serialization/opaque_values_serialize.sil
@@ -20,22 +20,22 @@
   init()
 }
 
-// CHECK-LABEL: sil @castOpaque : $@convention(thin) (Int) -> () {
+// CHECK-LABEL: sil [serialized] @castOpaque : $@convention(thin) (Int) -> () {
 // CHECK: bb0([[ARG:%.*]] : $Int):
 // CHECK:  unconditional_checked_cast_value [[ARG]] : $Int to $Foo
 // CHECK-LABEL: } // end sil function 'castOpaque'
-sil @castOpaque : $@convention(thin) (Int) -> () {
+sil [serialized] @castOpaque : $@convention(thin) (Int) -> () {
 bb0(%0 : $Int):
   %c = unconditional_checked_cast_value %0 : $Int to $Foo
   %t = tuple ()
   return %t : $()
 }
 
-// CHECK-LABEL: sil @condCastOpaque : $@convention(thin) (Int) -> () {
+// CHECK-LABEL: sil [serialized] @condCastOpaque : $@convention(thin) (Int) -> () {
 // CHECK: bb0([[ARG:%.*]] : $Int):
 // CHECK:  checked_cast_value_br [[ARG]] : $Int to $Int
 // CHECK-LABEL: } // end sil function 'condCastOpaque'
-sil @condCastOpaque : $@convention(thin) (Int) -> () {
+sil [serialized] @condCastOpaque : $@convention(thin) (Int) -> () {
 bb0(%0 : $Int):
   checked_cast_value_br %0 : $Int to $Int, bb2, bb1
 
@@ -50,12 +50,12 @@
   return %t : $()
 }
 
-// CHECK-LABEL: sil @initDeinitExistentialValue : $@convention(thin) <T> (@in T) -> () {
+// CHECK-LABEL: sil [serialized] @initDeinitExistentialValue : $@convention(thin) <T> (@in T) -> () {
 // CHECK: bb0([[ARG:%.*]] : $T):
 // CHECK:  [[IE:%.*]] = init_existential_value [[ARG]] : $T, $T, $Any
 // CHECK:  deinit_existential_value [[IE]] : $Any
 // CHECK-LABEL: } // end sil function 'initDeinitExistentialValue'
-sil @initDeinitExistentialValue : $@convention(thin) <T> (@in T) -> () {
+sil [serialized] @initDeinitExistentialValue : $@convention(thin) <T> (@in T) -> () {
 bb0(%0 : $T):
   %i = init_existential_value %0 : $T, $T, $Any
   deinit_existential_value %i : $Any
@@ -63,22 +63,22 @@
   return %t : $()
 }
 
-// CHECK-LABEL: sil @openExistentialBoxValue : $@convention(thin) (@in Error) -> () {
+// CHECK-LABEL: sil [serialized] @openExistentialBoxValue : $@convention(thin) (@in Error) -> () {
 // CHECK: bb0([[ARG:%.*]] : $Error):
 // CHECK:  open_existential_box_value [[ARG]] : $Error to $@opened({{.*}}) Error
 // CHECK-LABEL: } // end sil function 'openExistentialBoxValue'
-sil @openExistentialBoxValue : $@convention(thin) (@in Error) -> () {
+sil [serialized] @openExistentialBoxValue : $@convention(thin) (@in Error) -> () {
 bb0(%0 : $Error):
   %o = open_existential_box_value %0 : $Error to $@opened("2E9EACA6-FD59-11E6-B016-685B3593C495") Error
   %t = tuple ()
   return %t : $()
 }
 
-// CHECK-LABEL: sil @openExistentialValue : $@convention(thin) (@in Foo) -> () {
+// CHECK-LABEL: sil [serialized] @openExistentialValue : $@convention(thin) (@in Foo) -> () {
 // CHECK: bb0([[ARG:%.*]] : $Foo):
 // CHECK:  open_existential_value [[ARG]] : $Foo to $@opened({{.*}}) Foo
 // CHECK-LABEL: } // end sil function 'openExistentialValue'
-sil @openExistentialValue : $@convention(thin) (@in Foo) -> () {
+sil [serialized] @openExistentialValue : $@convention(thin) (@in Foo) -> () {
 bb0(%0 : $Foo):
   %o = open_existential_value %0 : $Foo to $@opened("2E9EACA6-FD59-11E6-B016-685B3593C496") Foo
   %t = tuple ()
@@ -88,8 +88,8 @@
 // Test @in/@out serialization.
 // ----
 
-// CHECK-LABEL: sil hidden @serialize_identity : $@convention(thin) <T> (@in T) -> @out T {
-sil hidden @serialize_identity : $@convention(thin) <T> (@in T) -> @out T {
+// CHECK-LABEL: sil hidden [serialized] @serialize_identity : $@convention(thin) <T> (@in T) -> @out T {
+sil hidden [serialized] @serialize_identity : $@convention(thin) <T> (@in T) -> @out T {
 // CHECK: bb0(%0 : $T):
 bb0(%0 : $T):
   // CHECK: return %0 : $T
@@ -102,8 +102,8 @@
 
 sil @doWithS : $@convention(method) (S) -> ()
 
-// CHECK-LABEL: sil hidden [transparent] [thunk] @serialize_mutating : $@convention(witness_method) (@in_guaranteed S) -> () {
-sil hidden [transparent] [thunk] @serialize_mutating : $@convention(witness_method) (@in_guaranteed S) -> () {
+// CHECK-LABEL: sil hidden [transparent] [serialized] [thunk] @serialize_mutating : $@convention(witness_method) (@in_guaranteed S) -> () {
+sil hidden [transparent] [serialized] [thunk] @serialize_mutating : $@convention(witness_method) (@in_guaranteed S) -> () {
 // CHECK: bb0(%0 : $S):
 bb0(%0 : $S):
   %f = function_ref @doWithS : $@convention(method) (S) -> ()
diff --git a/test/SIL/Serialization/ownership_qualified_memopts.sil b/test/SIL/Serialization/ownership_qualified_memopts.sil
index 5e7f446..67a5f4f 100644
--- a/test/SIL/Serialization/ownership_qualified_memopts.sil
+++ b/test/SIL/Serialization/ownership_qualified_memopts.sil
@@ -10,11 +10,11 @@
 import Builtin
 
 
-// CHECK-LABEL: sil @trivial : $@convention(thin) (@in Builtin.Int32, Builtin.Int32) -> () {
+// CHECK-LABEL: sil [serialized] @trivial : $@convention(thin) (@in Builtin.Int32, Builtin.Int32) -> () {
 // CHECK: bb0([[ARG1:%[0-9]+]] : $*Builtin.Int32, [[ARG2:%[0-9]+]] : $Builtin.Int32):
 // CHECK: load [trivial] [[ARG1]] : $*Builtin.Int32
 // CHECK: store [[ARG2]] to [trivial] [[ARG1]] : $*Builtin.Int32
-sil @trivial : $@convention(thin) (@in Builtin.Int32, Builtin.Int32) -> () {
+sil [serialized] @trivial : $@convention(thin) (@in Builtin.Int32, Builtin.Int32) -> () {
 bb0(%0 : $*Builtin.Int32, %1 : $Builtin.Int32):
   load [trivial] %0 : $*Builtin.Int32
   store %1 to [trivial] %0 : $*Builtin.Int32
@@ -22,13 +22,13 @@
   return %2 : $()
 }
 
-// CHECK-LABEL: sil @non_trivial : $@convention(thin) (@in Builtin.NativeObject, Builtin.NativeObject) -> () {
+// CHECK-LABEL: sil [serialized] @non_trivial : $@convention(thin) (@in Builtin.NativeObject, Builtin.NativeObject) -> () {
 // CHECK: bb0([[ARG1:%[0-9]+]] : $*Builtin.NativeObject, [[ARG2:%[0-9]+]] : $Builtin.NativeObject):
 // CHECK: load [take] [[ARG1]] : $*Builtin.NativeObject
 // CHECK: load [copy] [[ARG1]] : $*Builtin.NativeObject
 // CHECK: store [[ARG2]] to [init] [[ARG1]] : $*Builtin.NativeObject
 // CHECK: store [[ARG2]] to [assign] [[ARG1]] : $*Builtin.NativeObject
-sil @non_trivial : $@convention(thin) (@in Builtin.NativeObject, Builtin.NativeObject) -> () {
+sil [serialized] @non_trivial : $@convention(thin) (@in Builtin.NativeObject, Builtin.NativeObject) -> () {
 bb0(%0 : $*Builtin.NativeObject, %1 : $Builtin.NativeObject):
   load [take] %0 : $*Builtin.NativeObject
   load [copy] %0 : $*Builtin.NativeObject
diff --git a/test/SIL/Serialization/perf_inline_without_inline_all.swift b/test/SIL/Serialization/perf_inline_without_inline_all.swift
index d11e748..b2d516d 100644
--- a/test/SIL/Serialization/perf_inline_without_inline_all.swift
+++ b/test/SIL/Serialization/perf_inline_without_inline_all.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module %S/Inputs/nontransparent.swift -O -sil-serialize-all -parse-stdlib -parse-as-library -emit-module -o %t/Swift.swiftmodule -module-name=Swift -module-link-name swiftCore
+// RUN: %target-swift-frontend -emit-module %S/Inputs/nontransparent.swift -O -sil-serialize-witness-tables -sil-serialize-vtables -parse-stdlib -parse-as-library -emit-module -o %t/Swift.swiftmodule -module-name=Swift -module-link-name swiftCore
 // RUN: %target-swift-frontend %s -O -I %t -emit-sil -o - | %FileCheck %s
 
 import Swift
diff --git a/test/SIL/Serialization/projection_lowered_type_parse.sil b/test/SIL/Serialization/projection_lowered_type_parse.sil
index 5676871..c6d3cd5 100644
--- a/test/SIL/Serialization/projection_lowered_type_parse.sil
+++ b/test/SIL/Serialization/projection_lowered_type_parse.sil
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-module %s -module-name Swift -sil-serialize-all -module-link-name swiftCore -parse-as-library -parse-sil -parse-stdlib -o - | %target-sil-opt -assume-parsing-unqualified-ownership-sil -module-name=Swift
+// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-module %s -module-name Swift -sil-serialize-witness-tables -sil-serialize-vtables -module-link-name swiftCore -parse-as-library -parse-sil -parse-stdlib -o - | %target-sil-opt -assume-parsing-unqualified-ownership-sil -module-name=Swift
 
 struct A {
   var f : () -> ()
diff --git a/test/SIL/Serialization/public_external.sil b/test/SIL/Serialization/public_external.sil
index d20b528..8143158 100644
--- a/test/SIL/Serialization/public_external.sil
+++ b/test/SIL/Serialization/public_external.sil
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend %s -Xllvm -sil-disable-pass="External Definition To Declaration" -parse-sil -emit-module -module-name Swift -module-link-name swiftCore -parse-stdlib -parse-as-library -sil-serialize-all -o - | %target-sil-opt -assume-parsing-unqualified-ownership-sil -module-name Swift -emit-sorted-sil | %FileCheck %s
+// RUN: %target-swift-frontend %s -Xllvm -sil-disable-pass="External Definition To Declaration" -parse-sil -emit-module -module-name Swift -module-link-name swiftCore -parse-stdlib -parse-as-library -sil-serialize-witness-tables -sil-serialize-vtables -o - | %target-sil-opt -assume-parsing-unqualified-ownership-sil -module-name Swift -emit-sorted-sil | %FileCheck %s
 
 sil_stage raw
 import Builtin
@@ -110,7 +110,7 @@
 
 // The body of this fragile function has to be emitted.
 // CHECK-LABEL: sil{{.*}}@use_external_functions : $@convention(thin) () -> () {
-sil @use_external_functions: $@convention(thin) () -> () {
+sil [serialized] @use_external_functions: $@convention(thin) () -> () {
   %0 = function_ref @public_external_fn : $@convention(thin) () -> ()
   %1 = apply %0 () : $@convention(thin) () -> ()
 
diff --git a/test/SIL/Serialization/semanticsattr.sil b/test/SIL/Serialization/semanticsattr.sil
index a4edaf2..b5b2ea2 100644
--- a/test/SIL/Serialization/semanticsattr.sil
+++ b/test/SIL/Serialization/semanticsattr.sil
@@ -10,16 +10,16 @@
 @_semantics("123") @_semantics("456")
 func semanticsFunction() -> Builtin.Int64
 
-// CHECK: sil [_semantics "789"] [_semantics "ABC"] @foo1 : $@convention(thin) () -> () {
-sil public [_semantics "789"] [_semantics "ABC"] @foo1 : $@convention(thin) () -> () {
+// CHECK: sil [serialized] [_semantics "789"] [_semantics "ABC"] @foo1 : $@convention(thin) () -> () {
+sil public [serialized] [_semantics "789"] [_semantics "ABC"] @foo1 : $@convention(thin) () -> () {
 bb0:
   return undef : $()
 }
 
 // Make sure that we can parse with multiple generics that are after the semantic attributes.
 //
-// CHECK: sil [_semantics "DEF"] [_semantics "GHI"] @foo2 : $@convention(thin) <T1, T2> () -> () {
-sil public [_semantics "DEF"] [_semantics "GHI"] @foo2 : $@convention(thin) <T1, T2> () -> () {
+// CHECK: sil [serialized] [_semantics "DEF"] [_semantics "GHI"] @foo2 : $@convention(thin) <T1, T2> () -> () {
+sil public [serialized] [_semantics "DEF"] [_semantics "GHI"] @foo2 : $@convention(thin) <T1, T2> () -> () {
 bb0:
   return undef : $()
 }
diff --git a/test/SIL/Serialization/shared_function_serialization.sil b/test/SIL/Serialization/shared_function_serialization.sil
index 5de0b23..5c873d8 100644
--- a/test/SIL/Serialization/shared_function_serialization.sil
+++ b/test/SIL/Serialization/shared_function_serialization.sil
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend %S/Inputs/shared_function_serialization_input.swift -o %t/Swift.swiftmodule -emit-module -parse-as-library -parse-stdlib -module-link-name swiftCore -module-name Swift -sil-serialize-all -O
+// RUN: %target-swift-frontend %S/Inputs/shared_function_serialization_input.swift -o %t/Swift.swiftmodule -emit-module -parse-as-library -parse-stdlib -module-link-name swiftCore -module-name Swift -sil-serialize-witness-tables -sil-serialize-vtables -O
 // RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all -I %t -linker -inline %s -o - | %FileCheck %s
 
 // CHECK: sil private @top_level_code
diff --git a/test/SIL/Serialization/specializer_can_deserialize.swift b/test/SIL/Serialization/specializer_can_deserialize.swift
index 708bd61..44c79b4 100644
--- a/test/SIL/Serialization/specializer_can_deserialize.swift
+++ b/test/SIL/Serialization/specializer_can_deserialize.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module %S/Inputs/specializer_input.swift -O -sil-serialize-all -parse-stdlib -parse-as-library -emit-module -o %t/Swift.swiftmodule -module-name=Swift -module-link-name swiftCore 
+// RUN: %target-swift-frontend -emit-module %S/Inputs/specializer_input.swift -O -sil-serialize-witness-tables -sil-serialize-vtables -parse-stdlib -parse-as-library -emit-module -o %t/Swift.swiftmodule -module-name=Swift -module-link-name swiftCore 
 // RUN: %target-swift-frontend %s -O -I %t -emit-sil -o - | %FileCheck %s
 
 import Swift
diff --git a/test/SIL/Serialization/unmanaged.sil b/test/SIL/Serialization/unmanaged.sil
index 79cc3a2..ead2d22 100644
--- a/test/SIL/Serialization/unmanaged.sil
+++ b/test/SIL/Serialization/unmanaged.sil
@@ -10,13 +10,13 @@
 
 class C {}
 
-// CHECK-LABEL: sil @retain_release : $@convention(thin) (@sil_unmanaged Optional<C>) -> () {
+// CHECK-LABEL: sil [serialized] @retain_release : $@convention(thin) (@sil_unmanaged Optional<C>) -> () {
 // CHECK: bb0([[ARG:%.*]] : $@sil_unmanaged Optional<C>):
 // CHECK: [[REF:%.*]] = unmanaged_to_ref [[ARG]] : $@sil_unmanaged Optional<C> to $Optional<C>
 // CHECK: unmanaged_retain_value [[REF]]
 // CHECK: unmanaged_autorelease_value [[REF]]
 // CHECK: unmanaged_release_value [[REF]]
-sil @retain_release : $@convention(thin) (@sil_unmanaged Optional<C>) -> () {
+sil [serialized] @retain_release : $@convention(thin) (@sil_unmanaged Optional<C>) -> () {
 bb0(%0 : $@sil_unmanaged Optional<C>):
   %1 = unmanaged_to_ref %0 : $@sil_unmanaged Optional<C> to $Optional<C>
   unmanaged_retain_value %1 : $Optional<C>
@@ -26,13 +26,13 @@
   return %9999 : $()
 }
 
-// CHECK-LABEL: sil @test : $@convention(thin) <U where U : AnyObject> (@inout Optional<U>) -> () {
+// CHECK-LABEL: sil [serialized] @test : $@convention(thin) <U where U : AnyObject> (@inout Optional<U>) -> () {
 // CHECK: bb0([[ARG:%.*]] : $*Optional<U>):
 // CHECK: [[LOADED_ARG:%.*]] = load [copy] [[ARG]]
 // CHECK: [[UNMANAGED_LOADED_ARG:%.*]] = ref_to_unmanaged [[LOADED_ARG]] : $Optional<U> to $@sil_unmanaged Optional<U>
 // CHECK: {{%.*}} = unmanaged_to_ref [[UNMANAGED_LOADED_ARG]] : $@sil_unmanaged Optional<U> to $Optional<U>
 // CHECK: destroy_value [[LOADED_ARG]]
-sil @test : $@convention(thin) <U where U : AnyObject> (@inout Optional<U>) -> () {
+sil [serialized] @test : $@convention(thin) <U where U : AnyObject> (@inout Optional<U>) -> () {
 bb0(%0 : $*Optional<U>):
   %1 = load [copy] %0 : $*Optional<U>
   %2 = ref_to_unmanaged %1 : $Optional<U> to $@sil_unmanaged Optional<U>
diff --git a/test/SIL/Serialization/visibility.sil b/test/SIL/Serialization/visibility.sil
index c31a381..0e56db2 100644
--- a/test/SIL/Serialization/visibility.sil
+++ b/test/SIL/Serialization/visibility.sil
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend %s -Xllvm -sil-disable-pass="External Definition To Declaration" -parse-sil -sil-serialize-all -emit-module -o - -module-name Swift -module-link-name swiftCore -parse-as-library -parse-stdlib | %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all=false -module-name Swift > %t.sil
+// RUN: %target-swift-frontend %s -Xllvm -sil-disable-pass="External Definition To Declaration" -parse-sil -sil-serialize-witness-tables -emit-module -o - -module-name Swift -module-link-name swiftCore -parse-as-library -parse-stdlib | %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all=false -module-name Swift > %t.sil
 // RUN: %FileCheck %s < %t.sil
 // RUN: %FileCheck -check-prefix=NEG-CHECK %s < %t.sil
 
@@ -212,7 +212,7 @@
   return %8 : $()
 }
 
-sil @hidden_external_function_test_caller : $@convention(thin) () -> () {
+sil [serialized] @hidden_external_function_test_caller : $@convention(thin) () -> () {
   %0 = function_ref @hidden_external_function_test : $@convention(thin) () -> ()
   %1 = apply %0() : $@convention(thin) () -> ()
   %2 = tuple()
@@ -240,7 +240,7 @@
   return %8 : $()
 }
 
-sil @public_external_function_test_caller : $@convention(thin) () -> () {
+sil [serialized] @public_external_function_test_caller : $@convention(thin) () -> () {
   %0 = function_ref @public_external_function_test : $@convention(thin) () -> ()
   %1 = apply %0() : $@convention(thin) () -> ()
   %2 = tuple()
@@ -268,7 +268,7 @@
   return %8 : $()
 }
 
-sil @shared_external_function_test_caller : $@convention(thin) () -> () {
+sil [serialized] @shared_external_function_test_caller : $@convention(thin) () -> () {
   %0 = function_ref @shared_external_function_test : $@convention(thin) () -> ()
   %1 = apply %0() : $@convention(thin) () -> ()
   %2 = tuple()
diff --git a/test/SIL/Serialization/vtable.sil b/test/SIL/Serialization/vtable.sil
index fd5fcb3..06ec8bb 100644
--- a/test/SIL/Serialization/vtable.sil
+++ b/test/SIL/Serialization/vtable.sil
@@ -1,44 +1,44 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -parse-sil -emit-sib -parse-as-library -parse-stdlib -module-name vtable -o %t/vtable.sib %s
+// RUN: %target-swift-frontend -parse-sil -emit-sib -parse-as-library -sil-serialize-vtables -parse-stdlib -module-name vtable -o %t/vtable.sib %s
 // RUN: %target-sil-opt %t/vtable.sib -o - -emit-sorted-sil | %FileCheck %s
 
 sil_stage canonical
 
 import Builtin
 
-class Base {
+public class Base {
   func m1()
   func m2()
 }
 
-class Derived : Base {
+public class Derived : Base {
   override func m2()
   func m3()
 }
 
-sil hidden_external @_T01x4BaseC2m1yyF : $@convention(method) (@guaranteed Base) -> ()
+sil hidden_external [serialized] @_T01x4BaseC2m1yyF : $@convention(method) (@guaranteed Base) -> ()
 
-sil hidden_external @_T01x4BaseC2m2yyF : $@convention(method) (@guaranteed Base) -> ()
+sil hidden_external [serialized] @_T01x4BaseC2m2yyF : $@convention(method) (@guaranteed Base) -> ()
 
-sil hidden_external @_T01x4BaseCfd : $@convention(method) (@guaranteed Base) -> @owned Builtin.NativeObject
+sil hidden_external [serialized] @_T01x4BaseCfd : $@convention(method) (@guaranteed Base) -> @owned Builtin.NativeObject
 
-sil hidden_external @_T01x4BaseCfD : $@convention(method) (@owned Base) -> ()
+sil hidden_external [serialized] @_T01x4BaseCfD : $@convention(method) (@owned Base) -> ()
 
-sil hidden_external @_T01x4BaseCACycfC : $@convention(method) (@thick Base.Type) -> @owned Base
+sil hidden_external [serialized] @_T01x4BaseCACycfC : $@convention(method) (@thick Base.Type) -> @owned Base
 
-sil hidden_external @_T01x4BaseCACycfc : $@convention(method) (@owned Base) -> @owned Base
+sil hidden_external [serialized] @_T01x4BaseCACycfc : $@convention(method) (@owned Base) -> @owned Base
 
-sil hidden_external @_T01x7DerivedC2m2yyF : $@convention(method) (@guaranteed Derived) -> ()
+sil hidden_external [serialized] @_T01x7DerivedC2m2yyF : $@convention(method) (@guaranteed Derived) -> ()
 
-sil hidden_external @_T01x7DerivedC2m3yyF : $@convention(method) (@guaranteed Derived) -> ()
+sil hidden_external [serialized] @_T01x7DerivedC2m3yyF : $@convention(method) (@guaranteed Derived) -> ()
 
-sil hidden_external @_T01x7DerivedCfd : $@convention(method) (@guaranteed Derived) -> @owned Builtin.NativeObject
+sil hidden_external [serialized] @_T01x7DerivedCfd : $@convention(method) (@guaranteed Derived) -> @owned Builtin.NativeObject
 
-sil hidden_external @_T01x7DerivedCfD : $@convention(method) (@owned Derived) -> ()
+sil hidden_external [serialized] @_T01x7DerivedCfD : $@convention(method) (@owned Derived) -> ()
 
-sil hidden_external @_T01x7DerivedCACycfC : $@convention(method) (@thick Derived.Type) -> @owned Derived
+sil hidden_external [serialized] @_T01x7DerivedCACycfC : $@convention(method) (@thick Derived.Type) -> @owned Derived
 
-sil hidden_external @_T01x7DerivedCACycfc : $@convention(method) (@owned Derived) -> @owned Derived
+sil hidden_external [serialized] @_T01x7DerivedCACycfc : $@convention(method) (@owned Derived) -> @owned Derived
 
 sil_vtable Base {
   #Base.m1!1: (Base) -> () -> () : _T01x4BaseC2m1yyF
diff --git a/test/SIL/Serialization/vtable_deserialization.swift b/test/SIL/Serialization/vtable_deserialization.swift
index acae21f..5c21124 100644
--- a/test/SIL/Serialization/vtable_deserialization.swift
+++ b/test/SIL/Serialization/vtable_deserialization.swift
@@ -1,9 +1,11 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend %S/Inputs/vtable_deserialization_input.swift -o %t/Swift.swiftmodule -emit-module -parse-as-library -parse-stdlib -module-link-name swiftCore -module-name Swift -sil-serialize-all
+// RUN: %target-swift-frontend %S/Inputs/vtable_deserialization_input.swift -o %t/Swift.swiftmodule -emit-module -parse-as-library -parse-stdlib -module-link-name swiftCore -module-name Swift -sil-serialize-witness-tables -sil-serialize-vtables
 // RUN: %target-swift-frontend %s -emit-sil -O -I %t -o - | %FileCheck %s
 
 import Swift
 
+@_versioned
+@_inlineable
 func WhatShouldIDoImBored<T : P>(_ t : T) {
   t.doSomething()
 }
diff --git a/test/SIL/Serialization/witness_tables.sil b/test/SIL/Serialization/witness_tables.sil
index 285239c..83c2b7d 100644
--- a/test/SIL/Serialization/witness_tables.sil
+++ b/test/SIL/Serialization/witness_tables.sil
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -parse-as-library -sil-serialize-all -module-name witness_tables -emit-module -o - %s | %target-sil-opt -assume-parsing-unqualified-ownership-sil -module-name witness_tables | %FileCheck %s
+// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -parse-as-library -sil-serialize-witness-tables -module-name witness_tables -emit-module -o - %s | %target-sil-opt -assume-parsing-unqualified-ownership-sil -module-name witness_tables | %FileCheck %s
 
 protocol AssocReqt {
   func requiredMethod()
@@ -8,14 +8,14 @@
   func requiredMethod()
 }
 
-sil @_TFV14witness_tables15ConformingAssoc14requiredMethodfS0_FT_T_ : $@convention(method) (ConformingAssoc) -> () {
+sil [serialized] @_TFV14witness_tables15ConformingAssoc14requiredMethodfS0_FT_T_ : $@convention(method) (ConformingAssoc) -> () {
 bb0(%0 : $ConformingAssoc):
   debug_value %0 : $ConformingAssoc
   %2 = tuple ()
   return %2 : $()
 }
 
-sil @_TTWV14witness_tables15ConformingAssocS_9AssocReqtS_FS1_14requiredMethodU_fRQPS1_FT_T_ : $@convention(witness_method) (@inout ConformingAssoc) -> () {
+sil [serialized] @_TTWV14witness_tables15ConformingAssocS_9AssocReqtS_FS1_14requiredMethodU_fRQPS1_FT_T_ : $@convention(witness_method) (@inout ConformingAssoc) -> () {
 bb0(%0 : $*ConformingAssoc):
   %1 = load %0 : $*ConformingAssoc
   %2 = function_ref @_TFV14witness_tables15ConformingAssoc14requiredMethodfS0_FT_T_ : $@convention(method) (ConformingAssoc) -> ()
@@ -23,10 +23,10 @@
   return %3 : $()
 }
 
-// CHECK-LABEL: sil_witness_table ConformingAssoc: AssocReqt module witness_tables {
+// CHECK-LABEL: sil_witness_table [serialized] ConformingAssoc: AssocReqt module witness_tables {
 // CHECK: #AssocReqt.requiredMethod!1: {{.*}} : @_TTWV14witness_tables15ConformingAssocS_9AssocReqtS_FS1_14requiredMethodU_fRQPS1_FT_T_
 // CHECK: }
-sil_witness_table ConformingAssoc: AssocReqt module witness_tables {
+sil_witness_table [serialized] ConformingAssoc: AssocReqt module witness_tables {
   method #AssocReqt.requiredMethod!1: @_TTWV14witness_tables15ConformingAssocS_9AssocReqtS_FS1_14requiredMethodU_fRQPS1_FT_T_
 }
 
@@ -57,18 +57,18 @@
 }
 
 
-// CHECK-LABEL: sil_witness_table shared InheritedConformance: InheritedProtocol1 module
+// CHECK-LABEL: sil_witness_table shared [serialized] InheritedConformance: InheritedProtocol1 module
 // CHECK: base_protocol AnyProtocol: InheritedConformance: AnyProtocol module
 // CHECK: }
-sil_witness_table shared InheritedConformance: InheritedProtocol1 module witness_tables {
+sil_witness_table shared [serialized] InheritedConformance: InheritedProtocol1 module witness_tables {
   base_protocol AnyProtocol: InheritedConformance: AnyProtocol module witness_tables
 }
 
-// CHECK-LABEL: sil_witness_table shared InheritedConformance: AnyProtocol module
+// CHECK-LABEL: sil_witness_table shared [serialized] InheritedConformance: AnyProtocol module
 // CHECK: associated_type AssocType: SomeAssoc
 // CHECK: associated_type_protocol (AssocWithReqt: AssocReqt): ConformingAssoc: AssocReqt module
 // CHECK: }
-sil_witness_table shared InheritedConformance: AnyProtocol module witness_tables {
+sil_witness_table shared [serialized] InheritedConformance: AnyProtocol module witness_tables {
   associated_type AssocType: SomeAssoc
   associated_type_protocol (AssocWithReqt: AssocReqt): ConformingAssoc: AssocReqt module witness_tables
 }
@@ -89,10 +89,10 @@
 	func abc()
 }
 
-// CHECK-LABEL: sil_witness_table DeadMethodClass: Proto module witness_tables
+// CHECK-LABEL: sil_witness_table [serialized] DeadMethodClass: Proto module witness_tables
 // CHECK: method #Proto.abc!1: {{.*}} : nil
 // CHECK: }
-sil_witness_table DeadMethodClass: Proto module witness_tables {
+sil_witness_table [serialized] DeadMethodClass: Proto module witness_tables {
   method #Proto.abc!1: nil
 }
 
diff --git a/test/SILGen/Inputs/ModuleA.swift b/test/SILGen/Inputs/ModuleA.swift
index 0a1aa28..066e3dd 100644
--- a/test/SILGen/Inputs/ModuleA.swift
+++ b/test/SILGen/Inputs/ModuleA.swift
@@ -1,11 +1,14 @@
+@_versioned
+internal var gg = nonTrivialInit()
 
-private var gg = nonTrivialInit()
-
+@_inlineable
 public func get_gg_a() -> Int {
   return gg
 }
 
+@_inlineable
+@_versioned
 @inline(never)
-private func nonTrivialInit() -> Int {
+internal func nonTrivialInit() -> Int {
   return 27
 }
diff --git a/test/SILGen/Inputs/ModuleB.swift b/test/SILGen/Inputs/ModuleB.swift
index 7180344..79d456c 100644
--- a/test/SILGen/Inputs/ModuleB.swift
+++ b/test/SILGen/Inputs/ModuleB.swift
@@ -1,12 +1,14 @@
+@_versioned
+internal var gg = nonTrivialInit()
 
-
-private var gg = nonTrivialInit()
-
+@_inlineable
 public func get_gg_b() -> Int {
   return gg
 }
 
+@_versioned
+@_inlineable
 @inline(never)
-private func nonTrivialInit() -> Int {
+internal func nonTrivialInit() -> Int {
   return 28
 }
diff --git a/test/SILGen/fragile_globals.swift b/test/SILGen/fragile_globals.swift
index 3cdc72b..bb64dd4 100644
--- a/test/SILGen/fragile_globals.swift
+++ b/test/SILGen/fragile_globals.swift
@@ -1,6 +1,6 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module -parse-as-library -sil-serialize-all -o %t %S/Inputs/ModuleA.swift
-// RUN: %target-swift-frontend -emit-module -parse-as-library -sil-serialize-all -o %t %S/Inputs/ModuleB.swift
+// RUN: %target-swift-frontend -emit-module -parse-as-library -sil-serialize-witness-tables -o %t %S/Inputs/ModuleA.swift
+// RUN: %target-swift-frontend -emit-module -parse-as-library -sil-serialize-witness-tables -o %t %S/Inputs/ModuleB.swift
 // RUN: %target-swift-frontend -parse-as-library -I%t %s -Xllvm -sil-disable-pass="SIL Global Optimization" -O -emit-sil | %FileCheck %s
 
 import ModuleA
@@ -8,27 +8,23 @@
 
 var mygg = 29
 
-// Check if we have three tokens: 2 from the imported modules, one from mygg.
+// Check if we have one token: from mygg.
+// Initializers from other modules are never fragile.
 
-// CHECK: sil_global private{{.*}} @globalinit_[[T1:.*]]_token0
-// CHECK: sil_global private{{.*}} @globalinit_[[T2:.*]]_token0
 // CHECK: sil_global private{{.*}} @globalinit_[[T3:.*]]_token0
 
+//@_inlineable
 public func sum() -> Int {
   return mygg + get_gg_a() + get_gg_b()
 }
 
 // Check if all the addressors are inlined.
 
-// CHECK-LABEL: sil @_T015fragile_globals3sumSiyF
-// CHECK-DAG: global_addr @_T015fragile_globals4myggSiv
-// CHECK-DAG: global_addr @_T07ModuleA2gg33_{{.*}}
-// CHECK-DAG: global_addr @_T07ModuleA2gg33_{{.*}}
-// CHECK-DAG: global_addr @globalinit_[[T1]]_token0
-// CHECK-DAG: global_addr @globalinit_[[T2]]_token0
-// CHECK-DAG: global_addr @globalinit_[[T3]]_token0
+// CHECK-LABEL: sil {{.*}}@_T015fragile_globals3sumSiyF
+// CHECK-DAG: global_addr @globalinit_[[T1:.*]]_token0
 // CHECK-DAG: function_ref @globalinit_[[T1]]_func0
-// CHECK-DAG: function_ref @globalinit_[[T2]]_func0
-// CHECK-DAG: function_ref @globalinit_[[T3]]_func0
+// CHECK-DAG: global_addr @_T015fragile_globals4myggSivp
+// CHECK-DAG: function_ref @_T07ModuleA2ggSivau
+// CHECK-DAG: function_ref @_T07ModuleB2ggSivau
 // CHECK: return
 
diff --git a/test/SILGen/keypaths.swift b/test/SILGen/keypaths.swift
index 4f7247b..7142e6a 100644
--- a/test/SILGen/keypaths.swift
+++ b/test/SILGen/keypaths.swift
@@ -267,6 +267,13 @@
   _ = \IUOProperty.iuo!.x
 }
 
+class Bass: Hashable {
+  static func ==(_: Bass, _: Bass) -> Bool { return false }
+  var hashValue: Int { return 0 }
+}
+
+class Treble: Bass { }
+
 struct Subscripts<T> {
   subscript() -> T {
     get { fatalError() }
@@ -292,6 +299,10 @@
     get { fatalError() }
     set { fatalError() }
   }
+  subscript(bass: Bass) -> Bass {
+    get { return bass }
+    set { }
+  }
 }
 
 // CHECK-LABEL: sil hidden @{{.*}}10subscripts
@@ -321,4 +332,7 @@
   _ = \Subscripts<String>.[subGeneric: y]
 
   _ = \Subscripts<T>.[s, s].count
+
+  _ = \Subscripts<T>.[Bass()]
+  _ = \Subscripts<T>.[Treble()]
 }
diff --git a/test/SILGen/witness_tables_serialized.swift b/test/SILGen/witness_tables_serialized.swift
index 3d06881..ba1261a 100644
--- a/test/SILGen/witness_tables_serialized.swift
+++ b/test/SILGen/witness_tables_serialized.swift
@@ -2,14 +2,17 @@
 
 public protocol PublicProtocol {}
 
+@_versioned
 internal protocol InternalProtocol {}
 
+@_fixed_layout
 public struct PublicStruct : PublicProtocol, InternalProtocol {}
 
+@_versioned
 internal struct InternalStruct : PublicProtocol, InternalProtocol {}
 
 // CHECK-LABEL: sil_witness_table [serialized] PublicStruct: PublicProtocol
-// CHECK-LABEL: sil_witness_table hidden PublicStruct: InternalProtocol
+// CHECK-LABEL: sil_witness_table [serialized] PublicStruct: InternalProtocol
 
-// CHECK-LABEL: sil_witness_table hidden InternalStruct: PublicProtocol
-// CHECK-LABEL: sil_witness_table hidden InternalStruct: InternalProtocol
+// CHECK-LABEL: sil_witness_table [serialized] InternalStruct: PublicProtocol
+// CHECK-LABEL: sil_witness_table [serialized] InternalStruct: InternalProtocol
diff --git a/test/SILOptimizer/Inputs/TestModule.swift b/test/SILOptimizer/Inputs/TestModule.swift
index 2104a06..5419671 100644
--- a/test/SILOptimizer/Inputs/TestModule.swift
+++ b/test/SILOptimizer/Inputs/TestModule.swift
@@ -5,6 +5,7 @@
 }
 
 public struct MyStruct : Proto {
+  @_versioned
   func confx() {
   }
 
diff --git a/test/SILOptimizer/Inputs/linker_pass_input.swift b/test/SILOptimizer/Inputs/linker_pass_input.swift
index a31f379..872bdf8 100644
--- a/test/SILOptimizer/Inputs/linker_pass_input.swift
+++ b/test/SILOptimizer/Inputs/linker_pass_input.swift
@@ -2,23 +2,26 @@
 @_silgen_name("unknown")
 public func unknown() -> ()
 
+@_inlineable
 public func doSomething() {
   unknown()
 }
 
-@_semantics("stdlib_binary_only")
 public func doSomething2() {
   unknown()
 }
 
 @inline(never)
-@_semantics("stdlib_binary_only")
 public func doSomething3<T>(_ a:T) {
   unknown()
 }
 
-struct A {}
+@_versioned struct A {
+  @_versioned init() {}
+}
+
 @inline(never)
+@_inlineable
 public func callDoSomething3() {
   doSomething3(A())
 }
diff --git a/test/SILOptimizer/bug-reducer-tester-miscompile.sil b/test/SILOptimizer/bug-reducer-tester-miscompile.sil
index 3a20e98..9c61c9b 100644
--- a/test/SILOptimizer/bug-reducer-tester-miscompile.sil
+++ b/test/SILOptimizer/bug-reducer-tester-miscompile.sil
@@ -44,7 +44,7 @@
 
 sil @putchar : $@convention(c) (Builtin.Int64) -> ()
 
-sil @target_func : $@convention(thin) () -> () {
+sil [serialized] @target_func : $@convention(thin) () -> () {
 bb0:
   %0 = function_ref @putchar : $@convention(c) (Builtin.Int64) -> ()
   // "swift\n" in ASCII
@@ -64,7 +64,7 @@
   return %9999 : $()
 }
 
-sil @function_2 : $@convention(thin) () -> () {
+sil [serialized] @function_2 : $@convention(thin) () -> () {
 bb0:
   %0 = function_ref @target_func : $@convention(thin) () -> ()
   apply %0() : $@convention(thin) () -> ()
@@ -76,7 +76,7 @@
   return %9999 : $()
 }
 
-sil @function_3 : $@convention(thin) () -> () {
+sil [serialized] @function_3 : $@convention(thin) () -> () {
 bb0:
   // Make sure we only eliminate one.
   %0 = function_ref @target_func : $@convention(thin) () -> ()
diff --git a/test/SILOptimizer/bug-reducer-tester-runtime-crasher.sil b/test/SILOptimizer/bug-reducer-tester-runtime-crasher.sil
index 0fb01d7..e7d010e 100644
--- a/test/SILOptimizer/bug-reducer-tester-runtime-crasher.sil
+++ b/test/SILOptimizer/bug-reducer-tester-runtime-crasher.sil
@@ -41,7 +41,7 @@
 
 sil @putchar : $@convention(c) (Builtin.Int64) -> ()
 
-sil @target_func : $@convention(thin) () -> () {
+sil [serialized] @target_func : $@convention(thin) () -> () {
 bb0:
   %0 = function_ref @putchar : $@convention(c) (Builtin.Int64) -> ()
   // "swift\n" in ASCII
@@ -61,7 +61,7 @@
   return %9999 : $()
 }
 
-sil @function_2 : $@convention(thin) () -> () {
+sil [serialized] @function_2 : $@convention(thin) () -> () {
 bb0:
   %0 = function_ref @target_func : $@convention(thin) () -> ()
   apply %0() : $@convention(thin) () -> ()
@@ -73,7 +73,7 @@
   return %9999 : $()
 }
 
-sil @function_3 : $@convention(thin) () -> () {
+sil [serialized] @function_3 : $@convention(thin) () -> () {
 bb0:
   // Make sure we only eliminate one.
   %0 = function_ref @target_func : $@convention(thin) () -> ()
diff --git a/test/SILOptimizer/dead_inlined_func.swift b/test/SILOptimizer/dead_inlined_func.swift
index b1ef650..3fd99b7 100644
--- a/test/SILOptimizer/dead_inlined_func.swift
+++ b/test/SILOptimizer/dead_inlined_func.swift
@@ -1,5 +1,5 @@
 // RUN: %target-swift-frontend -O -g %s -emit-sil | %FileCheck %s -check-prefix=CHECK-SIL
-// RUN: %target-swift-frontend -O -g %s -sil-serialize-all -emit-ir | %FileCheck %s -check-prefix=CHECK-IR
+// RUN: %target-swift-frontend -O -g %s -sil-serialize-witness-tables -sil-serialize-vtables -emit-ir | %FileCheck %s -check-prefix=CHECK-IR
 
 // The dead inlined function should not be in the SIL
 // CHECK-SIL-NOT: sil {{.*}}to_be_inlined
diff --git a/test/SILOptimizer/dead_witness_module.swift b/test/SILOptimizer/dead_witness_module.swift
index e0796a7..8c6659d 100644
--- a/test/SILOptimizer/dead_witness_module.swift
+++ b/test/SILOptimizer/dead_witness_module.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -Onone -parse-stdlib -parse-as-library  -module-name TestModule -sil-serialize-all %S/Inputs/TestModule.swift -emit-module-path %t/TestModule.swiftmodule 
+// RUN: %target-swift-frontend -Onone -parse-stdlib -parse-as-library  -module-name TestModule -sil-serialize-witness-tables %S/Inputs/TestModule.swift -emit-module-path %t/TestModule.swiftmodule 
 // RUN: %target-swift-frontend -O %s -I %t -emit-sil | %FileCheck %s
 
 // DeadFunctionElimination may not remove a method from a witness table which
diff --git a/test/SILOptimizer/linker.swift b/test/SILOptimizer/linker.swift
index df23ad7..45a1e1f 100644
--- a/test/SILOptimizer/linker.swift
+++ b/test/SILOptimizer/linker.swift
@@ -1,23 +1,21 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module %S/Inputs/linker_pass_input.swift -o %t/Swift.swiftmodule -parse-stdlib -parse-as-library -module-name Swift -sil-serialize-all -module-link-name swiftCore
+// RUN: %target-swift-frontend -emit-module %S/Inputs/linker_pass_input.swift -o %t/Swift.swiftmodule -parse-stdlib -parse-as-library -module-name Swift -sil-serialize-witness-tables -sil-serialize-vtables -module-link-name swiftCore
 // RUN: %target-swift-frontend %s -O -I %t -sil-debug-serialization -o - -emit-sil | %FileCheck %s
 
 // CHECK: sil public_external [serialized] @_T0s11doSomethingyyF : $@convention(thin) () -> () {
 doSomething()
 
-// Make sure we are not linking doSomething2 because it is marked with 'noimport'
-
-// CHECK: sil [_semantics "stdlib_binary_only"] @_T0s12doSomething2yyF : $@convention(thin) () -> ()
+// CHECK: sil @_T0s12doSomething2yyF : $@convention(thin) () -> ()
 // CHECK-NOT: return
 doSomething2()
 
-// CHECK: sil public_external [serialized] [noinline] @{{.*}}callDoSomething3{{.*}}
+// CHECK: sil public_external [serialized] [noinline] @_T0s16callDoSomething3yyF
 
 // CHECK: sil @unknown
 
-// CHECK: sil [serialized] [noinline] [_semantics "stdlib_binary_only"] @{{.*}}doSomething3{{.*}}
+// CHECK: sil [noinline] @_T0s12doSomething3yxlF
 // CHECK-NOT: return
 
-// CHECK: sil {{.*}} @_T0s1AV{{[_0-9a-zA-Z]*}}fC
+// CHECK: sil @_T0s1AVABycfC
 
 callDoSomething3()
diff --git a/test/SILOptimizer/sil_witness_tables_external_witnesstable.swift b/test/SILOptimizer/sil_witness_tables_external_witnesstable.swift
index 9f765a4..5edd7c9 100644
--- a/test/SILOptimizer/sil_witness_tables_external_witnesstable.swift
+++ b/test/SILOptimizer/sil_witness_tables_external_witnesstable.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module %S/Inputs/sil_witness_tables_external_input.swift -o %t/Swift.swiftmodule -parse-stdlib -parse-as-library -module-name Swift -sil-serialize-all -module-link-name swiftCore
+// RUN: %target-swift-frontend -emit-module %S/Inputs/sil_witness_tables_external_input.swift -o %t/Swift.swiftmodule -parse-stdlib -parse-as-library -module-name Swift -sil-serialize-witness-tables -module-link-name swiftCore
 // RUN: %target-swift-frontend -O -I %t %s -emit-sil | %FileCheck %s
 
 import Swift
diff --git a/test/SILOptimizer/specialization_of_stdlib_binary_only.swift b/test/SILOptimizer/specialization_of_stdlib_binary_only.swift
deleted file mode 100644
index 38e125a..0000000
--- a/test/SILOptimizer/specialization_of_stdlib_binary_only.swift
+++ /dev/null
@@ -1,23 +0,0 @@
-// RUN: %target-swift-frontend -sil-serialize-all -O -parse-stdlib -parse-as-library -emit-sil %s | %FileCheck %s
-
-// Make sure specialization of stdlib_binary_only functions are not marked
-// shared. Marking them shared would make their visibility hidden. Because
-// stdlib_binary_only implies public external linkage in other modules we would
-// get linking errors.
-
-@_silgen_name("unknown")
-public func unknown() -> ()
-
-@inline(never)
-@_semantics("stdlib_binary_only")
-public func doSomething3<T>(_ a:T) {
-    unknown()
-}
-
-struct A {}
-@inline(never)
-public func callDoSomething3() {
-    doSomething3(A())
-}
-
-// CHECK-NOT: sil {{.*}}shared{{.*}} {{.*}}12doSomething3
diff --git a/test/SILOptimizer/specialize_cg_update_crash.sil b/test/SILOptimizer/specialize_cg_update_crash.sil
index 830e845..a117b3a 100644
--- a/test/SILOptimizer/specialize_cg_update_crash.sil
+++ b/test/SILOptimizer/specialize_cg_update_crash.sil
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -parse-stdlib -parse-as-library  -module-name TestMod -sil-serialize-all %S/Inputs/TestMod.sil -emit-module-path %t/TestMod.swiftmodule
+// RUN: %target-swift-frontend -parse-stdlib -parse-as-library  -module-name TestMod -sil-serialize-witness-tables -sil-serialize-vtables %S/Inputs/TestMod.sil -emit-module-path %t/TestMod.swiftmodule
 // RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all -inline -I %t %s | %FileCheck %s
 
 // Test if the CG is updated correctly during specialization and
diff --git a/test/SILOptimizer/string_switch.swift b/test/SILOptimizer/string_switch.swift
index d563a58..933c78d 100644
--- a/test/SILOptimizer/string_switch.swift
+++ b/test/SILOptimizer/string_switch.swift
@@ -2,7 +2,6 @@
 // RUN: %target-build-swift -O %s -module-name=test -Xllvm -sil-disable-pass=FunctionSignatureOpts -emit-sil | %FileCheck %s
 // RUN: %target-run %t.out
 // UNSUPPORTED: nonatomic_rc
-// UNSUPPORTED: resilient_stdlib
 
 import StdlibUnittest
 
diff --git a/test/Serialization/Inputs/def_basic.sil b/test/Serialization/Inputs/def_basic.sil
index 4bd889a..a691df7 100644
--- a/test/Serialization/Inputs/def_basic.sil
+++ b/test/Serialization/Inputs/def_basic.sil
@@ -1221,18 +1221,18 @@
   return undef : $()
 }
 
-// CHECK-LABEL: sil {{.*}} [reabstraction_thunk] @a_reabstraction_thunk : $@convention(thin) () -> ()
+// CHECK-LABEL: sil {{.*}}[reabstraction_thunk] @a_reabstraction_thunk : $@convention(thin) () -> ()
 sil [reabstraction_thunk] @a_reabstraction_thunk : $@convention(thin) () -> () {
   %1 = tuple()
   return %1 : $()
 }
-// CHECK-LABEL: sil {{.*}} [thunk] @a_regular_thunk : $@convention(thin) () -> () {
-sil [thunk] @a_regular_thunk : $@convention(thin) () -> () {
+// CHECK-LABEL: sil {{.*}}[thunk] @a_regular_thunk : $@convention(thin) () -> () {
+sil [serialized] [thunk] @a_regular_thunk : $@convention(thin) () -> () {
   %1 = tuple()
   return %1 : $()
 }
 
-class Foo {
+public class Foo {
   subscript (x: Int, y: Int) -> Int32 { get set }
   var x: Int
   var y: Int
diff --git a/test/Serialization/Inputs/def_noinline.swift b/test/Serialization/Inputs/def_noinline.swift
index f60a561..f06796b 100644
--- a/test/Serialization/Inputs/def_noinline.swift
+++ b/test/Serialization/Inputs/def_noinline.swift
@@ -1,10 +1,13 @@
+@_inlineable
 @inline(never) public func testNoinline(x x: Bool) -> Bool {
   return x
 }
 
 public struct NoInlineInitStruct {
+  @_versioned
   var x: Bool
 
+  @_inlineable
   @inline(never)
   public init(x x2: Bool) {
     self.x = x2
diff --git a/test/Serialization/Inputs/def_transparent.swift b/test/Serialization/Inputs/def_transparent.swift
index 70111eb..c061dfa 100644
--- a/test/Serialization/Inputs/def_transparent.swift
+++ b/test/Serialization/Inputs/def_transparent.swift
@@ -11,13 +11,21 @@
 @_transparent public func standalone_function(x x: Int32, y: Int32) -> Int32 {
   return x
 }
+
+@_inlineable
 public func foo() -> Int32 { return 0 }
+@_inlineable
 public func runced() -> Bool { return true }
 
+@_inlineable
 public func a() {}
+@_inlineable
 public func b() {}
+@_inlineable
 public func c() {}
+@_inlineable
 public func d() {}
+@_inlineable
 public func e() {}
 
 @_transparent public func test_br() {
@@ -36,6 +44,7 @@
   case Right(String)
   case Both(Int32, String)
 }
+@_inlineable
 public func do_switch(u u: MaybePair) {
   switch u {
   case .Neither:
diff --git a/test/Serialization/always_inline.swift b/test/Serialization/always_inline.swift
index a0269db..28591c8 100644
--- a/test/Serialization/always_inline.swift
+++ b/test/Serialization/always_inline.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module -sil-serialize-all -o %t %S/Inputs/def_always_inline.swift
+// RUN: %target-swift-frontend -emit-module -sil-serialize-witness-tables -sil-serialize-vtables -o %t %S/Inputs/def_always_inline.swift
 // RUN: llvm-bcanalyzer %t/def_always_inline.swiftmodule | %FileCheck %s
 // RUN: %target-swift-frontend -emit-silgen -sil-link-all -I %t %s | %FileCheck %s -check-prefix=SIL
 
diff --git a/test/Serialization/basic_sil.swift b/test/Serialization/basic_sil.swift
index 63743ea..d5abee1 100644
--- a/test/Serialization/basic_sil.swift
+++ b/test/Serialization/basic_sil.swift
@@ -1,10 +1,10 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-build-swift -Xfrontend -assume-parsing-unqualified-ownership-sil -emit-module -Xfrontend -disable-diagnostic-passes -Xfrontend -sil-serialize-all -force-single-frontend-invocation -o %t/def_basic.swiftmodule %S/Inputs/def_basic.sil
+// RUN: %target-build-swift -Xfrontend -assume-parsing-unqualified-ownership-sil -emit-module -Xfrontend -disable-diagnostic-passes -Xfrontend -sil-serialize-witness-tables -Xfrontend -sil-serialize-vtables -force-single-frontend-invocation -o %t/def_basic.swiftmodule %S/Inputs/def_basic.sil
 // RUN: llvm-bcanalyzer %t/def_basic.swiftmodule | %FileCheck %s
 // RUN: %target-build-swift -emit-silgen -Xfrontend -sil-link-all -I %t %s | %FileCheck %S/Inputs/def_basic.sil
 
 // RUN: %empty-directory(%t)
-// RUN: %target-build-swift  -Xfrontend -assume-parsing-unqualified-ownership-sil -emit-module -Xfrontend -disable-diagnostic-passes -force-single-frontend-invocation -Xfrontend -sil-serialize-all -o %t/def_basic.swiftmodule %S/Inputs/def_basic.sil
+// RUN: %target-build-swift  -Xfrontend -assume-parsing-unqualified-ownership-sil -emit-module -Xfrontend -disable-diagnostic-passes -force-single-frontend-invocation -Xfrontend -sil-serialize-witness-tables -Xfrontend -sil-serialize-vtables -o %t/def_basic.swiftmodule %S/Inputs/def_basic.sil
 // RUN: %target-build-swift -emit-silgen -Xfrontend -sil-link-all -I %t %s | %FileCheck -check-prefix=CHECK_DECL %S/Inputs/def_basic.sil
 
 // This test currently is written such that no optimizations are assumed.
diff --git a/test/Serialization/basic_sil_objc.swift b/test/Serialization/basic_sil_objc.swift
index f54147c..3eeb900 100644
--- a/test/Serialization/basic_sil_objc.swift
+++ b/test/Serialization/basic_sil_objc.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-build-swift -Xfrontend %clang-importer-sdk -I %S/../Inputs/clang-importer-sdk/swift-modules -emit-module -Xfrontend -disable-diagnostic-passes -Xfrontend -sil-serialize-all -force-single-frontend-invocation -o %t/def_basic_objc.swiftmodule %S/Inputs/def_basic_objc.sil
+// RUN: %target-build-swift -Xfrontend %clang-importer-sdk -I %S/../Inputs/clang-importer-sdk/swift-modules -emit-module -Xfrontend -disable-diagnostic-passes -Xfrontend -sil-serialize-witness-tables -Xfrontend -sil-serialize-vtables -force-single-frontend-invocation -o %t/def_basic_objc.swiftmodule %S/Inputs/def_basic_objc.sil
 // RUN: llvm-bcanalyzer %t/def_basic_objc.swiftmodule | %FileCheck %s
 // RUN: %target-build-swift -Xfrontend %clang-importer-sdk -emit-silgen -Xfrontend -sil-link-all -I %t %s | %FileCheck %S/Inputs/def_basic_objc.sil
 
diff --git a/test/Serialization/default-witness-table-deserialization.swift b/test/Serialization/default-witness-table-deserialization.swift
index 8f7757a..87d8484 100644
--- a/test/Serialization/default-witness-table-deserialization.swift
+++ b/test/Serialization/default-witness-table-deserialization.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend %s -module-name Test -sil-serialize-all -emit-module -emit-module-path - -o /dev/null | %target-sil-opt -enable-sil-verify-all -disable-sil-linking -module-name="Test" | %FileCheck %s
+// RUN: %target-swift-frontend %s -module-name Test -sil-serialize-witness-tables -sil-serialize-vtables -emit-module -emit-module-path - -o /dev/null | %target-sil-opt -enable-sil-verify-all -disable-sil-linking -module-name="Test" | %FileCheck %s
 
 // Check that default witness tables are properly deserialized.
 // rdar://problem/29173229
diff --git a/test/Serialization/duplicate_normalprotocolconformance.swift b/test/Serialization/duplicate_normalprotocolconformance.swift
index 1a33f32..752d0ad 100644
--- a/test/Serialization/duplicate_normalprotocolconformance.swift
+++ b/test/Serialization/duplicate_normalprotocolconformance.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend %S/Inputs/duplicate_normalprotocolconformance_input.swift -o %t/Swift.swiftmodule -sil-serialize-all -emit-module -parse-stdlib -parse-as-library -module-link-name swiftCore -module-name Swift
+// RUN: %target-swift-frontend %S/Inputs/duplicate_normalprotocolconformance_input.swift -o %t/Swift.swiftmodule -sil-serialize-witness-tables -sil-serialize-vtables -emit-module -parse-stdlib -parse-as-library -module-link-name swiftCore -module-name Swift
 // RUN: %target-swift-frontend -c %s -I %t -sil-link-all -o %t/out
 
 import Swift
diff --git a/test/Serialization/global_init.swift b/test/Serialization/global_init.swift
index 88f659f..18c8bbd 100644
--- a/test/Serialization/global_init.swift
+++ b/test/Serialization/global_init.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module -parse-as-library -sil-serialize-all -o %t %s
+// RUN: %target-swift-frontend -emit-module -parse-as-library -sil-serialize-witness-tables -o %t %s
 // RUN: llvm-bcanalyzer %t/global_init.swiftmodule | %FileCheck %s -check-prefix=BCANALYZER
 // RUN: %target-sil-opt -enable-sil-verify-all -disable-sil-linking %t/global_init.swiftmodule | %FileCheck %s
 
@@ -12,15 +12,19 @@
 // The only way to inspect the serialized module is sil-opt. The swift
 // driver will only output the SIL that it deserializes.
 
+@_versioned
 let MyConst = 42
+@_versioned
 var MyVar = 3
 
 // CHECK: let MyConst: Int
 // CHECK: var MyVar: Int
 
-// CHECK-DAG: sil hidden [serialized] [global_init] @_T011global_init7MyConstSivau : $@convention(thin) () -> Builtin.RawPointer
-// CHECK-DAG: sil hidden [serialized] [global_init] @_T011global_init5MyVarSivau : $@convention(thin) () -> Builtin.RawPointer
+// CHECK-DAG: sil [global_init] @_T011global_init7MyConstSivau : $@convention(thin) () -> Builtin.RawPointer
+// CHECK-DAG: sil [global_init] @_T011global_init5MyVarSivau : $@convention(thin) () -> Builtin.RawPointer
 
+@_inlineable
+@_versioned
 func getGlobals() -> Int {
   return MyVar + MyConst
 }
diff --git a/test/Serialization/noinline.swift b/test/Serialization/noinline.swift
index 46c448f..4510841 100644
--- a/test/Serialization/noinline.swift
+++ b/test/Serialization/noinline.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module -sil-serialize-all -o %t %S/Inputs/def_noinline.swift
+// RUN: %target-swift-frontend -emit-module -sil-serialize-witness-tables -sil-serialize-vtables -o %t %S/Inputs/def_noinline.swift
 // RUN: llvm-bcanalyzer %t/def_noinline.swiftmodule | %FileCheck %s
 // RUN: %target-swift-frontend -emit-silgen -sil-link-all -I %t %s | %FileCheck %s -check-prefix=SIL
 
diff --git a/test/Serialization/resilience.swift b/test/Serialization/resilience.swift
index a668045..db5ec5e 100644
--- a/test/Serialization/resilience.swift
+++ b/test/Serialization/resilience.swift
@@ -11,7 +11,7 @@
 // RUN: llvm-bcanalyzer -dump %t/resilience.swiftmodule > %t/resilience2.dump.txt
 // RUN: %FileCheck -check-prefix=CHECK -check-prefix=RESILIENCE %s < %t/resilience2.dump.txt
 
-// RUN: %target-swift-frontend -emit-module -o %t -sil-serialize-all %s
+// RUN: %target-swift-frontend -emit-module -o %t -sil-serialize-witness-tables -sil-serialize-vtables %s
 // RUN: llvm-bcanalyzer -dump %t/resilience.swiftmodule > %t/resilience3.dump.txt
 // RUN: %FileCheck -check-prefix=CHECK -check-prefix=FRAGILE %s < %t/resilience3.dump.txt
 
@@ -19,7 +19,7 @@
 
 // CHECK: <MODULE_BLOCK {{.*}}>
 // RESILIENCE: <RESILIENCE_STRATEGY abbrevid={{[0-9]+}} op0=1/>
-// FRAGILE: <RESILIENCE_STRATEGY abbrevid={{[0-9]+}} op0=2/>
+// FRAGILE-NOT: <RESILIENCE_STRATEGY abbrevid={{[0-9]+}}
 // DEFAULT-NOT: RESILIENCE_STRATEGY
 
 // CHECK: </MODULE_BLOCK>
diff --git a/test/Serialization/serialize_attr.swift b/test/Serialization/serialize_attr.swift
index e1e8a73..41104f9 100644
--- a/test/Serialization/serialize_attr.swift
+++ b/test/Serialization/serialize_attr.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module -parse-as-library -sil-serialize-all -o %t %s
+// RUN: %target-swift-frontend -emit-module -parse-as-library -sil-serialize-witness-tables -o %t %s
 // RUN: llvm-bcanalyzer %t/serialize_attr.swiftmodule | %FileCheck %s -check-prefix=BCANALYZER
 // RUN: %target-sil-opt -enable-sil-verify-all -disable-sil-linking %t/serialize_attr.swiftmodule | %FileCheck %s
 
@@ -9,6 +9,8 @@
 // -----------------------------------------------------------------------------
 
 //CHECK-DAG: @_semantics("crazy") func foo()
+@_inlineable
+@_versioned
 @_semantics("crazy") func foo() -> Int  { return 5}
 
 // @_specialize
@@ -17,24 +19,26 @@
 // These lines should be contiguous.
 // CHECK-DAG: @_specialize(exported: false, kind: full, where T == Int, U == Float)
 // CHECK-DAG: func specializeThis<T, U>(_ t: T, u: U)
+@_inlineable
+@_versioned
 @_specialize(where T == Int, U == Float)
 func specializeThis<T, U>(_ t: T, u: U) {}
 
-protocol PP {
+public protocol PP {
   associatedtype PElt
 }
-protocol QQ {
+public protocol QQ {
   associatedtype QElt
 }
 
-struct RR : PP {
-  typealias PElt = Float
+public struct RR : PP {
+  public typealias PElt = Float
 }
-struct SS : QQ {
-  typealias QElt = Int
+public struct SS : QQ {
+  public typealias QElt = Int
 }
 
-struct GG<T : PP> {}
+public struct GG<T : PP> {}
 
 // These three lines should be contiguous, however, there is no way to
 // sequence FileCheck directives while using CHECK-DAG as the outer
@@ -43,7 +47,9 @@
 // CHECK-DAG: class CC<T> where T : PP {
 // CHECK-DAG: @_specialize(exported: false, kind: full, where T == RR, U == SS)
 // CHECK-DAG: @inline(never) func foo<U>(_ u: U, g: GG<T>) -> (U, GG<T>) where U : QQ
-class CC<T : PP> {
+public class CC<T : PP> {
+  @_inlineable
+  @_versioned
   @inline(never)
   @_specialize(where T==RR, U==SS)
   func foo<U : QQ>(_ u: U, g: GG<T>) -> (U, GG<T>) {
@@ -51,6 +57,6 @@
   }
 }
 
-// CHECK-DAG: sil hidden [serialized] [_specialize exported: false, kind: full, where T == Int, U == Float] @_T014serialize_attr14specializeThisyx_q_1utr0_lF : $@convention(thin) <T, U> (@in T, @in U) -> () {
+// CHECK-DAG: sil [serialized] [_specialize exported: false, kind: full, where T == Int, U == Float] @_T014serialize_attr14specializeThisyx_q_1utr0_lF : $@convention(thin) <T, U> (@in T, @in U) -> () {
 
-// CHECK-DAG: sil hidden [serialized] [noinline] [_specialize exported: false, kind: full, where T == RR, U == SS] @_T014serialize_attr2CCC3fooqd___AA2GGVyxGtqd___AG1gtAA2QQRd__lF : $@convention(method) <T where T : PP><U where U : QQ> (@in U, GG<T>, @guaranteed CC<T>) -> (@out U, GG<T>) {
+// CHECK-DAG: sil [serialized] [noinline] [_specialize exported: false, kind: full, where T == RR, U == SS] @_T014serialize_attr2CCC3fooqd___AA2GGVyxGtqd___AG1gtAA2QQRd__lF : $@convention(method) <T where T : PP><U where U : QQ> (@in U, GG<T>, @guaranteed CC<T>) -> (@out U, GG<T>) {
diff --git a/test/Serialization/sil-serialize-all-with-cross-module-conformance.swift b/test/Serialization/sil-serialize-all-with-cross-module-conformance.swift
index 38d19ca..2b23d86 100644
--- a/test/Serialization/sil-serialize-all-with-cross-module-conformance.swift
+++ b/test/Serialization/sil-serialize-all-with-cross-module-conformance.swift
@@ -1,6 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -emit-module -parse-as-library -module-name ProtoModule -o %t/ProtoModule.swiftmodule %s -DPROTO
-// RUN: %target-swift-frontend -emit-module -parse-as-library -module-name ModelModule -o %t/ModelModule.swiftmodule %s -DMODEL -I %t -sil-serialize-all
+// RUN: %target-swift-frontend -emit-module -parse-as-library -module-name ModelModule -o %t/ModelModule.swiftmodule %s -DMODEL -I %t -sil-serialize-witness-tables -sil-serialize-vtables
 // RUN: %target-swift-frontend -emit-sil -O -sil-verify-all -o /dev/null %s -DUSE -I %t
 
 #if PROTO
diff --git a/test/Serialization/sil_box_types.sil b/test/Serialization/sil_box_types.sil
index 9c68bf2..7957368 100644
--- a/test/Serialization/sil_box_types.sil
+++ b/test/Serialization/sil_box_types.sil
@@ -1,6 +1,6 @@
 // RUN: rm -rf %t
 // RUN: mkdir %t
-// RUN: %target-build-swift -emit-module -Xfrontend -disable-diagnostic-passes -Xfrontend -sil-serialize-all -force-single-frontend-invocation -o %t/sil_box_types.swiftmodule %s
+// RUN: %target-build-swift -emit-module -Xfrontend -disable-diagnostic-passes -Xfrontend -sil-serialize-witness-tables -Xfrontend -sil-serialize-vtables -force-single-frontend-invocation -o %t/sil_box_types.swiftmodule %s
 // RUN: %target-build-swift -emit-sil -Xfrontend -sil-link-all -I %t %s | %FileCheck %s
 
 import Builtin
diff --git a/test/Serialization/sil_partial_apply_ownership.sil b/test/Serialization/sil_partial_apply_ownership.sil
index 194eced..7356e33 100644
--- a/test/Serialization/sil_partial_apply_ownership.sil
+++ b/test/Serialization/sil_partial_apply_ownership.sil
@@ -1,6 +1,6 @@
 // RUN: rm -rf %t
 // RUN: mkdir %t
-// RUN: %target-build-swift -Xfrontend -assume-parsing-unqualified-ownership-sil -emit-module -Xfrontend -disable-diagnostic-passes -Xfrontend -sil-serialize-all -force-single-frontend-invocation -o %t/sil_partial_apply_ownership.swiftmodule %s
+// RUN: %target-build-swift -Xfrontend -assume-parsing-unqualified-ownership-sil -emit-module -Xfrontend -disable-diagnostic-passes -Xfrontend -sil-serialize-witness-tables -Xfrontend -sil-serialize-vtables -force-single-frontend-invocation -o %t/sil_partial_apply_ownership.swiftmodule %s
 // RUN: %target-build-swift -Xfrontend -assume-parsing-unqualified-ownership-sil -emit-sil -Xfrontend -sil-link-all -I %t %s | %FileCheck %s
 
 import Builtin
diff --git a/test/Serialization/transparent.swift b/test/Serialization/transparent.swift
index 73e90d6..aab86af 100644
--- a/test/Serialization/transparent.swift
+++ b/test/Serialization/transparent.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module -sil-serialize-all -o %t %S/Inputs/def_transparent.swift
+// RUN: %target-swift-frontend -emit-module -sil-serialize-witness-tables -sil-serialize-vtables -o %t %S/Inputs/def_transparent.swift
 // RUN: llvm-bcanalyzer %t/def_transparent.swiftmodule | %FileCheck %s
 // RUN: %target-swift-frontend -emit-silgen -sil-link-all -I %t %s | %FileCheck %s -check-prefix=SIL
 
diff --git a/test/Serialization/vtable-function-deserialization.swift b/test/Serialization/vtable-function-deserialization.swift
index ffe3c34..e89d042 100644
--- a/test/Serialization/vtable-function-deserialization.swift
+++ b/test/Serialization/vtable-function-deserialization.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module -o Swift.swiftmodule -O -sil-inline-threshold 0 -module-name Swift -module-link-name swiftCore -parse-as-library -parse-stdlib -emit-module -sil-serialize-all %S/Inputs/vtable-function-deserialization-input.swift -o %t/Swift.swiftmodule
+// RUN: %target-swift-frontend -emit-module -o Swift.swiftmodule -O -sil-inline-threshold 0 -module-name Swift -module-link-name swiftCore -parse-as-library -parse-stdlib -emit-module -sil-serialize-witness-tables -sil-serialize-vtables %S/Inputs/vtable-function-deserialization-input.swift -o %t/Swift.swiftmodule
 // RUN: %target-swift-frontend -I %t %s -emit-sil -o - -O -sil-link-all
 
 import Swift
diff --git a/test/Serialization/witnesstable-function-deserialization.swift b/test/Serialization/witnesstable-function-deserialization.swift
index a1a9f22..b84b26e 100644
--- a/test/Serialization/witnesstable-function-deserialization.swift
+++ b/test/Serialization/witnesstable-function-deserialization.swift
@@ -1,5 +1,5 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module -O -module-name Swift -module-link-name swiftCore -parse-as-library -parse-stdlib -emit-module -sil-serialize-all %S/Inputs/witnesstable-function-deserialization-input.swift -o %t/Swift.swiftmodule -sil-inline-threshold 10
+// RUN: %target-swift-frontend -emit-module -O -module-name Swift -module-link-name swiftCore -parse-as-library -parse-stdlib -emit-module -sil-serialize-witness-tables -sil-serialize-vtables %S/Inputs/witnesstable-function-deserialization-input.swift -o %t/Swift.swiftmodule -sil-inline-threshold 10
 // RUN: %target-swift-frontend -I %t %s -emit-sil -o - -O -sil-link-all
 
 import Swift
diff --git a/test/SourceKit/Misc/stats.swift b/test/SourceKit/Misc/stats.swift
new file mode 100644
index 0000000..32c7fff
--- /dev/null
+++ b/test/SourceKit/Misc/stats.swift
@@ -0,0 +1,57 @@
+func foo() {}
+
+// RUN: %sourcekitd-test -req=syntax-map %s == -req=stats | %FileCheck %s -check-prefix=SYNTAX_1
+
+// SYNTAX_1: 2 {{.*}} source.statistic.num-requests
+// SYNTAX_1: 0 {{.*}} source.statistic.num-semantic-requests
+// SYNTAX_1: 0 {{.*}} source.statistic.num-ast-builds
+// SYNTAX_1: 1 {{.*}} source.statistic.num-open-documents
+// SYNTAX_1: 1 {{.*}} source.statistic.max-open-documents
+
+// RUN: %sourcekitd-test -req=syntax-map %s == -req=close %s == -req=stats | %FileCheck %s -check-prefix=SYNTAX_2
+
+// SYNTAX_2: 3 {{.*}} source.statistic.num-requests
+// SYNTAX_2: 0 {{.*}} source.statistic.num-semantic-requests
+// SYNTAX_2: 0 {{.*}} source.statistic.num-ast-builds
+// SYNTAX_2: 0 {{.*}} source.statistic.num-open-documents
+// SYNTAX_2: 1 {{.*}} source.statistic.max-open-documents
+
+// RUN: %sourcekitd-test -req=sema %s -- %s == -req=stats | %FileCheck %s -check-prefix=SEMA_1
+
+// SEMA_1: 3 {{.*}} source.statistic.num-requests
+// SEMA_1: 0 {{.*}} source.statistic.num-semantic-requests
+// SEMA_1: 1 {{.*}} source.statistic.num-ast-builds
+// SEMA_1: 1 {{.*}} source.statistic.num-asts-in-memory
+// SEMA_1: 1 {{.*}} source.statistic.max-asts-in-memory
+// SEMA_1: 0 {{.*}} source.statistic.num-ast-cache-hits
+// SEMA_1: 0 {{.*}} source.statistic.num-ast-snaphost-uses
+
+// RUN: %sourcekitd-test -req=sema %s -- %s == -req=edit -pos=1:1 -replace=" " %s == -req=stats | %FileCheck %s -check-prefix=SEMA_2
+
+// SEMA_2: 5 {{.*}} source.statistic.num-requests
+// SEMA_2: 0 {{.*}} source.statistic.num-semantic-requests
+// SEMA_2: 2 {{.*}} source.statistic.num-ast-builds
+// SEMA_2: 1 {{.*}} source.statistic.num-asts-in-memory
+// SEMA_2: 2 {{.*}} source.statistic.max-asts-in-memory
+// SEMA_2: 0 {{.*}} source.statistic.num-ast-cache-hits
+// SEMA_2: 0 {{.*}} source.statistic.num-ast-snaphost-uses
+
+// RUN: %sourcekitd-test -req=sema %s -- %s == -req=cursor -pos=1:6 %s -- %s == -req=stats | %FileCheck %s -check-prefix=SEMA_3
+
+// SEMA_3: 4 {{.*}} source.statistic.num-requests
+// SEMA_3: 1 {{.*}} source.statistic.num-semantic-requests
+// SEMA_3: 1 {{.*}} source.statistic.num-ast-builds
+// SEMA_3: 1 {{.*}} source.statistic.num-asts-in-memory
+// SEMA_3: 1 {{.*}} source.statistic.max-asts-in-memory
+// SEMA_3: 0 {{.*}} source.statistic.num-ast-cache-hits
+// SEMA_3: 1 {{.*}} source.statistic.num-ast-snaphost-uses
+
+// RUN: %sourcekitd-test -req=sema %s -- %s == -req=related-idents -pos=1:6 %s -- %s == -req=stats | %FileCheck %s -check-prefix=SEMA_4
+
+// SEMA_4: 4 {{.*}} source.statistic.num-requests
+// SEMA_4: 1 {{.*}} source.statistic.num-semantic-requests
+// SEMA_4: 1 {{.*}} source.statistic.num-ast-builds
+// SEMA_4: 1 {{.*}} source.statistic.num-asts-in-memory
+// SEMA_4: 1 {{.*}} source.statistic.max-asts-in-memory
+// SEMA_4: 1 {{.*}} source.statistic.num-ast-cache-hits
+// SEMA_4: 0 {{.*}} source.statistic.num-ast-snaphost-uses
diff --git a/test/expr/unary/keypath/keypath.swift b/test/expr/unary/keypath/keypath.swift
index 3b7f36c..0077db8 100644
--- a/test/expr/unary/keypath/keypath.swift
+++ b/test/expr/unary/keypath/keypath.swift
@@ -417,6 +417,23 @@
   _ = \X.Type.b // expected-error{{cannot refer to static member}}
 }
 
+class Bass: Hashable {
+  static func ==(_: Bass, _: Bass) -> Bool { return false }
+  var hashValue: Int { return 0 }
+}
+
+class Treble: Bass { }
+
+struct BassSubscript {
+  subscript(_: Bass) -> Int { fatalError() }
+  subscript(_: @autoclosure () -> String) -> Int { fatalError() }
+}
+
+func testImplicitConversionInSubscriptIndex() {
+  _ = \BassSubscript.[Treble()]
+  _ = \BassSubscript.["hello"] // expected-error{{must be Hashable}}
+}
+
 func testSyntaxErrors() { // expected-note{{}}
   _ = \.  ; // expected-error{{expected member name following '.'}}
   _ = \.a ;
diff --git a/test/sil-func-extractor/basic.sil b/test/sil-func-extractor/basic.sil
index f4aaf96..39ba357 100644
--- a/test/sil-func-extractor/basic.sil
+++ b/test/sil-func-extractor/basic.sil
@@ -14,11 +14,11 @@
 // CHECK-NOT: sil @makesInt : $@convention(thin) () -> Int64
 sil @makesInt : $@convention(thin) () -> Int64
 
-// CHECK-LABEL: sil @use_before_init : $@convention(thin) () -> Int64 {
+// CHECK-LABEL: sil [serialized] @use_before_init : $@convention(thin) () -> Int64 {
 // CHECK: bb0:
 // CHECK: return
 // CHECK: }
-sil @use_before_init : $@convention(thin) () -> Int64 {
+sil [serialized] @use_before_init : $@convention(thin) () -> Int64 {
 bb0:
   %1 = alloc_box $<τ_0_0> { var τ_0_0 } <Int64>
   %1a = project_box %1 : $<τ_0_0> { var τ_0_0 } <Int64>, 0
diff --git a/test/sil-func-extractor/basic.swift b/test/sil-func-extractor/basic.swift
index cdf1e69..b04a786 100644
--- a/test/sil-func-extractor/basic.swift
+++ b/test/sil-func-extractor/basic.swift
@@ -17,7 +17,7 @@
 // EXTRACT-FOO-NOT: sil hidden @_T05basic7VehicleCACSi1n_tcfc : $@convention(method) (Int, @guaranteed Vehicle) -> @owned Vehicle {
 // EXTRACT-FOO-NOT: sil hidden @_T05basic7VehicleC3nowSiyF : $@convention(method) (@guaranteed Vehicle) -> Int {
 
-// EXTRACT-FOO-LABEL: sil hidden @_T05basic3fooSiyF : $@convention(thin) () -> Int {
+// EXTRACT-FOO-LABEL: sil [serialized] @_T05basic3fooSiyF : $@convention(thin) () -> Int {
 // EXTRACT-FOO:       bb0:
 // EXTRACT-FOO-NEXT:    %0 = integer_literal
 // EXTRACT-FOO:         %[[POS:.*]] = struct $Int
@@ -28,7 +28,7 @@
 // EXTRACT-TEST-NOT: sil hidden @_T05basic7VehicleCACSi1n_tcfc : $@convention(method) (Int, @guaranteed Vehicle) -> @owned Vehicle {
 // EXTRACT-TEST-NOT: sil hidden @_T05basic7VehicleC3nowSiyF : $@convention(method) (@guaranteed Vehicle) -> Int {
 
-// EXTRACT-TEST-LABEL:  sil hidden @_T05basic1XV4testyyF : $@convention(method) (X) -> () {
+// EXTRACT-TEST-LABEL:  sil [serialized] @_T05basic1XV4testyyF : $@convention(method) (X) -> () {
 // EXTRACT-TEST:        bb0(%0 : $X):
 // EXTRACT-TEST-NEXT:     function_ref
 // EXTRACT-TEST-NEXT:     function_ref @_T05basic3fooSiyF : $@convention(thin) () -> Int
@@ -37,11 +37,11 @@
 // EXTRACT-TEST-NEXT:     return
 
 
-// EXTRACT-INIT-NOT: sil hidden @_T05basic3fooSiyF : $@convention(thin) () -> Int {
-// EXTRACT-INIT-NOT: sil hidden @_T05basic1XV4testyyF : $@convention(method) (X) -> () {
-// EXTRACT-INIT-NOT: sil hidden @_T05basic7VehicleC3nowSiyF : $@convention(method) (@owned Vehicle) -> Int {
+// EXTRACT-INIT-NOT: sil [serialized] @_T05basic3fooSiyF : $@convention(thin) () -> Int {
+// EXTRACT-INIT-NOT: sil [serialized] @_T05basic1XV4testyyF : $@convention(method) (X) -> () {
+// EXTRACT-INIT-NOT: sil [serialized] @_T05basic7VehicleC3nowSiyF : $@convention(method) (@owned Vehicle) -> Int {
 
-// EXTRACT-INIT-LABEL:   sil hidden @_T05basic7VehicleCACSi1n_tcfc : $@convention(method) (Int, @owned Vehicle) -> @owned Vehicle {
+// EXTRACT-INIT-LABEL:   sil [serialized] @_T05basic7VehicleCACSi1n_tcfc : $@convention(method) (Int, @owned Vehicle) -> @owned Vehicle {
 // EXTRACT-INIT:         bb0
 // EXTRACT-INIT-NEXT:      ref_element_addr
 // EXTRACT-INIT-NEXT:      begin_access [modify] [dynamic]
@@ -50,11 +50,11 @@
 // EXTRACT-INIT-NEXT:      return
 
 
-// EXTRACT-NOW-NOT: sil hidden @_T05basic3fooSiyF : $@convention(thin) () -> Int {
-// EXTRACT-NOW-NOT: sil hidden @_T05basic1XV4testyyF : $@convention(method) (X) -> () {
-// EXTRACT-NOW-NOT: sil hidden @_T05basic7VehicleCACSi1n_tcfc : $@convention(method) (Int, @guaranteed Vehicle) -> @owned Vehicle {
+// EXTRACT-NOW-NOT: sil [serialized] @_T05basic3fooSiyF : $@convention(thin) () -> Int {
+// EXTRACT-NOW-NOT: sil [serialized] @_T05basic1XV4testyyF : $@convention(method) (X) -> () {
+// EXTRACT-NOW-NOT: sil [serialized] @_T05basic7VehicleCACSi1n_tcfc : $@convention(method) (Int, @guaranteed Vehicle) -> @owned Vehicle {
 
-// EXTRACT-NOW-LABEL:   sil hidden @_T05basic7VehicleC3nowSiyF : $@convention(method) (@guaranteed Vehicle) -> Int {
+// EXTRACT-NOW-LABEL:   sil [serialized] @_T05basic7VehicleC3nowSiyF : $@convention(method) (@guaranteed Vehicle) -> Int {
 // EXTRACT-NOW:         bb0
 // EXTRACT-NOW:           ref_element_addr
 // EXTRACT-NOW-NEXT:      begin_access [read] [dynamic]
@@ -62,25 +62,34 @@
 // EXTRACT-NOW-NEXT:      end_access
 // EXTRACT-NOW-NEXT:      return
 
-struct X {
+public struct X {
+  @_versioned
+  @_inlineable
   func test() {
     foo()
   }
 }
 
-class Vehicle {
+public class Vehicle {
+    @_versioned
     var numOfWheels: Int
 
+    @_versioned
+    @_inlineable
     init(n: Int) {
       numOfWheels = n
     }
 
+    @_versioned
+    @_inlineable
     func now() -> Int {
         return numOfWheels
     }
 }
 
 @discardableResult
+@_versioned
+@_inlineable
 func foo() -> Int {
   return 7
 }
diff --git a/test/sil-func-extractor/load-serialized-sil.swift b/test/sil-func-extractor/load-serialized-sil.swift
index 28dbbac..52c1eda 100644
--- a/test/sil-func-extractor/load-serialized-sil.swift
+++ b/test/sil-func-extractor/load-serialized-sil.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -sil-serialize-all -module-link-name swiftCore -O -parse-as-library -parse-stdlib -emit-module -emit-module-path - -o /dev/null | %target-sil-func-extractor -module-name="Swift" -func="_T0s1XV4testyyF" | %FileCheck %s
+// RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -sil-serialize-witness-tables -sil-serialize-vtables -module-link-name swiftCore -O -parse-as-library -parse-stdlib -emit-module -emit-module-path - -o /dev/null | %target-sil-func-extractor -module-name="Swift" -func="_T0s1XV4testyyF" | %FileCheck %s
 // RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -O -parse-as-library -parse-stdlib -emit-sib -o - | %target-sil-func-extractor -module-name="Swift" -func="_T0s1XV4testyyF" | %FileCheck %s -check-prefix=SIB-CHECK
 
 // CHECK: import Builtin
@@ -7,13 +7,14 @@
 // CHECK: func unknown()
 
 // CHECK: struct X {
-// CHECK-NEXT:  func test()
+// CHECK-NEXT:  @_versioned
+// CHECK-NEXT:  @_inlineable func test()
 // CHECK-NEXT:  init
 // CHECK-NEXT: }
 
 // CHECK: sil @unknown : $@convention(thin) () -> ()
 
-// CHECK-LABEL: sil hidden [serialized] @_T0s1XV4testyyF : $@convention(method) (X) -> ()
+// CHECK-LABEL: sil [serialized] @_T0s1XV4testyyF : $@convention(method) (X) -> ()
 // CHECK: bb0
 // CHECK-NEXT: function_ref
 // CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> ()
@@ -30,13 +31,14 @@
 // SIB-CHECK: func unknown()
 
 // SIB-CHECK: struct X {
-// SIB-CHECK-NEXT:  func test()
+// SIB-CHECK-NEXT:  @_versioned
+// SIB-CHECK-NEXT:  @_inlineable func test()
 // SIB-CHECK-NEXT:  init
 // SIB-CHECK-NEXT: }
 
 // SIB-CHECK: sil @unknown : $@convention(thin) () -> ()
 
-// SIB-CHECK-LABEL: sil hidden @_T0s1XV4testyyF : $@convention(method) (X) -> ()
+// SIB-CHECK-LABEL: sil [serialized] @_T0s1XV4testyyF : $@convention(method) (X) -> ()
 // SIB-CHECK: bb0
 // SIB-CHECK-NEXT: function_ref
 // SIB-CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> ()
@@ -49,7 +51,9 @@
 @_silgen_name("unknown")
 public func unknown() -> ()
 
-struct X {
+public struct X {
+  @_versioned
+  @_inlineable
   func test() {
     unknown()
   }
diff --git a/test/sil-nm/basic.sil b/test/sil-nm/basic.sil
index 5464b2d..77fdabe 100644
--- a/test/sil-nm/basic.sil
+++ b/test/sil-nm/basic.sil
@@ -1,4 +1,4 @@
-// RUN: %target-sil-nm -assume-parsing-unqualified-ownership-sil %s | %FileCheck %s
+// RUN: %target-sil-nm -assume-parsing-unqualified-ownership-sil %s | %FileCheck -check-prefix=SIL-NM -check-prefix=CHECK %s
 // RUN: %target-sil-nm -demangle -assume-parsing-unqualified-ownership-sil %s | %FileCheck -check-prefix=DEMANGLE %s
 // RUN: rm -rfv %t
 // RUN: mkdir %t
@@ -22,28 +22,28 @@
 }
 
 // CHECK: F c_deinit
-sil @c_deinit : $@convention(method) (@owned C) -> () {
+sil [serialized] @c_deinit : $@convention(method) (@owned C) -> () {
 bb0(%0 : $C):
   %1 = tuple()
   return %1 : $()
 }
 
 // CHECK: F defaultA
-sil @defaultA : $@convention(witness_method) <Self where Self : ResilientProtocol> (@in_guaranteed Self) -> () {
+sil [serialized] @defaultA : $@convention(witness_method) <Self where Self : ResilientProtocol> (@in_guaranteed Self) -> () {
 bb0(%0 : $*Self):
   %result = tuple ()
   return %result : $()
 }
 
 // CHECK: F f1
-sil @f1 : $@convention(thin) () -> () {
+sil [serialized] @f1 : $@convention(thin) () -> () {
 bb0:
   %0 = tuple()
   return %0 : $()
 }
 
 // CHECK: F globalinit
-sil @globalinit : $@convention(thin) () -> () {
+sil [serialized] @globalinit : $@convention(thin) () -> () {
 bb0:
   %0 = tuple()
   return %0 : $()
@@ -54,11 +54,13 @@
 
 // CHECK: W _T04main23ConformingGenericStructVyxGAA17ResilientProtocolAAlWP
 // DEMANGLE: W protocol witness table for <A> main.ConformingGenericStruct<A> : main.ResilientProtocol in main
-sil_witness_table <T> ConformingGenericStruct<T> : ResilientProtocol module protocol_resilience {
+sil_witness_table [serialized] <T> ConformingGenericStruct<T> : ResilientProtocol module protocol_resilience {
   method #ResilientProtocol.defaultA!1: @defaultA
 }
 
-// CHECK: V C
+// vtables cannot be serialized from SIL.
+// Only the frontend has the -Xfrontend -sil-serialize-vtables option. 
+// SIL-NM: V C
 sil_vtable C {
   #C.deinit!deallocator: c_deinit
 }
diff --git a/test/sil-opt/sil-opt.swift b/test/sil-opt/sil-opt.swift
index c90c52f..4171261 100644
--- a/test/sil-opt/sil-opt.swift
+++ b/test/sil-opt/sil-opt.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -sil-serialize-all -module-link-name swiftCore -O -parse-as-library -parse-stdlib -emit-module -emit-module-path - -o /dev/null | %target-sil-opt -enable-sil-verify-all -module-name="Swift" | %FileCheck %s
+// RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -sil-serialize-witness-tables -module-link-name swiftCore -O -parse-as-library -parse-stdlib -emit-module -emit-module-path - -o /dev/null | %target-sil-opt -enable-sil-verify-all -module-name="Swift" | %FileCheck %s
 // RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -O -parse-as-library -parse-stdlib -emit-sib -o - | %target-sil-opt -enable-sil-verify-all -module-name="Swift" | %FileCheck %s -check-prefix=SIB-CHECK
 
 // CHECK: import Builtin
@@ -7,13 +7,13 @@
 // CHECK: func unknown()
 
 // CHECK: struct X {
-// CHECK-NEXT:  func test()
-// CHECK-NEXT:  init
+// CHECK-NEXT:  @_inlineable func test()
+// CHECK-NEXT:  @_inlineable init
 // CHECK-NEXT: }
 
 // CHECK: sil @unknown : $@convention(thin) () -> ()
 
-// CHECK-LABEL: sil hidden [serialized] @_T0s1XV4testyyF : $@convention(method) (X) -> ()
+// CHECK-LABEL: sil [serialized] @_T0s1XV4testyyF : $@convention(method) (X) -> ()
 // CHECK: bb0
 // CHECK-NEXT: function_ref
 // CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> ()
@@ -21,7 +21,7 @@
 // CHECK-NEXT: tuple
 // CHECK-NEXT: return
 
-// CHECK-LABEL: sil hidden [serialized] @_T0s1XVABycfC : $@convention(method) (@thin X.Type) -> X
+// CHECK-LABEL: sil [serialized] @_T0s1XVABycfC : $@convention(method) (@thin X.Type) -> X
 // CHECK: bb0
 // CHECK-NEXT: struct $X ()
 // CHECK-NEXT: return
@@ -39,7 +39,7 @@
 
 // SIB-CHECK: sil @unknown : $@convention(thin) () -> ()
 
-// SIB-CHECK-LABEL: sil hidden @_T0s1XV4testyyF : $@convention(method) (X) -> ()
+// SIB-CHECK-LABEL: sil [serialized] @_T0s1XV4testyyF : $@convention(method) (X) -> ()
 // SIB-CHECK: bb0
 // SIB-CHECK-NEXT: function_ref
 // SIB-CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> ()
@@ -47,7 +47,7 @@
 // SIB-CHECK-NEXT: tuple
 // SIB-CHECK-NEXT: return
 
-// SIB-CHECK-LABEL: sil hidden @_T0s1XVABycfC : $@convention(method) (@thin X.Type) -> X
+// SIB-CHECK-LABEL: sil [serialized] @_T0s1XVABycfC : $@convention(method) (@thin X.Type) -> X
 // SIB-CHECK: bb0
 // SIB-CHECK-NEXT: struct $X ()
 // SIB-CHECK-NEXT: return
@@ -55,8 +55,13 @@
 @_silgen_name("unknown")
 public func unknown() -> ()
 
-struct X {
-  func test() {
+// FIXME: Why does it need to be public?
+public struct X {
+  @_inlineable
+  public func test() {
     unknown()
   }
+
+  @_inlineable
+  public init() {}
 }
diff --git a/tools/SourceKit/include/SourceKit/Core/LangSupport.h b/tools/SourceKit/include/SourceKit/Core/LangSupport.h
index 7cb7f86..117fc80 100644
--- a/tools/SourceKit/include/SourceKit/Core/LangSupport.h
+++ b/tools/SourceKit/include/SourceKit/Core/LangSupport.h
@@ -251,6 +251,9 @@
   virtual bool valueForOption(UIdent Key, StringRef &Val) = 0;
 };
 
+struct Statistic;
+typedef std::function<void(ArrayRef<Statistic *> stats)> StatisticsReceiver;
+
 struct RefactoringInfo {
   UIdent Kind;
   StringRef KindName;
@@ -626,6 +629,8 @@
                           StringRef ModuleName,
                           ArrayRef<const char *> Args,
                           DocInfoConsumer &Consumer) = 0;
+
+  virtual void getStatistics(StatisticsReceiver) = 0;
 };
 
 } // namespace SourceKit
diff --git a/tools/SourceKit/include/SourceKit/Core/ProtocolUIDs.def b/tools/SourceKit/include/SourceKit/Core/ProtocolUIDs.def
index b332d41..2efa730 100644
--- a/tools/SourceKit/include/SourceKit/Core/ProtocolUIDs.def
+++ b/tools/SourceKit/include/SourceKit/Core/ProtocolUIDs.def
@@ -107,6 +107,7 @@
 KEY(LocalizationKey, "key.localization_key")
 KEY(IsZeroArgSelector, "key.is_zero_arg_selector")
 KEY(SwiftVersion, "key.swift_version")
+KEY(Value, "key.value")
 
 KEY(EnableDiagnostics, "key.enablediagnostics")
 KEY(GroupName, "key.groupname")
@@ -181,6 +182,7 @@
 REQUEST(ModuleGroups, "source.request.module.groups")
 REQUEST(NameTranslation, "source.request.name.translation")
 REQUEST(MarkupToXML, "source.request.convert.markup.xml")
+REQUEST(Statistics, "source.request.statistics")
 
 REQUEST(SyntacticRename, "source.request.syntacticrename")
 REQUEST(FindRenameRanges, "source.request.find-syntactic-rename-ranges")
@@ -340,6 +342,9 @@
 KIND(Call, "source.syntacticrename.call")
 KIND(Unknown, "source.syntacticrename.unknown")
 
+KIND(StatNumRequests, "source.statistic.num-requests")
+KIND(StatNumSemaRequests, "source.statistic.num-semantic-requests")
+
 #undef KIND
 #undef REQUEST
 #undef KEY
diff --git a/tools/SourceKit/include/SourceKit/Support/Statistic.h b/tools/SourceKit/include/SourceKit/Support/Statistic.h
new file mode 100644
index 0000000..8f62f55
--- /dev/null
+++ b/tools/SourceKit/include/SourceKit/Support/Statistic.h
@@ -0,0 +1,48 @@
+//===--- Statistic.h - ------------------------------------------*- C++ -*-===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SOURCEKIT_SUPPORT_STATISTIC_H
+#define LLVM_SOURCEKIT_SUPPORT_STATISTIC_H
+
+#include "SourceKit/Support/UIdent.h"
+#include <atomic>
+#include <string>
+
+namespace SourceKit {
+
+struct Statistic {
+  const UIdent name;
+  const std::string description;
+  std::atomic<int64_t> value = {0};
+
+  Statistic(UIdent name, std::string description)
+      : name(name), description(std::move(description)) {}
+
+  int64_t operator++() {
+    return 1 + value.fetch_add(1, std::memory_order_relaxed);
+  }
+  int64_t operator--() {
+    return value.fetch_sub(1, std::memory_order_relaxed) - 1;
+  }
+
+  void updateMax(int64_t newValue) {
+    int64_t prev = value.load(std::memory_order_relaxed);
+    // Note: compare_exchange_weak updates 'prev' if it fails.
+    while (newValue > prev && !value.compare_exchange_weak(
+                                  prev, newValue, std::memory_order_relaxed)) {
+    }
+  }
+};
+
+} // namespace SourceKit
+
+#endif // LLVM_SOURCEKIT_SUPPORT_STATISTIC_H
diff --git a/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp b/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp
index b082757..9597a5f 100644
--- a/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp
+++ b/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp
@@ -158,13 +158,15 @@
 namespace SourceKit {
   struct ASTUnit::Implementation {
     const uint64_t Generation;
+    SwiftStatistics &Stats;
     SmallVector<ImmutableTextSnapshotRef, 4> Snapshots;
     EditorDiagConsumer CollectDiagConsumer;
     CompilerInstance CompInst;
     OwnedResolver TypeResolver{ nullptr, nullptr };
     WorkQueue Queue{ WorkQueue::Dequeuing::Serial, "sourcekit.swift.ConsumeAST" };
 
-    Implementation(uint64_t Generation) : Generation(Generation) {}
+    Implementation(uint64_t Generation, SwiftStatistics &Statistics)
+        : Generation(Generation), Stats(Statistics) {}
 
     void consumeAsync(SwiftASTConsumerRef ASTConsumer, ASTUnitRef ASTRef);
   };
@@ -185,10 +187,14 @@
     });
   }
 
-  ASTUnit::ASTUnit(uint64_t Generation) : Impl(*new Implementation(Generation)) {
+  ASTUnit::ASTUnit(uint64_t Generation, SwiftStatistics &Stats)
+      : Impl(*new Implementation(Generation, Stats)) {
+    auto numASTs = ++Stats.numASTsInMem;
+    Stats.maxASTsInMem.updateMax(numASTs);
   }
 
   ASTUnit::~ASTUnit() {
+    --Impl.Stats.numASTsInMem;
     delete &Impl;
   }
 
@@ -307,10 +313,12 @@
 
 struct SwiftASTManager::Implementation {
   explicit Implementation(SwiftLangSupport &LangSupport)
-    : EditorDocs(LangSupport.getEditorDocuments()),
-      RuntimeResourcePath(LangSupport.getRuntimeResourcePath()) { }
+      : EditorDocs(LangSupport.getEditorDocuments()),
+        Stats(LangSupport.getStatistics()),
+        RuntimeResourcePath(LangSupport.getRuntimeResourcePath()) {}
 
   SwiftEditorDocumentFileMap &EditorDocs;
+  SwiftStatistics &Stats;
   std::string RuntimeResourcePath;
   SourceManager SourceMgr;
   Cache<ASTKey, ASTProducerRef> ASTCache{ "sourcekit.swift.ASTCache" };
@@ -488,6 +496,7 @@
 
   if (ASTUnitRef Unit = Producer->getExistingAST()) {
     if (ASTConsumer->canUseASTWithSnapshots(Unit->getSnapshots())) {
+      ++Impl.Stats.numASTsUsedWithSnaphots;
       Unit->Impl.consumeAsync(std::move(ASTConsumer), Unit);
       return;
     }
@@ -616,6 +625,8 @@
       ASTProducerRef ThisProducer = this;
       MgrImpl.ASTCache.set(InvokRef->Impl.Key, ThisProducer);
     }
+  } else {
+    ++MgrImpl.Stats.numASTCacheHits;
   }
 
   return AST;
@@ -732,6 +743,8 @@
 ASTUnitRef ASTProducer::createASTUnit(SwiftASTManager::Implementation &MgrImpl,
                                       ArrayRef<ImmutableTextSnapshotRef> Snapshots,
                                       std::string &Error) {
+  ++MgrImpl.Stats.numASTBuilds;
+
   Stamps.clear();
   DependencyStamps.clear();
 
@@ -770,7 +783,7 @@
     TraceInfo.Args.Args = Opts.Args;
   }
 
-  ASTUnitRef ASTRef = new ASTUnit(++ASTUnitGeneration);
+  ASTUnitRef ASTRef = new ASTUnit(++ASTUnitGeneration, MgrImpl.Stats);
   for (auto &Content : Contents) {
     if (Content.Snapshot)
       ASTRef->Impl.Snapshots.push_back(Content.Snapshot);
diff --git a/tools/SourceKit/lib/SwiftLang/SwiftASTManager.h b/tools/SourceKit/lib/SwiftLang/SwiftASTManager.h
index e6b4cee..a47c975 100644
--- a/tools/SourceKit/lib/SwiftLang/SwiftASTManager.h
+++ b/tools/SourceKit/lib/SwiftLang/SwiftASTManager.h
@@ -40,6 +40,7 @@
   class SwiftEditorDocumentFileMap;
   class SwiftLangSupport;
   class SwiftInvocation;
+  struct SwiftStatistics;
   typedef RefPtr<SwiftInvocation> SwiftInvocationRef;
   class EditorDiagConsumer;
 
@@ -48,7 +49,7 @@
   struct Implementation;
   Implementation &Impl;
 
-  explicit ASTUnit(uint64_t Generation);
+  explicit ASTUnit(uint64_t Generation, SwiftStatistics &Statistics);
   ~ASTUnit();
 
   swift::CompilerInstance &getCompilerInstance() const;
diff --git a/tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp b/tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp
index 7414626..b42e0ef 100644
--- a/tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp
+++ b/tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp
@@ -2073,6 +2073,8 @@
       LOG_WARN_FUNC("Document already exists in editorOpen(..): " << Name);
       Snapshot = nullptr;
     }
+    auto numOpen = ++Stats.numOpenDocs;
+    Stats.maxOpenDocs.updateMax(numOpen);
   }
 
   if (!Snapshot) {
@@ -2095,8 +2097,12 @@
 
 void SwiftLangSupport::editorClose(StringRef Name, bool RemoveCache) {
   auto Removed = EditorDocuments.remove(Name);
-  if (!Removed)
+  if (Removed) {
+    --Stats.numOpenDocs;
+  } else {
     IFaceGenContexts.remove(Name);
+  }
+
   if (Removed && RemoveCache)
     Removed->removeCachedAST();
   // FIXME: Report error if Name did not apply to anything ?
diff --git a/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp b/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp
index dfb75c6..f4afeb8 100644
--- a/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp
+++ b/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp
@@ -715,6 +715,14 @@
 #endif
 }
 
+void SwiftLangSupport::getStatistics(StatisticsReceiver receiver) {
+  std::vector<Statistic *> stats = {
+#define SWIFT_STATISTIC(VAR, UID, DESC) &Stats.VAR,
+#include "SwiftStatistics.def"
+  };
+  receiver(stats);
+}
+
 CloseClangModuleFiles::~CloseClangModuleFiles() {
   clang::Preprocessor &PP = loader.getClangPreprocessor();
   clang::ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
diff --git a/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.h b/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.h
index 4e837c1..8b2bc5a 100644
--- a/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.h
+++ b/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.h
@@ -17,6 +17,7 @@
 #include "SwiftInterfaceGenContext.h"
 #include "SourceKit/Core/LangSupport.h"
 #include "SourceKit/Support/Concurrency.h"
+#include "SourceKit/Support/Statistic.h"
 #include "SourceKit/Support/ThreadSafeRefCntPtr.h"
 #include "SourceKit/Support/Tracing.h"
 #include "swift/Basic/ThreadSafeRefCounted.h"
@@ -250,6 +251,12 @@
                         const swift::DiagnosticInfo &Info) override;
 };
 
+struct SwiftStatistics {
+#define SWIFT_STATISTIC(VAR, UID, DESC)                                        \
+  Statistic VAR{UIdent{"source.statistic." #UID}, DESC};
+#include "SwiftStatistics.def"
+};
+
 class SwiftLangSupport : public LangSupport {
   SourceKit::Context &SKCtx;
   std::string RuntimeResourcePath;
@@ -260,6 +267,7 @@
   ThreadSafeRefCntPtr<SwiftPopularAPI> PopularAPI;
   CodeCompletion::SessionCacheMap CCSessions;
   ThreadSafeRefCntPtr<SwiftCustomCompletions> CustomCompletions;
+  SwiftStatistics Stats;
 
 public:
   explicit SwiftLangSupport(SourceKit::Context &SKCtx);
@@ -277,6 +285,8 @@
     return CCCache;
   }
 
+  SwiftStatistics &getStatistics() { return Stats; }
+
   static SourceKit::UIdent getUIDForDecl(const swift::Decl *D,
                                          bool IsRef = false);
   static SourceKit::UIdent getUIDForExtensionOfDecl(const swift::Decl *D);
@@ -492,6 +502,8 @@
   void findModuleGroups(StringRef ModuleName, ArrayRef<const char *> Args,
                std::function<void(ArrayRef<StringRef>, StringRef Error)> Receiver) override;
 
+  void getStatistics(StatisticsReceiver) override;
+
 private:
   swift::SourceFile *getSyntacticSourceFile(llvm::MemoryBuffer *InputBuf,
                                             ArrayRef<const char *> Args,
diff --git a/tools/SourceKit/lib/SwiftLang/SwiftStatistics.def b/tools/SourceKit/lib/SwiftLang/SwiftStatistics.def
new file mode 100644
index 0000000..8bc2b45
--- /dev/null
+++ b/tools/SourceKit/lib/SwiftLang/SwiftStatistics.def
@@ -0,0 +1,28 @@
+//===--- SwiftStatistics.def - ----------------------------------*- C++ -*-===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SWIFT_STATISTIC
+#error "must define SWIFT_STATISTIC to use"
+#endif
+
+/// SWIFT_STATISTIC(VAR_NAME, UNIQUE_ID, DESCRIPTION)
+
+SWIFT_STATISTIC(numASTBuilds, num-ast-builds, "# of ASTs built or rebuilt")
+SWIFT_STATISTIC(numASTsInMem, num-asts-in-memory, "# of ASTs currently in memory")
+SWIFT_STATISTIC(maxASTsInMem, max-asts-in-memory, "maximum # of ASTs ever in memory at once")
+SWIFT_STATISTIC(numASTCacheHits, num-ast-cache-hits, "# of ASTs found in the cache without rebuilding")
+SWIFT_STATISTIC(numASTsUsedWithSnaphots, num-ast-snaphost-uses, "# of ASTs used with snaphots without rebuilding")
+
+SWIFT_STATISTIC(numOpenDocs, num-open-documents, "# of editor documents currently open")
+SWIFT_STATISTIC(maxOpenDocs, max-open-documents, "maximum # of editor documents ever open at once")
+
+#undef SWIFT_STATISTIC
diff --git a/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp b/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp
index 07a1f7c..4f77007 100644
--- a/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp
+++ b/tools/SourceKit/tools/sourcekitd-test/TestOptions.cpp
@@ -127,6 +127,7 @@
         .Case("find-usr", SourceKitRequest::FindUSR)
         .Case("find-interface", SourceKitRequest::FindInterfaceDoc)
         .Case("open", SourceKitRequest::Open)
+        .Case("close", SourceKitRequest::Close)
         .Case("edit", SourceKitRequest::Edit)
         .Case("print-annotations", SourceKitRequest::PrintAnnotations)
         .Case("print-diags", SourceKitRequest::PrintDiags)
@@ -145,6 +146,7 @@
         .Case("expand-default", SourceKitRequest::ExpandDefault)
         .Case("localize-string", SourceKitRequest::LocalizeString)
         .Case("markup-xml", SourceKitRequest::MarkupToXML)
+        .Case("stats", SourceKitRequest::Statistics)
         .Default(SourceKitRequest::None);
 
       if (Request == SourceKitRequest::None) {
@@ -153,8 +155,8 @@
                "complete.update/complete.cache.ondisk/complete.cache.setpopularapi/"
                "cursor/related-idents/syntax-map/structure/format/expand-placeholder/"
                "doc-info/sema/interface-gen/interface-gen-openfind-usr/find-interface/"
-               "open/edit/print-annotations/print-diags/extract-comment/module-groups/"
-               "range/syntactic-rename/find-rename-ranges/translate/markup-xml\n";
+               "open/close/edit/print-annotations/print-diags/extract-comment/module-groups/"
+               "range/syntactic-rename/find-rename-ranges/translate/markup-xml/stats\n";
         return true;
       }
       break;
diff --git a/tools/SourceKit/tools/sourcekitd-test/TestOptions.h b/tools/SourceKit/tools/sourcekitd-test/TestOptions.h
index 0464d8da..3d3d05b 100644
--- a/tools/SourceKit/tools/sourcekitd-test/TestOptions.h
+++ b/tools/SourceKit/tools/sourcekitd-test/TestOptions.h
@@ -45,6 +45,7 @@
   FindUSR,
   FindInterfaceDoc,
   Open,
+  Close,
   Edit,
   PrintAnnotations,
   PrintDiags,
@@ -55,6 +56,7 @@
   FindLocalRenameRanges,
   NameTranslation,
   MarkupToXML,
+  Statistics,
 #define SEMANTIC_REFACTORING(KIND, NAME, ID) KIND,
 #include "swift/IDE/RefactoringKinds.def"
 };
diff --git a/tools/SourceKit/tools/sourcekitd-test/sourcekitd-test.cpp b/tools/SourceKit/tools/sourcekitd-test/sourcekitd-test.cpp
index 47ce8a1..5c1568a 100644
--- a/tools/SourceKit/tools/sourcekitd-test/sourcekitd-test.cpp
+++ b/tools/SourceKit/tools/sourcekitd-test/sourcekitd-test.cpp
@@ -71,6 +71,7 @@
 static void prepareMangleRequest(sourcekitd_object_t Req,
                                  const TestOptions &Opts);
 static void printMangleResults(sourcekitd_variant_t Info, raw_ostream &OS);
+static void printStatistics(sourcekitd_variant_t Info, raw_ostream &OS);
 
 static unsigned resolveFromLineCol(unsigned Line, unsigned Col,
                                    StringRef Filename);
@@ -569,6 +570,11 @@
     sourcekitd_request_dictionary_set_string(Req, KeyName, SourceFile.c_str());
     break;
 
+  case SourceKitRequest::Close:
+    sourcekitd_request_dictionary_set_uid(Req, KeyRequest, RequestEditorClose);
+    sourcekitd_request_dictionary_set_string(Req, KeyName, SourceFile.c_str());
+    break;
+
   case SourceKitRequest::Edit:
     sourcekitd_request_dictionary_set_uid(Req, KeyRequest,
                                           RequestEditorReplaceText);
@@ -662,7 +668,7 @@
     break;
 
   case SourceKitRequest::SyntacticRename:
-  case SourceKitRequest::FindRenameRanges:
+  case SourceKitRequest::FindRenameRanges: {
     if (Opts.Request == SourceKitRequest::SyntacticRename) {
       sourcekitd_request_dictionary_set_uid(Req, KeyRequest, RequestSyntacticRename);
     } else {
@@ -684,6 +690,10 @@
     sourcekitd_request_dictionary_set_value(Req, KeyRenameLocations, RenameSpec);
     break;
   }
+  case SourceKitRequest::Statistics:
+    sourcekitd_request_dictionary_set_uid(Req, KeyRequest, RequestStatistics);
+    break;
+  }
 
   if (!SourceFile.empty()) {
     if (Opts.PassAsSourceText) {
@@ -803,6 +813,7 @@
       break;
 
     case SourceKitRequest::ProtocolVersion:
+    case SourceKitRequest::Close:
     case SourceKitRequest::Index:
     case SourceKitRequest::CodeComplete:
     case SourceKitRequest::CodeCompleteOpen:
@@ -945,6 +956,8 @@
       case SourceKitRequest::FindLocalRenameRanges:
         printRenameRanges(Info, llvm::outs());
         break;
+      case SourceKitRequest::Statistics:
+        printStatistics(Info, llvm::outs());
     }
   }
 
@@ -1636,6 +1649,18 @@
   OS << "END MANGLE\n";
 }
 
+static void printStatistics(sourcekitd_variant_t Info, raw_ostream &OS) {
+  sourcekitd_variant_t results =
+    sourcekitd_variant_dictionary_get_value(Info, KeyResults);
+  sourcekitd_variant_array_apply(results, ^bool(size_t index, sourcekitd_variant_t value) {
+    auto uid = sourcekitd_variant_dictionary_get_uid(value, KeyKind);
+    auto desc = sourcekitd_variant_dictionary_get_string(value, KeyDescription);
+    auto statValue = sourcekitd_variant_dictionary_get_int64(value, KeyValue);
+    OS << statValue << "\t" << desc << "\t- " << sourcekitd_uid_get_string_ptr(uid) << "\n";
+    return true;
+  });
+}
+
 static void initializeRewriteBuffer(StringRef Input,
                                     clang::RewriteBuffer &RewriteBuf) {
   RewriteBuf.Initialize(Input);
diff --git a/tools/SourceKit/tools/sourcekitd/lib/API/Requests.cpp b/tools/SourceKit/tools/sourcekitd/lib/API/Requests.cpp
index f20d429..35514ef 100644
--- a/tools/SourceKit/tools/sourcekitd/lib/API/Requests.cpp
+++ b/tools/SourceKit/tools/sourcekitd/lib/API/Requests.cpp
@@ -21,6 +21,7 @@
 #include "SourceKit/Core/NotificationCenter.h"
 #include "SourceKit/Support/Concurrency.h"
 #include "SourceKit/Support/Logging.h"
+#include "SourceKit/Support/Statistic.h"
 #include "SourceKit/Support/UIdent.h"
 #include "SourceKit/SwiftLang/Factory.h"
 
@@ -294,6 +295,11 @@
                       ArrayRef<const char *> Args);
 
 void handleRequestImpl(sourcekitd_object_t ReqObj, ResponseReceiver Rec) {
+  // NOTE: if we had a connection context, these stats should move into it.
+  static Statistic numRequests(UIdentFromSKDUID(KindStatNumRequests), "# of requests (total)");
+  static Statistic numSemaRequests(UIdentFromSKDUID(KindStatNumSemaRequests), "# of semantic requests");
+  ++numRequests;
+
   RequestDict Req(ReqObj);
   sourcekitd_uid_t ReqUID = Req.getUID(KeyRequest);
   if (!ReqUID)
@@ -660,6 +666,27 @@
     return Rec(ResponseBuilder().createResponse());
   }
 
+  if (ReqUID == RequestStatistics) {
+    LangSupport &Lang = getGlobalContext().getSwiftLangSupport();
+    Lang.getStatistics([Rec](ArrayRef<Statistic *> stats) {
+      ResponseBuilder builder;
+      auto results = builder.getDictionary().setArray(KeyResults);
+      auto addStat = [&results](Statistic *stat) {
+        auto dict = results.appendDictionary();
+        dict.set(KeyKind, stat->name);
+        dict.set(KeyDescription, stat->description);
+        dict.set(KeyValue, stat->value);
+      };
+
+      addStat(&numRequests);
+      addStat(&numSemaRequests);
+      std::for_each(stats.begin(), stats.end(), addStat);
+
+      Rec(builder.createResponse());
+    });
+    return;
+  }
+
   if (!SourceFile.hasValue() && !SourceText.hasValue() &&
       ReqUID != RequestCodeCompleteUpdate)
     return Rec(createErrorRequestInvalid(
@@ -673,6 +700,7 @@
   static WorkQueue SemaQueue{ WorkQueue::Dequeuing::Concurrent,
                               "sourcekit.request.semantic" };
   sourcekitd_request_retain(ReqObj);
+  ++numSemaRequests;
   SemaQueue.dispatch(
     [ReqObj, Rec, ReqUID, SourceFile, SourceText, Args] {
       RequestDict Req(ReqObj);
diff --git a/utils/swift-project-settings.el b/utils/swift-project-settings.el
index 79ecb57..b7d8957 100644
--- a/utils/swift-project-settings.el
+++ b/utils/swift-project-settings.el
@@ -369,7 +369,7 @@
 
 (defconst swift-project-stdlib-aux-swiftc-args
   (append swift-project-single-frontend-swiftc-args
-          (list "-Xfrontend" "-sil-serialize-all" "-parse-stdlib"))
+          (list "-Xfrontend" "-sil-serialize-witness-tables" "-sil-serialize-vtables" "-parse-stdlib"))
   "swiftc arguments for library components that are compiled as
   though they are part of the standard library even though
   they're not strictly in that binary."  )
diff --git a/validation-test/SIL/Inputs/gen_parse_stdlib_tests.sh b/validation-test/SIL/Inputs/gen_parse_stdlib_tests.sh
index 351b753..6db4953 100755
--- a/validation-test/SIL/Inputs/gen_parse_stdlib_tests.sh
+++ b/validation-test/SIL/Inputs/gen_parse_stdlib_tests.sh
@@ -19,8 +19,8 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
 __EOF__
 
 done
diff --git a/validation-test/SIL/parse_stdlib_0.sil b/validation-test/SIL/parse_stdlib_0.sil
index 8dd0386..4979ca4 100644
--- a/validation-test/SIL/parse_stdlib_0.sil
+++ b/validation-test/SIL/parse_stdlib_0.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_1.sil b/validation-test/SIL/parse_stdlib_1.sil
index 891f74a..b984174 100644
--- a/validation-test/SIL/parse_stdlib_1.sil
+++ b/validation-test/SIL/parse_stdlib_1.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_10.sil b/validation-test/SIL/parse_stdlib_10.sil
index 1233d3c..8af2857 100644
--- a/validation-test/SIL/parse_stdlib_10.sil
+++ b/validation-test/SIL/parse_stdlib_10.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_11.sil b/validation-test/SIL/parse_stdlib_11.sil
index 6c69e51..8c62fd5 100644
--- a/validation-test/SIL/parse_stdlib_11.sil
+++ b/validation-test/SIL/parse_stdlib_11.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_12.sil b/validation-test/SIL/parse_stdlib_12.sil
index d35ec3c..d517ea2 100644
--- a/validation-test/SIL/parse_stdlib_12.sil
+++ b/validation-test/SIL/parse_stdlib_12.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_13.sil b/validation-test/SIL/parse_stdlib_13.sil
index ba53d48..cbe459e 100644
--- a/validation-test/SIL/parse_stdlib_13.sil
+++ b/validation-test/SIL/parse_stdlib_13.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_14.sil b/validation-test/SIL/parse_stdlib_14.sil
index 9573614..bc4c42a 100644
--- a/validation-test/SIL/parse_stdlib_14.sil
+++ b/validation-test/SIL/parse_stdlib_14.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_15.sil b/validation-test/SIL/parse_stdlib_15.sil
index b82685a..762e915 100644
--- a/validation-test/SIL/parse_stdlib_15.sil
+++ b/validation-test/SIL/parse_stdlib_15.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_16.sil b/validation-test/SIL/parse_stdlib_16.sil
index fe32687..0268bee 100644
--- a/validation-test/SIL/parse_stdlib_16.sil
+++ b/validation-test/SIL/parse_stdlib_16.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_2.sil b/validation-test/SIL/parse_stdlib_2.sil
index 52ab68e..cb4a5d1 100644
--- a/validation-test/SIL/parse_stdlib_2.sil
+++ b/validation-test/SIL/parse_stdlib_2.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_3.sil b/validation-test/SIL/parse_stdlib_3.sil
index be8278e..80da211 100644
--- a/validation-test/SIL/parse_stdlib_3.sil
+++ b/validation-test/SIL/parse_stdlib_3.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_4.sil b/validation-test/SIL/parse_stdlib_4.sil
index 01acaaf..4ba5869 100644
--- a/validation-test/SIL/parse_stdlib_4.sil
+++ b/validation-test/SIL/parse_stdlib_4.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_5.sil b/validation-test/SIL/parse_stdlib_5.sil
index 58de6b6..7e2adc0 100644
--- a/validation-test/SIL/parse_stdlib_5.sil
+++ b/validation-test/SIL/parse_stdlib_5.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_6.sil b/validation-test/SIL/parse_stdlib_6.sil
index 5b3ced2..dcc42f8 100644
--- a/validation-test/SIL/parse_stdlib_6.sil
+++ b/validation-test/SIL/parse_stdlib_6.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_7.sil b/validation-test/SIL/parse_stdlib_7.sil
index 4d759bd..eea810c 100644
--- a/validation-test/SIL/parse_stdlib_7.sil
+++ b/validation-test/SIL/parse_stdlib_7.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_8.sil b/validation-test/SIL/parse_stdlib_8.sil
index 1dab138..fb7e59b 100644
--- a/validation-test/SIL/parse_stdlib_8.sil
+++ b/validation-test/SIL/parse_stdlib_8.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322
diff --git a/validation-test/SIL/parse_stdlib_9.sil b/validation-test/SIL/parse_stdlib_9.sil
index cbca5e6..57cb8d0 100644
--- a/validation-test/SIL/parse_stdlib_9.sil
+++ b/validation-test/SIL/parse_stdlib_9.sil
@@ -11,5 +11,5 @@
 // REQUIRES: long_test
 // REQUIRES: nonexecutable_test
 
-// FIXME: Re-enable on Linux when we're no long running out of memory.
-// REQUIRES: OS=macosx
+// FIXME: Re-enable when we're no longer running out of memory.
+// REQUIRES: rdar34771322