Merge pull request #15172 from DougGregor/gsb-weaken-potential-archetypes

[GSB] Reduce dependence on potential archetypes for rewrite tree
diff --git a/include/swift/AST/AttrKind.h b/include/swift/AST/AttrKind.h
index e80c2c6..e67569a 100644
--- a/include/swift/AST/AttrKind.h
+++ b/include/swift/AST/AttrKind.h
@@ -23,7 +23,7 @@
 namespace swift {
 
 /// The associativity of a binary operator.
-enum class Associativity : unsigned char {
+enum class Associativity : uint8_t {
   /// Non-associative operators cannot be written next to other
   /// operators with the same precedence.  Relational operators are
   /// typically non-associative.
diff --git a/include/swift/AST/Builtins.h b/include/swift/AST/Builtins.h
index f12dc48..57578db 100644
--- a/include/swift/AST/Builtins.h
+++ b/include/swift/AST/Builtins.h
@@ -39,7 +39,7 @@
 Type getBuiltinType(ASTContext &Context, StringRef Name);
 
 /// OverloadedBuiltinKind - Whether and how a builtin is overloaded.
-enum class OverloadedBuiltinKind : unsigned char {
+enum class OverloadedBuiltinKind : uint8_t {
   /// The builtin is not overloaded.
   None,
 
diff --git a/include/swift/AST/Decl.h b/include/swift/AST/Decl.h
index f18d160..66d360e 100644
--- a/include/swift/AST/Decl.h
+++ b/include/swift/AST/Decl.h
@@ -3879,7 +3879,7 @@
 };
 
 /// The safety semantics of this addressor.
-enum class AddressorKind : unsigned char {
+enum class AddressorKind : uint8_t {
   /// \brief This is not an addressor.
   NotAddressor,
   /// \brief This is an unsafe addressor; it simply returns an address.
@@ -3896,7 +3896,7 @@
 };
 
 /// Whether an access to storage is for reading, writing, or both.
-enum class AccessKind : unsigned char {
+enum class AccessKind : uint8_t {
   /// The access is just to read the current value.
   Read,
 
@@ -3908,11 +3908,11 @@
 };
 
 /// The way to actually evaluate an access to storage.
-enum class AccessStrategy : unsigned char {
+enum class AccessStrategy : uint8_t {
   /// The decl is a VarDecl with its own backing storage; evaluate its
   /// address directly.
   Storage,
-  
+
   /// The decl is a VarDecl with storage defined by a property behavior;
   /// this access may initialize or reassign the storage based on dataflow.
   BehaviorStorage,
diff --git a/include/swift/AST/Expr.h b/include/swift/AST/Expr.h
index 0e38da3..c6be668 100644
--- a/include/swift/AST/Expr.h
+++ b/include/swift/AST/Expr.h
@@ -104,7 +104,7 @@
   Last_CheckedCastKind = Swift3BridgingDowncast,
 };
 
-enum class AccessSemantics : unsigned char {
+enum class AccessSemantics : uint8_t {
   /// On a property or subscript reference, this is a direct access to
   /// the underlying storage.  On a function reference, this is a
   /// non-polymorphic access to a particular implementation.
@@ -113,7 +113,7 @@
   /// On a property or subscript reference, this is a direct,
   /// non-polymorphic access to the getter/setter accessors.
   DirectToAccessor,
-  
+
   /// On a property or subscript reference, this is an access to a property
   /// behavior that may be an initialization. Reads always go through the
   /// 'get' accessor on the property. Writes may go through the 'init' or
diff --git a/include/swift/AST/LayoutConstraint.h b/include/swift/AST/LayoutConstraint.h
index 961fa8a..12b5980 100644
--- a/include/swift/AST/LayoutConstraint.h
+++ b/include/swift/AST/LayoutConstraint.h
@@ -31,7 +31,7 @@
 class ASTPrinter;
 
 /// Describes a layout constraint information.
-enum class LayoutConstraintKind : unsigned char {
+enum class LayoutConstraintKind : uint8_t {
   // It is not a known layout constraint.
   UnknownLayout,
   // It is a layout constraint representing a trivial type of an unknown size.
diff --git a/include/swift/AST/Types.h b/include/swift/AST/Types.h
index b57ee74..0c81278 100644
--- a/include/swift/AST/Types.h
+++ b/include/swift/AST/Types.h
@@ -2367,7 +2367,7 @@
 END_CAN_TYPE_WRAPPER(DynamicSelfType, Type)
 
 /// A language-level calling convention.
-enum class SILFunctionLanguage : unsigned char {
+enum class SILFunctionLanguage : uint8_t {
   /// A variation of the Swift calling convention.
   Swift = 0,
 
diff --git a/include/swift/Basic/PrettyStackTrace.h b/include/swift/Basic/PrettyStackTrace.h
index b7e3f42..036bdfa 100644
--- a/include/swift/Basic/PrettyStackTrace.h
+++ b/include/swift/Basic/PrettyStackTrace.h
@@ -16,6 +16,10 @@
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/ADT/StringRef.h"
 
+namespace llvm {
+  class MemoryBuffer;
+}
+
 namespace swift {
 
 /// A PrettyStackTraceEntry for performing an action involving a StringRef.
@@ -31,6 +35,15 @@
   void print(llvm::raw_ostream &OS) const override;
 };
 
+/// A PrettyStackTraceEntry to dump the contents of a file.
+class PrettyStackTraceFileContents : public llvm::PrettyStackTraceEntry {
+  const llvm::MemoryBuffer &Buffer;
+public:
+  explicit PrettyStackTraceFileContents(const llvm::MemoryBuffer &buffer)
+    : Buffer(buffer) {}
+  void print(llvm::raw_ostream &OS) const override;
+};
+
 } // end namespace swift
 
 #endif // SWIFT_BASIC_PRETTYSTACKTRACE_H
diff --git a/include/swift/Demangling/ManglingMacros.h b/include/swift/Demangling/ManglingMacros.h
index f3e09b4..9c35415 100644
--- a/include/swift/Demangling/ManglingMacros.h
+++ b/include/swift/Demangling/ManglingMacros.h
@@ -34,6 +34,8 @@
 #define METADATA_MANGLING N
 #define METATYPE_MANGLING m
 #define EMPTY_TUPLE_MANGLING yt
+#define ANY_MANGLING yp
+#define ANYOBJECT_MANGLING yXl
 #define NO_ARGS_MANGLING yy
 #define FUNC_TYPE_MANGLING c
 #define NOESCAPE_FUNC_TYPE_MANGLING XE
diff --git a/include/swift/Frontend/ArgsToFrontendInputsConverter.h b/include/swift/Frontend/ArgsToFrontendInputsConverter.h
index d2afd97..f6b1e03 100644
--- a/include/swift/Frontend/ArgsToFrontendInputsConverter.h
+++ b/include/swift/Frontend/ArgsToFrontendInputsConverter.h
@@ -42,21 +42,28 @@
 class ArgsToFrontendInputsConverter {
   DiagnosticEngine &Diags;
   const llvm::opt::ArgList &Args;
-  FrontendInputsAndOutputs &InputsAndOutputs;
 
   llvm::opt::Arg const *const FilelistPathArg;
   llvm::opt::Arg const *const PrimaryFilelistPathArg;
 
-  SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 4> BuffersToKeepAlive;
+  /// A place to keep alive any buffers that are loaded as part of setting up
+  /// the frontend inputs.
+  SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 4> ConfigurationFileBuffers;
 
   llvm::SetVector<StringRef> Files;
 
 public:
   ArgsToFrontendInputsConverter(DiagnosticEngine &diags,
-                                const llvm::opt::ArgList &args,
-                                FrontendInputsAndOutputs &inputsAndOutputs);
+                                const llvm::opt::ArgList &args);
 
-  bool convert();
+  /// Produces a FrontendInputsAndOutputs object with the inputs populated from
+  /// the arguments the converter was initialized with.
+  ///
+  /// \param buffers If present, buffers read in the processing of the frontend
+  /// inputs will be saved here. These should only be used for debugging
+  /// purposes.
+  Optional<FrontendInputsAndOutputs> convert(
+      SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>> *buffers);
 
 private:
   bool enforceFilelistExclusion();
@@ -66,11 +73,19 @@
                              llvm::function_ref<void(StringRef)> fn);
   bool addFile(StringRef file);
   Optional<std::set<StringRef>> readPrimaryFiles();
-  std::set<StringRef>
-  createInputFilesConsumingPrimaries(std::set<StringRef> primaryFiles);
-  bool checkForMissingPrimaryFiles(std::set<StringRef> primaryFiles);
 
-  bool isSingleThreadedWMO() const;
+  /// Returns the newly set-up FrontendInputsAndOutputs, as well as a set of
+  /// any unused primary files (those that do not correspond to an input).
+  std::pair<FrontendInputsAndOutputs, std::set<StringRef>>
+  createInputFilesConsumingPrimaries(std::set<StringRef> primaryFiles);
+
+  /// Emits an error for each file in \p unusedPrimaryFiles.
+  ///
+  /// \returns true if \p unusedPrimaryFiles is non-empty.
+  bool diagnoseUnusedPrimaryFiles(std::set<StringRef> unusedPrimaryFiles);
+
+  bool
+  isSingleThreadedWMO(const FrontendInputsAndOutputs &inputsAndOutputs) const;
 };
 
 } // namespace swift
diff --git a/include/swift/Frontend/ArgsToFrontendOptionsConverter.h b/include/swift/Frontend/ArgsToFrontendOptionsConverter.h
index e418c1a..dc37ab9d 100644
--- a/include/swift/Frontend/ArgsToFrontendOptionsConverter.h
+++ b/include/swift/Frontend/ArgsToFrontendOptionsConverter.h
@@ -69,7 +69,13 @@
                                  FrontendOptions &Opts)
       : Diags(Diags), Args(Args), Opts(Opts) {}
 
-  bool convert();
+  /// Populates the FrontendOptions the converter was initialized with.
+  ///
+  /// \param buffers If present, buffers read in the processing of the frontend
+  /// options will be saved here. These should only be used for debugging
+  /// purposes.
+  bool convert(
+      SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>> *buffers);
 
   static FrontendOptions::ActionType
   determineRequestedAction(const llvm::opt::ArgList &);
diff --git a/include/swift/Frontend/Frontend.h b/include/swift/Frontend/Frontend.h
index 46aef96..a1f59ae 100644
--- a/include/swift/Frontend/Frontend.h
+++ b/include/swift/Frontend/Frontend.h
@@ -86,11 +86,19 @@
   /// default values given the /absence/ of a flag. This is because \c parseArgs
   /// may be used to modify an already partially configured invocation.
   ///
+  /// Any configuration files loaded as a result of parsing arguments will be
+  /// stored in \p ConfigurationFileBuffers, if non-null. The contents of these
+  /// buffers should \e not be interpreted by the caller; they are only present
+  /// in order to make it possible to reproduce how these arguments were parsed
+  /// if the compiler ends up crashing or exhibiting other bad behavior.
+  ///
   /// If non-empty, relative search paths are resolved relative to
   /// \p workingDirectory.
   ///
   /// \returns true if there was an error, false on success.
   bool parseArgs(ArrayRef<const char *> Args, DiagnosticEngine &Diags,
+                 SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>>
+                     *ConfigurationFileBuffers = nullptr,
                  StringRef workingDirectory = {});
 
   /// Sets specific options based on the given serialized Swift binary data.
diff --git a/include/swift/Parse/Lexer.h b/include/swift/Parse/Lexer.h
index 9440aa6..2825ab4 100644
--- a/include/swift/Parse/Lexer.h
+++ b/include/swift/Parse/Lexer.h
@@ -459,14 +459,6 @@
     return BufferStart + SourceMgr.getLocOffsetInBuffer(Loc, BufferID);
   }
 
-  StringRef getSubstring(const char *Start, unsigned Length) const {
-    assert(Start >= BufferStart && Start <= BufferEnd);
-    unsigned BytesUntilBufferEnd = BufferEnd - Start;
-    if (Length > BytesUntilBufferEnd)
-      Length = BytesUntilBufferEnd;
-    return StringRef(Start, Length);
-  }
-
   void lexImpl();
   InFlightDiagnostic diagnose(const char *Loc, Diagnostic Diag);
   
diff --git a/include/swift/Parse/Parser.h b/include/swift/Parse/Parser.h
index 9759253..19891ae 100644
--- a/include/swift/Parse/Parser.h
+++ b/include/swift/Parse/Parser.h
@@ -276,7 +276,7 @@
   /// Describes the kind of a lexical structure marker, indicating
   /// what kind of structural element we started parsing at a
   /// particular location.
-  enum class StructureMarkerKind : unsigned char {
+  enum class StructureMarkerKind : uint8_t {
     /// The start of a declaration.
     Declaration,
     /// The start of a statement.
diff --git a/include/swift/Remote/MetadataReader.h b/include/swift/Remote/MetadataReader.h
index a331b43..cbf3f05 100644
--- a/include/swift/Remote/MetadataReader.h
+++ b/include/swift/Remote/MetadataReader.h
@@ -284,7 +284,6 @@
         return BuiltType();
       return readNominalTypeFromMetadata(Meta, skipArtificialSubclasses);
     case MetadataKind::Struct:
-      return readNominalTypeFromMetadata(Meta);
     case MetadataKind::Enum:
     case MetadataKind::Optional:
       return readNominalTypeFromMetadata(Meta);
@@ -419,16 +418,20 @@
       return BuiltExist;
     }
     case MetadataKind::ForeignClass: {
-      auto Foreign = cast<TargetForeignClassMetadata<Runtime>>(Meta);
+      auto descriptorAddr = readAddressOfNominalTypeDescriptor(Meta);
+      if (!descriptorAddr)
+        return BuiltType();
+      auto descriptor = readContextDescriptor(descriptorAddr);
+      if (!descriptor)
+        return BuiltType();
 
-      StoredPointer namePtr =
-        resolveRelativeField(Meta,
-                             asFullMetadata(Foreign)->Name);
-      if (namePtr == 0)
+      // Build the demangling tree from the context tree.
+      Demangle::NodeFactory nodeFactory;
+      auto node = buildNominalTypeMangling(descriptor, nodeFactory);
+      if (!node)
         return BuiltType();
-      std::string name;
-      if (!Reader->readString(RemoteAddress(namePtr), name))
-        return BuiltType();
+
+      auto name = Demangle::mangleNode(node);
       auto BuiltForeign = Builder.createForeignClassType(std::move(name));
       TypeCache[MetadataAddress] = BuiltForeign;
       return BuiltForeign;
@@ -1006,6 +1009,11 @@
       auto valueMeta = cast<TargetValueMetadata<Runtime>>(metadata);
       return valueMeta->getDescription();
     }
+        
+    case MetadataKind::ForeignClass: {
+      auto foreignMeta = cast<TargetForeignClassMetadata<Runtime>>(metadata);
+      return foreignMeta->Description;
+    }
 
     default:
       return 0;
diff --git a/include/swift/Runtime/Metadata.h b/include/swift/Runtime/Metadata.h
index 12d4515..9253e8c 100644
--- a/include/swift/Runtime/Metadata.h
+++ b/include/swift/Runtime/Metadata.h
@@ -1612,21 +1612,11 @@
     /// flag is set.
     RelativeDirectPointer<InitializationFunction_t> InitializationFunction;
     
-    /// The uniquing key for the metadata record. Metadata records with the
-    /// same Name string are considered equivalent by the runtime, and the
-    /// runtime will pick one to be canonical.
-    RelativeDirectPointer<const char> Name;
-
     mutable std::atomic<CacheValue> Cache;
   };
 
   struct HeaderType : HeaderPrefix, TargetTypeMetadataHeader<Runtime> {};
 
-  TargetPointer<Runtime, const char> getName() const {
-    return reinterpret_cast<TargetPointer<Runtime, const char>>(
-      asFullMetadata(this)->Name.get());
-  }
-
   CacheValue getCacheValue() const {
     /// NB: This can be a relaxed-order load if there is no initialization
     /// function. On platforms Swift currently targets, consume is no more
@@ -1941,7 +1931,7 @@
   FullMetadata<TupleTypeMetadata> METADATA_SYM(EMPTY_TUPLE_MANGLING);
 
 template <typename Runtime> struct TargetProtocolDescriptor;
-  
+
 /// An array of protocol descriptors with a header and tail-allocated elements.
 template <typename Runtime>
 struct TargetProtocolDescriptorList {
@@ -2131,6 +2121,10 @@
     : TargetMetadata<Runtime>(MetadataKind::Existential),
       Flags(ExistentialTypeFlags()), Protocols() {}
   
+  explicit constexpr TargetExistentialTypeMetadata(ExistentialTypeFlags Flags)
+    : TargetMetadata<Runtime>(MetadataKind::Existential),
+      Flags(Flags), Protocols() {}
+
   /// Get the representation form this existential type uses.
   ExistentialTypeRepresentation getRepresentation() const;
   
@@ -2192,6 +2186,17 @@
 using ExistentialTypeMetadata
   = TargetExistentialTypeMetadata<InProcess>;
 
+/// The standard metadata for the empty protocol composition type, Any.
+SWIFT_RUNTIME_EXPORT
+const
+  FullMetadata<ExistentialTypeMetadata> METADATA_SYM(ANY_MANGLING);
+
+/// The standard metadata for the empty class-constrained protocol composition
+/// type, AnyObject.
+SWIFT_RUNTIME_EXPORT
+const
+  FullMetadata<ExistentialTypeMetadata> METADATA_SYM(ANYOBJECT_MANGLING);
+
 /// The basic layout of an existential metatype type.
 template <typename Runtime>
 struct TargetExistentialMetatypeContainer {
@@ -2654,7 +2659,7 @@
 
 template<typename Runtime>
 struct TargetGenericContextDescriptorHeader {
-  uint32_t NumParams, NumRequirements, NumKeyArguments, NumExtraArguments;
+  uint16_t NumParams, NumRequirements, NumKeyArguments, NumExtraArguments;
   
   uint32_t getNumArguments() const {
     return NumKeyArguments + NumExtraArguments;
diff --git a/include/swift/SIL/Consumption.h b/include/swift/SIL/Consumption.h
index 56921e8..b279ef8 100644
--- a/include/swift/SIL/Consumption.h
+++ b/include/swift/SIL/Consumption.h
@@ -30,7 +30,7 @@
 enum IsInitialization_t : bool { IsNotInitialization, IsInitialization };
 
 /// The behavior of a dynamic cast operation on the source value.
-enum class CastConsumptionKind : unsigned char {
+enum class CastConsumptionKind : uint8_t {
   /// The source value is always taken, regardless of whether the cast
   /// succeeds.  That is, if the cast fails, the source value is
   /// destroyed.
diff --git a/include/swift/SIL/SILLinkage.h b/include/swift/SIL/SILLinkage.h
index 47008dd..6559bb7 100644
--- a/include/swift/SIL/SILLinkage.h
+++ b/include/swift/SIL/SILLinkage.h
@@ -29,7 +29,7 @@
 /// first does not, perhaps by reading a value out of it (and then
 /// ignoring the result) or retaining it (and then releasing it
 /// later).
-enum class SILLinkage : unsigned char {
+enum class SILLinkage : uint8_t {
   /// This object definition is visible to multiple Swift modules (and
   /// thus potentially across linkage-unit boundaries).  There are no
   /// other object definitions with this name in the program.
@@ -79,7 +79,7 @@
   /// module. Besides that caveat this should be treated exactly the same as
   /// shared.
   SharedExternal,
-  
+
   /// The same as SharedExternal, except that the definition is private in the
   /// other module. This can only occur if an inlined fragile function from
   /// another module references a private definition in the other module.
@@ -109,7 +109,7 @@
 };
 
 /// The scope in which a subclassable class can be subclassed.
-enum class SubclassScope : unsigned char {
+enum class SubclassScope : uint8_t {
   /// This class can be subclassed in other modules.
   External,
 
diff --git a/lib/AST/ConformanceLookupTable.h b/lib/AST/ConformanceLookupTable.h
index 3a08deb..18f93d3 100644
--- a/lib/AST/ConformanceLookupTable.h
+++ b/lib/AST/ConformanceLookupTable.h
@@ -42,7 +42,7 @@
 class ConformanceLookupTable {
   /// Describes the stage at which a particular nominal type or
   /// extension's conformances has been processed.
-  enum class ConformanceStage : unsigned char {
+  enum class ConformanceStage : uint8_t {
     /// The explicit conformances have been recorded in the lookup table.
     RecordedExplicit,
 
diff --git a/lib/Basic/PrettyStackTrace.cpp b/lib/Basic/PrettyStackTrace.cpp
index 16927a6..a7673b5 100644
--- a/lib/Basic/PrettyStackTrace.cpp
+++ b/lib/Basic/PrettyStackTrace.cpp
@@ -17,6 +17,7 @@
 
 #include "swift/Basic/PrettyStackTrace.h"
 #include "swift/Basic/QuotedString.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace swift;
@@ -24,3 +25,11 @@
 void PrettyStackTraceStringAction::print(llvm::raw_ostream &out) const {
   out << "While " << Action << ' ' << QuotedString(TheString) << '\n';
 }
+
+void PrettyStackTraceFileContents::print(llvm::raw_ostream &out) const {
+  out << "Contents of " << Buffer.getBufferIdentifier() << ":\n---\n"
+      << Buffer.getBuffer();
+  if (!Buffer.getBuffer().endswith("\n"))
+    out << '\n';
+  out << "---\n";
+}
diff --git a/lib/Demangling/Demangler.cpp b/lib/Demangling/Demangler.cpp
index ae82735..dcb6640 100644
--- a/lib/Demangling/Demangler.cpp
+++ b/lib/Demangling/Demangler.cpp
@@ -2103,10 +2103,16 @@
                                 Conf, AssocTypePath, ProtoTy);
     }
     case 'y': {
+      if (auto sig = popNode(Node::Kind::DependentGenericSignature))
+        return createWithChildren(Node::Kind::OutlinedCopy,
+                                  popNode(Node::Kind::Type), sig);
       return createWithChild(Node::Kind::OutlinedCopy,
                              popNode(Node::Kind::Type));
     }
     case 'e': {
+      if (auto sig = popNode(Node::Kind::DependentGenericSignature))
+        return createWithChildren(Node::Kind::OutlinedCopy,
+                                  popNode(Node::Kind::Type), sig);
       return createWithChild(Node::Kind::OutlinedConsume,
                              popNode(Node::Kind::Type));
     }
diff --git a/lib/Demangling/NodePrinter.cpp b/lib/Demangling/NodePrinter.cpp
index f1620f7..14bb8b0 100644
--- a/lib/Demangling/NodePrinter.cpp
+++ b/lib/Demangling/NodePrinter.cpp
@@ -892,10 +892,14 @@
   case Node::Kind::OutlinedCopy:
     Printer << "outlined copy of ";
     print(Node->getChild(0));
+    if (Node->getNumChildren() > 1)
+      print(Node->getChild(1));
     return nullptr;
   case Node::Kind::OutlinedConsume:
     Printer << "outlined consume of ";
     print(Node->getChild(0));
+    if (Node->getNumChildren() > 1)
+      print(Node->getChild(1));
     return nullptr;
   case Node::Kind::OutlinedRetain:
     Printer << "outlined retain of ";
diff --git a/lib/Demangling/Remangler.cpp b/lib/Demangling/Remangler.cpp
index 0090b6b..8c89cb1 100644
--- a/lib/Demangling/Remangler.cpp
+++ b/lib/Demangling/Remangler.cpp
@@ -1837,12 +1837,12 @@
 }
 
 void Remangler::mangleOutlinedCopy(Node *node) {
-  mangleSingleChildNode(node);
+  mangleChildNodes(node);
   Buffer << "Wy";
 }
 
 void Remangler::mangleOutlinedConsume(Node *node) {
-  mangleSingleChildNode(node);
+  mangleChildNodes(node);
   Buffer << "We";
 }
 
diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp
index 78107c0..c0c882b 100644
--- a/lib/Driver/Compilation.cpp
+++ b/lib/Driver/Compilation.cpp
@@ -15,6 +15,7 @@
 #include "swift/AST/DiagnosticEngine.h"
 #include "swift/AST/DiagnosticsDriver.h"
 #include "swift/Basic/Program.h"
+#include "swift/Basic/STLExtras.h"
 #include "swift/Basic/Statistic.h"
 #include "swift/Basic/TaskQueue.h"
 #include "swift/Basic/Version.h"
@@ -724,31 +725,31 @@
         Batches.push_back(Comp.addJob(std::move(J)));
     }
 
-    /// Inspect current batch \p i of the \p Partition currently being built
-    /// and, if that batch is "full" (in the sense of holding an evenly-divided
-    /// portion of NumJobs) then advance \p i to the next batch index in the
-    /// partition.
-    void maybeAdvanceToNextPartition(size_t &i,
-                                     BatchPartition const &Partition,
-                                     size_t NumJobs) {
-      assert(i < Partition.size());
-      size_t Remainder = NumJobs % Partition.size();
-      size_t TargetSize = NumJobs / Partition.size();
-      // Spread remainder evenly across partitions by adding 1 to the target
-      // size of the first Remainder of them.
-      if (i < Remainder)
-        TargetSize++;
-      if (Partition[i].size() >= TargetSize)
-        ++i;
-      assert(i < Partition.size());
-    }
-
-    /// Shuffle \p Batchable if -driver-batch-seed is nonzero.
-    void maybeShuffleBatchable(std::vector<const Job *> &Batchable) {
+    /// Build a vector of partition indices, one per Job: the i'th index says
+    /// which batch of the partition the i'th Job will be assigned to. If we are
+    /// shuffling due to -driver-batch-seed, the returned indices will not be
+    /// arranged in contiguous runs. We shuffle partition-indices here, not
+    /// elements themselves, to preserve the invariant that each batch is a
+    /// subsequence of the full set of inputs, not just a subset.
+    std::vector<size_t>
+    assignJobsToPartitions(size_t PartitionSize,
+                           size_t NumJobs) {
+      size_t Remainder = NumJobs % PartitionSize;
+      size_t TargetSize = NumJobs / PartitionSize;
+      std::vector<size_t> PartitionIndex;
+      PartitionIndex.reserve(NumJobs);
+      for (size_t P = 0; P < PartitionSize; ++P) {
+        // Spread remainder evenly across partitions by adding 1 to the target
+        // size of the first Remainder of them.
+        size_t FillCount = TargetSize + ((P < Remainder) ? 1 : 0);
+        std::fill_n(std::back_inserter(PartitionIndex), FillCount, P);
+      }
       if (Comp.BatchSeed != 0) {
         std::minstd_rand gen(Comp.BatchSeed);
-        std::shuffle(Batchable.begin(), Batchable.end(), gen);
+        std::shuffle(PartitionIndex.begin(), PartitionIndex.end(), gen);
       }
+      assert(PartitionIndex.size() == NumJobs);
+      return PartitionIndex;
     }
 
     /// Create \c NumberOfParallelCommands batches and assign each job to a
@@ -762,28 +763,28 @@
       }
 
       assert(!Partition.empty());
-      maybeShuffleBatchable(Batchable);
-
-      size_t i = 0;
+      auto PartitionIndex = assignJobsToPartitions(Partition.size(),
+                                                   Batchable.size());
+      assert(PartitionIndex.size() == Batchable.size());
       auto const &TC = Comp.getToolChain();
-      for (const Job *Cmd : Batchable) {
-        maybeAdvanceToNextPartition(i, Partition, Batchable.size());
-        std::vector<const Job*> &P = Partition[i];
-        if (P.empty() || TC.jobsAreBatchCombinable(Comp, P[0], Cmd)) {
-          if (Comp.ShowJobLifecycle)
-            llvm::outs() << "Adding " << LogJob(Cmd)
-                         << " to batch " << i << '\n';
-          P.push_back(Cmd);
-        } else {
-          // Strange but theoretically possible that we have a batchable job
-          // that's not combinable with others; tack a new batch on for it.
-          if (Comp.ShowJobLifecycle)
-            llvm::outs() << "Adding " << LogJob(Cmd)
-                         << " to new batch " << Partition.size() << '\n';
-          Partition.push_back(std::vector<const Job*>());
-          Partition.back().push_back(Cmd);
-        }
-      }
+      for_each(Batchable, PartitionIndex, [&](const Job *Cmd, size_t Idx) {
+          assert(Idx < Partition.size());
+          std::vector<const Job*> &P = Partition[Idx];
+          if (P.empty() || TC.jobsAreBatchCombinable(Comp, P[0], Cmd)) {
+            if (Comp.ShowJobLifecycle)
+              llvm::outs() << "Adding " << LogJob(Cmd)
+                           << " to batch " << Idx << '\n';
+            P.push_back(Cmd);
+          } else {
+            // Strange but theoretically possible that we have a batchable job
+            // that's not combinable with others; tack a new batch on for it.
+            if (Comp.ShowJobLifecycle)
+              llvm::outs() << "Adding " << LogJob(Cmd)
+                           << " to new batch " << Partition.size() << '\n';
+            Partition.push_back(std::vector<const Job*>());
+            Partition.back().push_back(Cmd);
+          }
+        });
     }
 
     // FIXME: at the moment we're not passing OutputFileMaps to frontends, so
diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp
index ec93a55..9e4997d 100644
--- a/lib/Driver/ToolChain.cpp
+++ b/lib/Driver/ToolChain.cpp
@@ -280,6 +280,35 @@
   return false;
 }
 
+/// Debugging only: return whether the set of \p jobs is an ordered subsequence
+/// of the sequence of top-level input files in the \c Compilation \p C.
+static bool
+jobsAreSubsequenceOfCompilationInputs(ArrayRef<const Job *> jobs,
+                                      Compilation &C) {
+  llvm::SmallVector<const Job *, 16> sortedJobs;
+  llvm::StringMap<const Job *> jobsByInput;
+  for (const Job *J : jobs) {
+    const CompileJobAction *CJA = cast<CompileJobAction>(&J->getSource());
+    const InputAction* IA = findSingleSwiftInput(CJA);
+    auto R = jobsByInput.insert(std::make_pair(IA->getInputArg().getValue(),
+                                               J));
+    assert(R.second);
+  }
+  for (const InputPair &P : C.getInputFiles()) {
+    auto I = jobsByInput.find(P.second->getValue());
+    if (I != jobsByInput.end()) {
+      sortedJobs.push_back(I->second);
+    }
+  }
+  if (sortedJobs.size() != jobs.size())
+    return false;
+  for (size_t i = 0; i < sortedJobs.size(); ++i) {
+    if (sortedJobs[i] != jobs[i])
+      return false;
+  }
+  return true;
+}
+
 /// Construct a \c BatchJob by merging the constituent \p jobs' CommandOutput,
 /// input \c Job and \c Action members. Call through to \c constructInvocation
 /// on \p BatchJob, to build the \c InvocationInfo.
@@ -287,17 +316,11 @@
 ToolChain::constructBatchJob(ArrayRef<const Job *> jobs,
                              Compilation &C) const
 {
-#ifndef NDEBUG
-  // Verify that the equivalence relation on the jobs also holds pairwise.
-  for (auto *A : jobs) {
-    for (auto *B : jobs) {
-      assert(jobsAreBatchCombinable(C, A, B));
-    }
-  }
-#endif
   if (jobs.empty())
     return nullptr;
 
+  assert(jobsAreSubsequenceOfCompilationInputs(jobs, C));
+
   // Synthetic OutputInfo is a slightly-modified version of the initial
   // compilation's OI.
   auto OI = C.getOutputInfo();
diff --git a/lib/Frontend/ArgsToFrontendInputsConverter.cpp b/lib/Frontend/ArgsToFrontendInputsConverter.cpp
index ceb6f2e..3fc47cb 100644
--- a/lib/Frontend/ArgsToFrontendInputsConverter.cpp
+++ b/lib/Frontend/ArgsToFrontendInputsConverter.cpp
@@ -13,6 +13,7 @@
 #include "swift/Frontend/ArgsToFrontendInputsConverter.h"
 
 #include "swift/AST/DiagnosticsFrontend.h"
+#include "swift/Basic/Defer.h"
 #include "swift/Frontend/ArgsToFrontendOutputsConverter.h"
 #include "swift/Frontend/FrontendOptions.h"
 #include "swift/Option/Options.h"
@@ -30,33 +31,47 @@
 using namespace llvm::opt;
 
 ArgsToFrontendInputsConverter::ArgsToFrontendInputsConverter(
-    DiagnosticEngine &diags, const ArgList &args,
-    FrontendInputsAndOutputs &inputsAndOutputs)
-    : Diags(diags), Args(args), InputsAndOutputs(inputsAndOutputs),
+    DiagnosticEngine &diags, const ArgList &args)
+    : Diags(diags), Args(args),
       FilelistPathArg(args.getLastArg(options::OPT_filelist)),
       PrimaryFilelistPathArg(args.getLastArg(options::OPT_primary_filelist)) {}
 
-bool ArgsToFrontendInputsConverter::convert() {
+Optional<FrontendInputsAndOutputs> ArgsToFrontendInputsConverter::convert(
+    SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>> *buffers) {
+  SWIFT_DEFER {
+    if (buffers) {
+      std::move(ConfigurationFileBuffers.begin(),
+                ConfigurationFileBuffers.end(),
+                std::back_inserter(*buffers));
+      // Clearing the original list of buffers isn't strictly necessary, but
+      // makes the behavior more sensible if we were to call convert() again.
+      ConfigurationFileBuffers.clear();
+    }
+  };
+
   if (enforceFilelistExclusion())
-    return true;
+    return None;
+
   if (FilelistPathArg ? readInputFilesFromFilelist()
                       : readInputFilesFromCommandLine())
-    return true;
+    return None;
   Optional<std::set<StringRef>> primaryFiles = readPrimaryFiles();
   if (!primaryFiles)
-    return true;
-  std::set<StringRef> unusedPrimaryFiles =
+    return None;
+
+  FrontendInputsAndOutputs result;
+  std::set<StringRef> unusedPrimaryFiles;
+  std::tie(result, unusedPrimaryFiles) =
       createInputFilesConsumingPrimaries(*primaryFiles);
 
-  if (checkForMissingPrimaryFiles(unusedPrimaryFiles))
-    return true;
+  if (diagnoseUnusedPrimaryFiles(unusedPrimaryFiles))
+    return None;
 
   // Must be set before iterating over inputs needing outputs.
-  InputsAndOutputs.setIsSingleThreadedWMO(isSingleThreadedWMO());
-
-  InputsAndOutputs.setBypassBatchModeChecks(
+  result.setBypassBatchModeChecks(
       Args.hasArg(options::OPT_bypass_batch_mode_checks));
-  return false;
+
+  return std::move(result);
 }
 
 bool ArgsToFrontendInputsConverter::enforceFilelistExclusion() {
@@ -114,7 +129,7 @@
        llvm::make_range(llvm::line_iterator(*filelistBufferOrError->get()),
                         llvm::line_iterator()))
     fn(file);
-  BuffersToKeepAlive.push_back(std::move(*filelistBufferOrError));
+  ConfigurationFileBuffers.push_back(std::move(*filelistBufferOrError));
   return false;
 }
 
@@ -137,34 +152,38 @@
   return primaryFiles;
 }
 
-std::set<StringRef>
+std::pair<FrontendInputsAndOutputs, std::set<StringRef>>
 ArgsToFrontendInputsConverter::createInputFilesConsumingPrimaries(
     std::set<StringRef> primaryFiles) {
+  bool hasAnyPrimaryFiles = !primaryFiles.empty();
+
+  FrontendInputsAndOutputs result;
   for (auto &file : Files) {
     bool isPrimary = primaryFiles.count(file) > 0;
-    InputsAndOutputs.addInput(InputFile(file, isPrimary));
+    result.addInput(InputFile(file, isPrimary));
     if (isPrimary)
       primaryFiles.erase(file);
   }
-  return primaryFiles;
+
+  if (!Files.empty() && !hasAnyPrimaryFiles) {
+    Optional<std::vector<std::string>> userSuppliedNamesOrErr =
+        OutputFilesComputer::getOutputFilenamesFromCommandLineOrFilelist(Args,
+                                                                         Diags);
+    if (userSuppliedNamesOrErr && userSuppliedNamesOrErr->size() == 1)
+      result.setIsSingleThreadedWMO(true);
+  }
+
+  return {std::move(result), std::move(primaryFiles)};
 }
 
-bool ArgsToFrontendInputsConverter::checkForMissingPrimaryFiles(
+bool ArgsToFrontendInputsConverter::diagnoseUnusedPrimaryFiles(
     std::set<StringRef> primaryFiles) {
   for (auto &file : primaryFiles) {
     // Catch "swiftc -frontend -c -filelist foo -primary-file
     // some-file-not-in-foo".
-    assert(FilelistPathArg && "Missing primary with no filelist");
+    assert(FilelistPathArg && "Unused primary with no filelist");
     Diags.diagnose(SourceLoc(), diag::error_primary_file_not_found, file,
                    FilelistPathArg->getValue());
   }
   return !primaryFiles.empty();
 }
-
-bool ArgsToFrontendInputsConverter::isSingleThreadedWMO() const {
-  Optional<std::vector<std::string>> userSuppliedNamesOrErr =
-      OutputFilesComputer::getOutputFilenamesFromCommandLineOrFilelist(Args,
-                                                                       Diags);
-  return InputsAndOutputs.hasInputs() && !InputsAndOutputs.hasPrimaryInputs() &&
-         userSuppliedNamesOrErr && userSuppliedNamesOrErr->size() == 1;
-}
diff --git a/lib/Frontend/ArgsToFrontendOptionsConverter.cpp b/lib/Frontend/ArgsToFrontendOptionsConverter.cpp
index 697f015..07024f4 100644
--- a/lib/Frontend/ArgsToFrontendOptionsConverter.cpp
+++ b/lib/Frontend/ArgsToFrontendOptionsConverter.cpp
@@ -45,7 +45,8 @@
 LLVM_ATTRIBUTE_NOINLINE
 static void debugFailWithCrash() { LLVM_BUILTIN_TRAP; }
 
-bool ArgsToFrontendOptionsConverter::convert() {
+bool ArgsToFrontendOptionsConverter::convert(
+    SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>> *buffers) {
   using namespace options;
 
   handleDebugCrashGroupArguments();
@@ -93,9 +94,11 @@
 
   computeDumpScopeMapLocations();
 
-  if (ArgsToFrontendInputsConverter(Diags, Args, Opts.InputsAndOutputs)
-          .convert())
+  Optional<FrontendInputsAndOutputs> inputsAndOutputs =
+      ArgsToFrontendInputsConverter(Diags, Args).convert(buffers);
+  if (!inputsAndOutputs)
     return true;
+  Opts.InputsAndOutputs = std::move(inputsAndOutputs).getValue();
 
   Opts.RequestedAction = determineRequestedAction(Args);
 
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index b522760..c1b0790 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -81,9 +81,11 @@
   llvm_unreachable("Unhandled InputFileKind in switch.");
 }
 
-static bool ParseFrontendArgs(FrontendOptions &opts, ArgList &args,
-                              DiagnosticEngine &diags) {
-  return ArgsToFrontendOptionsConverter(diags, args, opts).convert();
+static bool ParseFrontendArgs(
+    FrontendOptions &opts, ArgList &args, DiagnosticEngine &diags,
+    SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>> *buffers) {
+  ArgsToFrontendOptionsConverter converter(diags, args, opts);
+  return converter.convert(buffers);
 }
 
 static void diagnoseSwiftVersion(Optional<version::Version> &vers, Arg *verArg,
@@ -978,9 +980,12 @@
   return false;
 }
 
-bool CompilerInvocation::parseArgs(ArrayRef<const char *> Args,
-                                   DiagnosticEngine &Diags,
-                                   StringRef workingDirectory) {
+bool CompilerInvocation::parseArgs(
+    ArrayRef<const char *> Args,
+    DiagnosticEngine &Diags,
+    SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>>
+        *ConfigurationFileBuffers,
+    StringRef workingDirectory) {
   using namespace options;
 
   if (Args.empty())
@@ -1006,7 +1011,8 @@
     return true;
   }
 
-  if (ParseFrontendArgs(FrontendOpts, ParsedArgs, Diags)) {
+  if (ParseFrontendArgs(FrontendOpts, ParsedArgs, Diags,
+                        ConfigurationFileBuffers)) {
     return true;
   }
 
diff --git a/lib/FrontendTool/FrontendTool.cpp b/lib/FrontendTool/FrontendTool.cpp
index 743c1d7..72a7239 100644
--- a/lib/FrontendTool/FrontendTool.cpp
+++ b/lib/FrontendTool/FrontendTool.cpp
@@ -41,6 +41,7 @@
 #include "swift/Basic/JSONSerialization.h"
 #include "swift/Basic/LLVMContext.h"
 #include "swift/Basic/LLVMInitialize.h"
+#include "swift/Basic/PrettyStackTrace.h"
 #include "swift/Basic/SourceManager.h"
 #include "swift/Basic/Statistic.h"
 #include "swift/Basic/Timer.h"
@@ -1661,10 +1662,32 @@
   llvm::sys::fs::current_path(workingDirectory);
 
   // Parse arguments.
-  if (Invocation.parseArgs(Args, Instance->getDiags(), workingDirectory)) {
+  SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 4> configurationFileBuffers;
+  if (Invocation.parseArgs(Args, Instance->getDiags(),
+                           &configurationFileBuffers, workingDirectory)) {
     return finishDiagProcessing(1);
   }
 
+  // Make an array of PrettyStackTrace objects to dump the configuration files
+  // we used to parse the arguments. These are RAII objects, so they and the
+  // buffers they refer to must be kept alive in order to be useful. (That is,
+  // we want them to be alive for the entire rest of performFrontend.)
+  //
+  // This can't be a SmallVector or similar because PrettyStackTraces can't be
+  // moved (or copied)...and it can't be an array of non-optionals because
+  // PrettyStackTraces can't be default-constructed. So we end up with a
+  // dynamically-sized array of optional PrettyStackTraces, which get
+  // initialized by iterating over the buffers we collected above.
+  auto configurationFileStackTraces =
+      llvm::make_unique<Optional<PrettyStackTraceFileContents>[]>(
+        configurationFileBuffers.size());
+  for_each(configurationFileBuffers.begin(), configurationFileBuffers.end(),
+           &configurationFileStackTraces[0],
+           [](const std::unique_ptr<llvm::MemoryBuffer> &buffer,
+              Optional<PrettyStackTraceFileContents> &trace) {
+    trace.emplace(*buffer);
+  });
+
   // Setting DWARF Version depend on platform
   IRGenOptions &IRGenOpts = Invocation.getIRGenOptions();
   IRGenOpts.DWARFVersion = swift::DWARFVersion;
diff --git a/lib/IRGen/GenCast.h b/lib/IRGen/GenCast.h
index 86f0ed7..1043674 100644
--- a/lib/IRGen/GenCast.h
+++ b/lib/IRGen/GenCast.h
@@ -34,7 +34,7 @@
   class Explosion;
 
   /// Discriminator for checked cast modes.
-  enum class CheckedCastMode : unsigned char {
+  enum class CheckedCastMode : uint8_t {
     Unconditional,
     Conditional,
   };
diff --git a/lib/IRGen/GenEnum.cpp b/lib/IRGen/GenEnum.cpp
index f0efd44..5c55613 100644
--- a/lib/IRGen/GenEnum.cpp
+++ b/lib/IRGen/GenEnum.cpp
@@ -677,6 +677,14 @@
                      cast<FixedTypeInfo>(TI)->getFixedSize().getValueInBits(),
                      true);
     }
+
+    bool isSingleRetainablePointer(ResilienceExpansion expansion,
+                                   ReferenceCounting *rc) const override {
+      auto singleton = getSingleton();
+      if (!singleton)
+        return false;
+      return singleton->isSingleRetainablePointer(expansion, rc);
+    }
   };
 
   /// Implementation strategy for no-payload enums, in other words, 'C-like'
@@ -1423,15 +1431,35 @@
       PayloadTypesAndTagType.push_back(type);
     }
   }
+  
+  static std::pair<CanType, CanGenericSignature>
+  getTypeAndGenericSignatureForManglingOutlineFunction(SILType type) {
+    auto loweredType = type.getSwiftRValueType();
+    if (loweredType->hasArchetype()) {
+      GenericEnvironment *env = nullptr;
+      loweredType.findIf([&env](Type t) -> bool {
+        if (auto arch = t->getAs<ArchetypeType>()) {
+          env = arch->getGenericEnvironment();
+          return true;
+        }
+        return false;
+      });
+      assert(env && "has archetype but no archetype?!");
+      return {loweredType->mapTypeOutOfContext()->getCanonicalType(),
+              env->getGenericSignature()->getCanonicalSignature()};
+    }
+    return {loweredType, nullptr};
+  }
 
   static llvm::Function *createOutlineLLVMFunction(
       IRGenModule &IGM, std::string &name,
-      SmallVector<llvm::Type *, 2> &PayloadTypesAndTagType) {
+      ArrayRef<llvm::Type *> PayloadTypesAndTagType) {
     auto consumeTy = llvm::FunctionType::get(IGM.VoidTy, PayloadTypesAndTagType,
                                              /*isVarArg*/ false);
     auto func =
-        llvm::Function::Create(consumeTy, llvm::GlobalValue::InternalLinkage,
+        llvm::Function::Create(consumeTy, llvm::GlobalValue::LinkOnceODRLinkage,
                                llvm::StringRef(name), IGM.getModule());
+    func->setVisibility(llvm::GlobalValue::HiddenVisibility);
     func->setAttributes(IGM.constructInitialAttributes());
     func->setDoesNotThrow();
     func->setCallingConv(IGM.DefaultCC);
@@ -1490,14 +1518,19 @@
 
     unsigned NumExtraInhabitantTagValues = ~0U;
 
-    llvm::Function *copyEnumFunction = nullptr;
-    llvm::Function *consumeEnumFunction = nullptr;
+    SILType loweredType;
+    mutable llvm::Function *copyEnumFunction = nullptr;
+    mutable llvm::Function *consumeEnumFunction = nullptr;
     SmallVector<llvm::Type *, 2> PayloadTypesAndTagType;
 
-    llvm::Function *emitCopyEnumFunction(IRGenModule &IGM, EnumDecl *theEnum) {
+    llvm::Function *
+    emitCopyEnumFunction(IRGenModule &IGM, SILType theEnumType) const {
       IRGenMangler Mangler;
-      std::string name = Mangler.mangleOutlinedCopyFunction(
-          theEnum->getAsNominalTypeOrNominalTypeExtensionContext());
+      auto manglingBits =
+        getTypeAndGenericSignatureForManglingOutlineFunction(theEnumType);
+      std::string name =
+        Mangler.mangleOutlinedCopyFunction(manglingBits.first,
+                                           manglingBits.second);
       auto func = createOutlineLLVMFunction(IGM, name, PayloadTypesAndTagType);
 
       IRGenFunction IGF(IGM, func);
@@ -1528,9 +1561,13 @@
     }
 
     llvm::Function *emitConsumeEnumFunction(IRGenModule &IGM,
-                                            EnumDecl *theEnum) {
+                                            SILType theEnumType) const {
       IRGenMangler Mangler;
-      std::string name = Mangler.mangleOutlinedConsumeFunction(theEnum);
+      auto manglingBits =
+        getTypeAndGenericSignatureForManglingOutlineFunction(theEnumType);
+      std::string name =
+        Mangler.mangleOutlinedConsumeFunction(manglingBits.first,
+                                              manglingBits.second);
       auto func = createOutlineLLVMFunction(IGM, name, PayloadTypesAndTagType);
 
       IRGenFunction IGF(IGM, func);
@@ -2274,7 +2311,8 @@
         return;
 
       case Normal: {
-        assert(copyEnumFunction && "Did not create copy function for enum");
+        if (!copyEnumFunction)
+          copyEnumFunction = emitCopyEnumFunction(IGF.IGM, loweredType);
         Explosion tmp;
         fillExplosionForOutlinedCall(IGF, src, tmp);
         llvm::CallInst *call =
@@ -2307,8 +2345,8 @@
         return;
 
       case Normal: {
-        assert(consumeEnumFunction &&
-               "Did not create consume function for enum");
+        if (!consumeEnumFunction)
+          consumeEnumFunction = emitConsumeEnumFunction(IGF.IGM, loweredType);
         Explosion tmp;
         fillExplosionForOutlinedCall(IGF, src, tmp);
         llvm::CallInst *call =
@@ -2977,13 +3015,18 @@
     ReferenceCounting Refcounting;
     bool AllowFixedLayoutOptimizations;
 
-    llvm::Function *copyEnumFunction = nullptr;
-    llvm::Function *consumeEnumFunction = nullptr;
+    SILType loweredType;
+    mutable llvm::Function *copyEnumFunction = nullptr;
+    mutable llvm::Function *consumeEnumFunction = nullptr;
     SmallVector<llvm::Type *, 2> PayloadTypesAndTagType;
 
-    llvm::Function *emitCopyEnumFunction(IRGenModule &IGM, EnumDecl *theEnum) {
+    llvm::Function *emitCopyEnumFunction(IRGenModule &IGM, SILType type) const {
       IRGenMangler Mangler;
-      std::string name = Mangler.mangleOutlinedCopyFunction(theEnum);
+      auto manglingBits =
+        getTypeAndGenericSignatureForManglingOutlineFunction(type);
+      std::string name =
+        Mangler.mangleOutlinedCopyFunction(manglingBits.first,
+                                           manglingBits.second);
       auto func = createOutlineLLVMFunction(IGM, name, PayloadTypesAndTagType);
 
       IRGenFunction IGF(IGM, func);
@@ -3007,14 +3050,17 @@
     }
 
     llvm::Function *emitConsumeEnumFunction(IRGenModule &IGM,
-                                            EnumDecl *theEnum) {
+                                            SILType type) const {
       IRGenMangler Mangler;
-      std::string name = Mangler.mangleOutlinedConsumeFunction(theEnum);
+      auto manglingBits =
+        getTypeAndGenericSignatureForManglingOutlineFunction(type);
+      std::string name =
+        Mangler.mangleOutlinedConsumeFunction(manglingBits.first,
+                                              manglingBits.second);
       auto func = createOutlineLLVMFunction(IGM, name, PayloadTypesAndTagType);
 
       IRGenFunction IGF(IGM, func);
       Explosion src = IGF.collectParameters();
-
       auto parts = destructureAndTagLoadableEnumFromOutlined(IGF, src);
 
       forNontrivialPayloads(IGF, parts.tag, [&](unsigned tagIndex,
@@ -4021,7 +4067,8 @@
 
       case BitwiseTakable:
       case Normal: {
-        assert(copyEnumFunction && "Did not create copy function for enum");
+        if (!copyEnumFunction)
+          copyEnumFunction = emitCopyEnumFunction(IGF.IGM, loweredType);
         Explosion tmp;
         fillExplosionForOutlinedCall(IGF, src, tmp);
         llvm::CallInst *call =
@@ -4062,8 +4109,8 @@
 
       case BitwiseTakable:
       case Normal: {
-        assert(consumeEnumFunction &&
-               "Did not create consume function for enum");
+        if (!consumeEnumFunction)
+          consumeEnumFunction = emitConsumeEnumFunction(IGF.IGM, loweredType);
         Explosion tmp;
         fillExplosionForOutlinedCall(IGF, src, tmp);
         llvm::CallInst *call =
@@ -5354,6 +5401,10 @@
                               SILType T) const override {
       return Strategy.storeExtraInhabitant(IGF, index, dest, T);
     }
+    bool isSingleRetainablePointer(ResilienceExpansion expansion,
+                                   ReferenceCounting *rc) const override {
+      return Strategy.isSingleRetainablePointer(expansion, rc);
+    }
   };
 
   /// TypeInfo for fixed-layout, address-only enum types.
@@ -5725,8 +5776,7 @@
       payloadTI.isBitwiseTakable(ResilienceExpansion::Maximal));
   if (TIK >= Loadable && CopyDestroyKind == Normal) {
     computePayloadTypesAndTagType(TC.IGM, *TI, PayloadTypesAndTagType);
-    copyEnumFunction = emitCopyEnumFunction(TC.IGM, theEnum);
-    consumeEnumFunction = emitConsumeEnumFunction(TC.IGM, theEnum);
+    loweredType = Type;
   }
 
   return const_cast<TypeInfo *>(TI);
@@ -5916,8 +5966,7 @@
   if (TIK >= Loadable &&
       (CopyDestroyKind == Normal || CopyDestroyKind == BitwiseTakable)) {
     computePayloadTypesAndTagType(TC.IGM, *TI, PayloadTypesAndTagType);
-    copyEnumFunction = emitCopyEnumFunction(TC.IGM, theEnum);
-    consumeEnumFunction = emitConsumeEnumFunction(TC.IGM, theEnum);
+    loweredType = Type;
   }
 
   return const_cast<TypeInfo *>(TI);
diff --git a/lib/IRGen/GenEnum.h b/lib/IRGen/GenEnum.h
index 24dbbd6..b12eef5 100644
--- a/lib/IRGen/GenEnum.h
+++ b/lib/IRGen/GenEnum.h
@@ -436,6 +436,11 @@
       llvm::MapVector<CanType, llvm::Value *> &typeToMetadataVec,
       SILType T) const = 0;
 
+  virtual bool isSingleRetainablePointer(ResilienceExpansion expansion,
+                                         ReferenceCounting *rc) const {
+    return false;
+  }
+  
 private:
   EnumImplStrategy(const EnumImplStrategy &) = delete;
   EnumImplStrategy &operator=(const EnumImplStrategy &) = delete;
diff --git a/lib/IRGen/GenMeta.cpp b/lib/IRGen/GenMeta.cpp
index b4694f7..997336b 100644
--- a/lib/IRGen/GenMeta.cpp
+++ b/lib/IRGen/GenMeta.cpp
@@ -505,6 +505,10 @@
   // The empty tuple type has a singleton metadata.
   if (auto tuple = dyn_cast<TupleType>(type))
     return tuple->getNumElements() == 0;
+  
+  // Any and AnyObject have singleton metadata.
+  if (type->isAny() || type->isAnyObject())
+    return true;
 
   // The builtin types generally don't require metadata, but some of them
   // have nodes in the runtime anyway.
@@ -988,8 +992,24 @@
       if (auto metatype = tryGetLocal(type))
         return metatype;
 
-      auto layout = type.getExistentialLayout();
+      // Any and AnyObject have singleton metadata in the runtime.
+      llvm::Constant *singletonMetadata = nullptr;
+      if (type->isAny())
+        singletonMetadata = IGF.IGM.getAnyExistentialMetadata();
+      if (type->isAnyObject())
+        singletonMetadata = IGF.IGM.getAnyObjectExistentialMetadata();
+      
+      if (singletonMetadata) {
+        llvm::Constant *indices[] = {
+          llvm::ConstantInt::get(IGF.IGM.Int32Ty, 0),
+          llvm::ConstantInt::get(IGF.IGM.Int32Ty, 1)
+        };
+        return llvm::ConstantExpr::getInBoundsGetElementPtr(
+            /*Ty=*/nullptr, singletonMetadata, indices);
+      }
 
+      auto layout = type.getExistentialLayout();
+      
       auto protocols = layout.getProtocols();
 
       // Collect references to the protocol descriptors.
@@ -2344,10 +2364,10 @@
     void addGenericParametersHeader() {
       // Drop placeholders for the counts. We'll fill these in when we emit
       // the related sections.
-      GenericParamCount = B.addPlaceholderWithSize(IGM.Int32Ty);
-      GenericRequirementCount = B.addPlaceholderWithSize(IGM.Int32Ty);
-      GenericKeyArgumentCount = B.addPlaceholderWithSize(IGM.Int32Ty);
-      GenericExtraArgumentCount = B.addPlaceholderWithSize(IGM.Int32Ty);
+      GenericParamCount = B.addPlaceholderWithSize(IGM.Int16Ty);
+      GenericRequirementCount = B.addPlaceholderWithSize(IGM.Int16Ty);
+      GenericKeyArgumentCount = B.addPlaceholderWithSize(IGM.Int16Ty);
+      GenericExtraArgumentCount = B.addPlaceholderWithSize(IGM.Int16Ty);
     }
     
     void addGenericParameters() {
@@ -2369,7 +2389,9 @@
         B.addInt(IGM.Int8Ty, 0);
       
       // Fill in the parameter count.
-      B.fillPlaceholderWithInt(*GenericParamCount, IGM.Int32Ty,
+      assert(canSig->getGenericParams().size() <= UINT16_MAX
+             && "way too generic");
+      B.fillPlaceholderWithInt(*GenericParamCount, IGM.Int16Ty,
                                canSig->getGenericParams().size());
     }
     
@@ -2392,16 +2414,21 @@
                             asImpl().getGenericSignature()->getRequirements());
 
       // Fill in the final requirement count.
-      B.fillPlaceholderWithInt(*GenericRequirementCount, IGM.Int32Ty,
+      assert(metadata.NumRequirements <= UINT16_MAX
+             && "way too generic");
+      B.fillPlaceholderWithInt(*GenericRequirementCount, IGM.Int16Ty,
                                metadata.NumRequirements);
       NumGenericKeyArguments += metadata.NumGenericKeyArguments;
       NumGenericExtraArguments += metadata.NumGenericExtraArguments;
     }
 
     void finishGenericParameters() {
-      B.fillPlaceholderWithInt(*GenericKeyArgumentCount, IGM.Int32Ty,
+      assert(NumGenericKeyArguments <= UINT16_MAX
+             && NumGenericExtraArguments <= UINT16_MAX
+             && "way too generic");
+      B.fillPlaceholderWithInt(*GenericKeyArgumentCount, IGM.Int16Ty,
                                NumGenericKeyArguments);
-      B.fillPlaceholderWithInt(*GenericExtraArgumentCount, IGM.Int32Ty,
+      B.fillPlaceholderWithInt(*GenericExtraArgumentCount, IGM.Int16Ty,
                                NumGenericExtraArguments);
     }
 
@@ -5509,9 +5536,6 @@
     void layout() {
       if (asImpl().requiresInitializationFunction())
         asImpl().addInitializationFunction();
-      else
-        asImpl().addPaddingForInitializationFunction();
-      asImpl().addForeignName();
       asImpl().addForeignFlags();
       super::layout();
     }
@@ -5556,13 +5580,8 @@
       IGF.Builder.CreateRetVoid();
 
       B.addRelativeAddress(fn);
-    }
-    
-    void addPaddingForInitializationFunction() {
-      // The initialization function field is placed at the least offset of the
-      // record so it can be omitted when not needed. However, the metadata
-      // record is still pointer-aligned, so on 64 bit platforms we need to
-      // occupy the space to keep the rest of the record with the right layout.
+      
+      // Keep pointer alignment on 64-bit platforms for further fields.
       switch (IGM.getPointerSize().getValue()) {
       case 4:
         break;
@@ -5573,7 +5592,7 @@
         llvm_unreachable("unsupported word size");
       }
     }
-
+    
     void noteAddressPoint() {
       AddressPoint = B.getNextOffsetFromGlobal();
     }
diff --git a/lib/IRGen/GenStruct.cpp b/lib/IRGen/GenStruct.cpp
index 8ccbe10..83651d9 100644
--- a/lib/IRGen/GenStruct.cpp
+++ b/lib/IRGen/GenStruct.cpp
@@ -262,6 +262,14 @@
       field.getTypeInfo().storeExtraInhabitant(IGF, index, fieldAddr,
                                           field.getType(IGF.IGM, structType));
     }
+       
+    bool isSingleRetainablePointer(ResilienceExpansion expansion,
+                                   ReferenceCounting *rc) const override {
+      auto fields = asImpl().getFields();
+      if (fields.size() != 1)
+        return false;
+      return fields[0].getTypeInfo().isSingleRetainablePointer(expansion, rc);
+    }
     
     void verify(IRGenTypeVerifierFunction &IGF,
                 llvm::Value *metadata,
diff --git a/lib/IRGen/GenValueWitness.cpp b/lib/IRGen/GenValueWitness.cpp
index 5a823d1..a2f4f5a 100644
--- a/lib/IRGen/GenValueWitness.cpp
+++ b/lib/IRGen/GenValueWitness.cpp
@@ -1060,6 +1060,98 @@
                     concreteLoweredType, concreteTI);
 }
 
+static constexpr uint64_t sizeAndAlignment(Size size, Alignment alignment) {
+  return ((uint64_t)size.getValue() << 32) | alignment.getValue();
+}
+
+/// Return a reference to a known value witness table from the runtime
+/// that's suitable for the given type, if there is one, or return null
+/// if we should emit a new one.
+static llvm::Constant *
+getAddrOfKnownValueWitnessTable(IRGenModule &IGM, CanType type) {
+  // Native PE binaries shouldn't reference data symbols across DLLs, so disable
+  // this on Windows.
+  if (IGM.useDllStorage())
+    return nullptr;
+  
+  if (auto nom = type->getAnyNominal()) {
+    // TODO: Generic metadata patterns relative-reference their VWT, which won't
+    // work if it's in a different module without supporting indirection through
+    // the GOT.
+    if (nom->isGenericContext())
+      return nullptr;
+    // TODO: Enums need additional value witnesses for their tag manipulation.
+    if (isa<EnumDecl>(nom))
+      return nullptr;
+  }
+  
+  type = getFormalTypeInContext(type);
+  
+  auto &ti = IGM.getTypeInfoForUnlowered(AbstractionPattern::getOpaque(), type);
+  // We only have witnesses for fixed type info.
+  auto *fixedTI = dyn_cast<FixedTypeInfo>(&ti);
+  if (!fixedTI)
+    return nullptr;
+  
+  CanType witnessSurrogate;
+
+  // Handle common POD type layouts.
+  auto &C = type->getASTContext();
+  ReferenceCounting refCounting;
+  if (fixedTI->isPOD(ResilienceExpansion::Maximal)
+      && fixedTI->getFixedExtraInhabitantCount(IGM) == 0) {
+    // Reuse one of the integer witnesses if applicable.
+    switch (sizeAndAlignment(fixedTI->getFixedSize(),
+                             fixedTI->getFixedAlignment())) {
+    case sizeAndAlignment(Size(0), Alignment(1)):
+      witnessSurrogate = TupleType::getEmpty(C);
+      break;
+    case sizeAndAlignment(Size(1), Alignment(1)):
+      witnessSurrogate = BuiltinIntegerType::get(8, C)->getCanonicalType();
+      break;
+    case sizeAndAlignment(Size(2), Alignment(2)):
+      witnessSurrogate = BuiltinIntegerType::get(16, C)->getCanonicalType();
+      break;
+    case sizeAndAlignment(Size(4), Alignment(4)):
+      witnessSurrogate = BuiltinIntegerType::get(32, C)->getCanonicalType();
+      break;
+    case sizeAndAlignment(Size(8), Alignment(8)):
+      witnessSurrogate = BuiltinIntegerType::get(64, C)->getCanonicalType();
+      break;
+    case sizeAndAlignment(Size(16), Alignment(16)):
+      witnessSurrogate = BuiltinIntegerType::get(128, C)->getCanonicalType();
+      break;
+    case sizeAndAlignment(Size(32), Alignment(32)):
+      witnessSurrogate = BuiltinIntegerType::get(256, C)->getCanonicalType();
+      break;
+    case sizeAndAlignment(Size(64), Alignment(64)):
+      witnessSurrogate = BuiltinIntegerType::get(512, C)->getCanonicalType();
+      break;
+    }
+  } else if (fixedTI->isSingleRetainablePointer(ResilienceExpansion::Maximal,
+                                                &refCounting)) {
+    switch (refCounting) {
+    case ReferenceCounting::Native:
+      witnessSurrogate = C.TheNativeObjectType;
+      break;
+    case ReferenceCounting::ObjC:
+    case ReferenceCounting::Block:
+    case ReferenceCounting::Unknown:
+      witnessSurrogate = C.TheUnknownObjectType;
+      break;
+    case ReferenceCounting::Bridge:
+      witnessSurrogate = C.TheBridgeObjectType;
+      break;
+    case ReferenceCounting::Error:
+      break;
+    }
+  }
+  
+  if (witnessSurrogate)
+    return IGM.getAddrOfValueWitnessTable(witnessSurrogate);
+  return nullptr;
+}
+
 /// Emit a value-witness table for the given type, which is assumed to
 /// be non-dependent.
 llvm::Constant *irgen::emitValueWitnessTable(IRGenModule &IGM,
@@ -1068,7 +1160,16 @@
   // We shouldn't emit global value witness tables for generic type instances.
   assert(!isa<BoundGenericType>(abstractType) &&
          "emitting VWT for generic instance");
-
+  
+  // See if we can use a prefab witness table from the runtime.
+  // Note that we can't do this on Windows since the PE loader does not support
+  // cross-DLL pointers in data.
+  if (!isPattern) {
+    if (auto known = getAddrOfKnownValueWitnessTable(IGM, abstractType)) {
+      return known;
+    }
+  }
+  
   // We should never be making a pattern if the layout isn't fixed.
   // The reverse can be true for types whose layout depends on
   // resilient types.
diff --git a/lib/IRGen/HeapTypeInfo.h b/lib/IRGen/HeapTypeInfo.h
index 15021eb..ded80e4 100644
--- a/lib/IRGen/HeapTypeInfo.h
+++ b/lib/IRGen/HeapTypeInfo.h
@@ -32,7 +32,7 @@
   
 /// The kind of 'isa' encoding a heap object uses to reference its heap
 /// metadata.
-enum class IsaEncoding : unsigned char {
+enum class IsaEncoding : uint8_t {
   /// The object stores a plain pointer to its heap metadata as its first word.
   Pointer,
   /// The object's isa is managed by the Objective-C runtime and must be
@@ -43,7 +43,7 @@
   /// way.
   Unknown = ObjC,
 };
-  
+
 /// HeapTypeInfo - A type designed for use implementing a type
 /// which consists solely of something reference-counted.
 ///
diff --git a/lib/IRGen/IRGen.h b/lib/IRGen/IRGen.h
index 47ff1b9..50066ad 100644
--- a/lib/IRGen/IRGen.h
+++ b/lib/IRGen/IRGen.h
@@ -78,10 +78,10 @@
 }
 
 /// The kind of reference counting implementation a heap object uses.
-enum class ReferenceCounting : unsigned char {
+enum class ReferenceCounting : uint8_t {
   /// The object uses native Swift reference counting.
   Native,
-  
+
   /// The object uses ObjC reference counting.
   ///
   /// When ObjC interop is enabled, native Swift class objects are also ObjC
@@ -90,20 +90,20 @@
   ///
   /// Blocks are always ObjC reference counting compatible.
   ObjC,
-  
+
   /// The object uses _Block_copy/_Block_release reference counting.
   ///
   /// This is a strict subset of ObjC; all blocks are also ObjC reference
   /// counting compatible. The block is assumed to have already been moved to
   /// the heap so that _Block_copy returns the same object back.
   Block,
-  
+
   /// The object has an unknown reference counting implementation.
   ///
   /// This uses maximally-compatible reference counting entry points in the
   /// runtime.
   Unknown,
-  
+
   /// Cases prior to this one are binary-compatible with Unknown reference
   /// counting.
   LastUnknownCompatible = Unknown,
@@ -115,7 +115,7 @@
   /// runtime, with a masking layer on top. A bit inside the pointer is used
   /// to signal native Swift refcounting.
   Bridge,
-  
+
   /// The object uses ErrorType's reference counting entry points.
   Error,
 };
@@ -135,16 +135,16 @@
 };
 
 /// Whether a function requires extra data.
-enum class ExtraData : unsigned char {
+enum class ExtraData : uint8_t {
   /// The function requires no extra data.
   None,
 
   /// The function requires a retainable object pointer of extra data.
   Retainable,
-  
+
   /// The function takes its block object as extra data.
   Block,
-  
+
   Last_ExtraData = Block
 };
 
@@ -159,7 +159,7 @@
 ///
 /// See the comment in RelativePointer.h.
 
-enum class SymbolReferenceKind : unsigned char {
+enum class SymbolReferenceKind : uint8_t {
   /// An absolute reference to the object, i.e. an ordinary pointer.
   ///
   /// Generally well-suited for when C compatibility is a must, dynamic
@@ -295,11 +295,11 @@
 public:
   typedef uint32_t int_type;
 
-  Alignment() : Value(0) {}
-  explicit Alignment(int_type Value) : Value(Value) {}
+  constexpr Alignment() : Value(0) {}
+  constexpr explicit Alignment(int_type Value) : Value(Value) {}
 
-  int_type getValue() const { return Value; }
-  int_type getMaskValue() const { return Value - 1; }
+  constexpr int_type getValue() const { return Value; }
+  constexpr int_type getMaskValue() const { return Value - 1; }
 
   bool isOne() const { return Value == 1; }
   bool isZero() const { return Value == 0; }
@@ -349,7 +349,7 @@
   /// Is this the "invalid" size value?
   bool isInvalid() const { return *this == Size::invalid(); }
 
-  int_type getValue() const { return Value; }
+  constexpr int_type getValue() const { return Value; }
   
   int_type getValueInBits() const { return Value * 8; }
 
diff --git a/lib/IRGen/IRGenMangler.h b/lib/IRGen/IRGenMangler.h
index 06e0043..3f61f96 100644
--- a/lib/IRGen/IRGenMangler.h
+++ b/lib/IRGen/IRGenMangler.h
@@ -233,26 +233,32 @@
     return mangleConformanceSymbol(Type(), C, "MA");
   }
 
-  std::string mangleOutlinedCopyFunction(const GenericTypeDecl *Decl) {
+  std::string mangleOutlinedCopyFunction(CanType ty,
+                                         CanGenericSignature sig) {
     beginMangling();
-    appendAnyGenericType(Decl);
+    appendType(ty);
+    if (sig)
+      appendGenericSignature(sig);
     appendOperator("Wy");
     return finalize();
   }
-  std::string mangleOutlinedConsumeFunction(const GenericTypeDecl *Decl) {
+  std::string mangleOutlinedConsumeFunction(CanType ty,
+                                            CanGenericSignature sig) {
     beginMangling();
-    appendAnyGenericType(Decl);
+    appendType(ty);
+    if (sig)
+      appendGenericSignature(sig);
     appendOperator("We");
     return finalize();
   }
 
-  std::string mangleOutlinedRetainFunction(const Type t) {
+  std::string mangleOutlinedRetainFunction(Type t) {
     beginMangling();
     appendType(t);
     appendOperator("Wr");
     return finalize();
   }
-  std::string mangleOutlinedReleaseFunction(const Type t) {
+  std::string mangleOutlinedReleaseFunction(Type t) {
     beginMangling();
     appendType(t);
     appendOperator("Ws");
diff --git a/lib/IRGen/IRGenModule.cpp b/lib/IRGen/IRGenModule.cpp
index ed748c7..f2dad2f 100644
--- a/lib/IRGen/IRGenModule.cpp
+++ b/lib/IRGen/IRGenModule.cpp
@@ -562,19 +562,28 @@
   return { global, address };
 }
 
-llvm::Constant *IRGenModule::getEmptyTupleMetadata() {
-  if (EmptyTupleMetadata)
-    return EmptyTupleMetadata;
-
-  EmptyTupleMetadata = Module.getOrInsertGlobal(
-                          MANGLE_AS_STRING(METADATA_SYM(EMPTY_TUPLE_MANGLING)),
-                          FullTypeMetadataStructTy);
-  if (useDllStorage())
-    cast<llvm::GlobalVariable>(EmptyTupleMetadata)
-        ->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
-  return EmptyTupleMetadata;
+#define KNOWN_METADATA_ACCESSOR(NAME, SYM) \
+llvm::Constant *IRGenModule::get##NAME() { \
+  if (NAME) \
+    return NAME; \
+  NAME = Module.getOrInsertGlobal( \
+                          SYM, \
+                          FullTypeMetadataStructTy); \
+  if (useDllStorage()) \
+    cast<llvm::GlobalVariable>(NAME) \
+        ->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); \
+  return NAME; \
 }
 
+KNOWN_METADATA_ACCESSOR(EmptyTupleMetadata,
+                        MANGLE_AS_STRING(METADATA_SYM(EMPTY_TUPLE_MANGLING)))
+KNOWN_METADATA_ACCESSOR(AnyExistentialMetadata,
+                        MANGLE_AS_STRING(METADATA_SYM(ANY_MANGLING)))
+KNOWN_METADATA_ACCESSOR(AnyObjectExistentialMetadata,
+                        MANGLE_AS_STRING(METADATA_SYM(ANYOBJECT_MANGLING)))
+
+#undef KNOWN_METADATA_ACCESSOR
+
 llvm::Constant *IRGenModule::getObjCEmptyCachePtr() {
   if (ObjCEmptyCachePtr)
     return ObjCEmptyCachePtr;
diff --git a/lib/IRGen/IRGenModule.h b/lib/IRGen/IRGenModule.h
index 7825fb6..5150bc7 100644
--- a/lib/IRGen/IRGenModule.h
+++ b/lib/IRGen/IRGenModule.h
@@ -1023,6 +1023,8 @@
 //--- Runtime ---------------------------------------------------------------
 public:
   llvm::Constant *getEmptyTupleMetadata();
+  llvm::Constant *getAnyExistentialMetadata();
+  llvm::Constant *getAnyObjectExistentialMetadata();
   llvm::Constant *getObjCEmptyCachePtr();
   llvm::Constant *getObjCEmptyVTablePtr();
   llvm::InlineAsm *getObjCRetainAutoreleasedReturnValueMarker();
@@ -1034,6 +1036,8 @@
 
 private:
   llvm::Constant *EmptyTupleMetadata = nullptr;
+  llvm::Constant *AnyExistentialMetadata = nullptr;
+  llvm::Constant *AnyObjectExistentialMetadata = nullptr;
   llvm::Constant *ObjCEmptyCachePtr = nullptr;
   llvm::Constant *ObjCEmptyVTablePtr = nullptr;
   llvm::Constant *ObjCISAMaskPtr = nullptr;
diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp
index 9d7582a..3ca4b5b 100644
--- a/lib/IRGen/IRGenSIL.cpp
+++ b/lib/IRGen/IRGenSIL.cpp
@@ -26,6 +26,7 @@
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/SmallBitVector.h"
 #include "llvm/ADT/TinyPtrVector.h"
+#include "llvm/Support/SaveAndRestore.h"
 #include "llvm/Support/Debug.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/Basic/TargetInfo.h"
@@ -1552,6 +1553,12 @@
     return;
 
   PrettyStackTraceSILFunction stackTrace("emitting IR", f);
+  llvm::SaveAndRestore<SourceFile *> SetCurSourceFile(CurSourceFile);
+  if (auto dc = f->getDeclContext()) {
+    if (auto sf = dc->getParentSourceFile()) {
+      CurSourceFile = sf;
+    }
+  }
   IRGenSILFunction(*this, f).emitSILFunction();
 }
 
diff --git a/lib/IRGen/MemberAccessStrategy.h b/lib/IRGen/MemberAccessStrategy.h
index b847c2d..06e9f88 100644
--- a/lib/IRGen/MemberAccessStrategy.h
+++ b/lib/IRGen/MemberAccessStrategy.h
@@ -27,12 +27,12 @@
 /// A class which describes how to access a particular physical member.
 class MemberAccessStrategy {
 public:
-  enum class OffsetKind : unsigned char {
+  enum class OffsetKind : uint8_t {
     /// A word-size offset that represents a number of bytes.
     Bytes_Word,
   };
 
-  enum class Kind : unsigned char {
+  enum class Kind : uint8_t {
     /// The member has complex or overlapping storage.  It cannot be
     /// accessed simply by projecting out to a particular offset.
     Complex,
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index cbc527d..66e0fdb 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -3089,6 +3089,12 @@
 ParserResult<Expr> Parser::parseTrailingClosure(SourceRange calleeRange) {
   SourceLoc braceLoc = Tok.getLoc();
 
+  // Record the line numbers for the diagnostics below.
+  // Note that *do not* move this to after 'parseExprClosure()' it slows down
+  // 'getLineNumber()' call because of cache in SourceMgr.
+  auto origLine = SourceMgr.getLineNumber(calleeRange.End);
+  auto braceLine = SourceMgr.getLineNumber(braceLoc);
+
   // Parse the closure.
   ParserResult<Expr> closure = parseExprClosure();
   if (closure.isNull())
@@ -3097,8 +3103,6 @@
   // Warn if the trailing closure is separated from its callee by more than
   // one line. A single-line separation is acceptable for a trailing closure
   // call, and will be diagnosed later only if the call fails to typecheck.
-  auto origLine = SourceMgr.getLineNumber(calleeRange.End);
-  auto braceLine = SourceMgr.getLineNumber(braceLoc);
   if (braceLine > origLine + 1) {
     diagnose(braceLoc, diag::trailing_closure_after_newlines);
     diagnose(calleeRange.Start, diag::trailing_closure_callee_here);
diff --git a/lib/SIL/ValueOwnershipKindClassifier.cpp b/lib/SIL/ValueOwnershipKindClassifier.cpp
index 1dfb81a..d201e3f 100644
--- a/lib/SIL/ValueOwnershipKindClassifier.cpp
+++ b/lib/SIL/ValueOwnershipKindClassifier.cpp
@@ -148,6 +148,20 @@
 // If both the operand and the result are nontrivial, then either the types must
 // be compatible so that TBAA doesn't allow the destroy to be hoisted above uses
 // of the cast, or the programmer must use Builtin.fixLifetime.
+//
+// FIXME
+// -----
+//
+// SR-7175: Since we model this as unowned, then we must copy the
+// value before use. This directly contradicts the semantics mentioned
+// above since we will copy the value upon any use lest we use an
+// unowned value in an owned or guaranteed way. So really all we will
+// do here is perhaps add a copy slightly earlier unless the unowned
+// value immediately is cast to something trivial. In such a case, we
+// should be able to simplify the cast to just a trivial value and
+// then eliminate the copy. That being said, we should investigate
+// this since this is used in reinterpret_cast which is important from
+// a performance perspective.
 CONSTANT_OR_TRIVIAL_OWNERSHIP_INST(Unowned, UncheckedBitwiseCast)
 
 // A thin_to_thick instruction can return a trivial (@noescape) type.
diff --git a/lib/SILGen/ArgumentSource.h b/lib/SILGen/ArgumentSource.h
index 036a46e..15fae63 100644
--- a/lib/SILGen/ArgumentSource.h
+++ b/lib/SILGen/ArgumentSource.h
@@ -49,7 +49,7 @@
 /// working with multiple ArgumentSources should document the order in
 /// which they plan to evaluate them.
 class ArgumentSource {
-  enum class Kind : unsigned char {
+  enum class Kind : uint8_t {
     Invalid,
     RValue,
     LValue,
diff --git a/lib/SILGen/SILGenBridging.cpp b/lib/SILGen/SILGenBridging.cpp
index 710efca..101b1d8 100644
--- a/lib/SILGen/SILGenBridging.cpp
+++ b/lib/SILGen/SILGenBridging.cpp
@@ -1063,9 +1063,8 @@
     // Bitcast to Optional. This provides a barrier to the optimizer to prevent
     // it from attempting to eliminate null checks.
     auto optionalBridgedTy = SILType::getOptionalType(loweredBridgedTy);
-    auto optionalV =
-      SGF.B.createUncheckedBitCast(loc, v.getValue(), optionalBridgedTy);
-    auto optionalMV = ManagedValue(optionalV, v.getCleanup());
+    auto optionalMV =
+      SGF.B.createUncheckedBitCast(loc, v, optionalBridgedTy);
     return SGF.emitApplyOfLibraryIntrinsic(loc,
                            SGF.getASTContext().getBridgeAnyObjectToAny(nullptr),
                            SubstitutionMap(), optionalMV, C)
diff --git a/lib/SILGen/SILGenBuilder.cpp b/lib/SILGen/SILGenBuilder.cpp
index 9cba6dc..fe80671 100644
--- a/lib/SILGen/SILGenBuilder.cpp
+++ b/lib/SILGen/SILGenBuilder.cpp
@@ -702,7 +702,30 @@
                                                    ManagedValue value,
                                                    SILType type) {
   CleanupCloner cloner(*this, value);
-  SILValue cast = createUncheckedBitCast(loc, value.forward(SGF), type);
+  SILValue cast = createUncheckedBitCast(loc, value.getValue(), type);
+
+  // Currently SILBuilder::createUncheckedBitCast only produces these
+  // instructions. We assert here to make sure if this changes, this code is
+  // updated.
+  assert((isa<UncheckedTrivialBitCastInst>(cast) ||
+          isa<UncheckedRefCastInst>(cast) ||
+          isa<UncheckedBitwiseCastInst>(cast)) &&
+         "SILGenBuilder is out of sync with SILBuilder.");
+
+  // If we have a trivial inst, just return early.
+  if (isa<UncheckedTrivialBitCastInst>(cast))
+    return ManagedValue::forUnmanaged(cast);
+
+  // If we perform an unchecked bitwise case, then we are producing a new RC
+  // identity implying that we need a copy of the casted value to be returned so
+  // that the inputs/outputs of the case have separate ownership.
+  if (isa<UncheckedBitwiseCastInst>(cast)) {
+    return ManagedValue::forUnmanaged(cast).copy(SGF, loc);
+  }
+
+  // Otherwise, we forward the cleanup of the input value and place the cleanup
+  // on the cast value since unchecked_ref_cast is "forwarding".
+  value.forward(SGF);
   return cloner.clone(cast);
 }
 
@@ -871,3 +894,10 @@
             });
   return cloner.clone(createTuple(loc, type, forwardedValues));
 }
+
+ManagedValue SILGenBuilder::createUncheckedAddrCast(SILLocation loc, ManagedValue op,
+                                                    SILType resultTy) {
+  CleanupCloner cloner(*this, op);
+  SILValue cast = createUncheckedAddrCast(loc, op.forward(SGF), resultTy);
+  return cloner.clone(cast);
+}
diff --git a/lib/SILGen/SILGenBuilder.h b/lib/SILGen/SILGenBuilder.h
index d1b5420..26cce6f 100644
--- a/lib/SILGen/SILGenBuilder.h
+++ b/lib/SILGen/SILGenBuilder.h
@@ -310,6 +310,10 @@
   ManagedValue createUncheckedRefCast(SILLocation loc, ManagedValue original,
                                       SILType type);
 
+  using SILBuilder::createUncheckedAddrCast;
+  ManagedValue createUncheckedAddrCast(SILLocation loc, ManagedValue op,
+                                       SILType resultTy);
+
   using SILBuilder::createUncheckedBitCast;
   ManagedValue createUncheckedBitCast(SILLocation loc, ManagedValue original,
                                       SILType type);
diff --git a/lib/SILGen/SILGenPoly.cpp b/lib/SILGen/SILGenPoly.cpp
index 16491e4..1726561 100644
--- a/lib/SILGen/SILGenPoly.cpp
+++ b/lib/SILGen/SILGenPoly.cpp
@@ -415,12 +415,9 @@
     // If the conversion is trivial, just cast.
     if (SGF.SGM.Types.checkForABIDifferences(v.getType(), loweredResultTy)
           == TypeConverter::ABIDifference::Trivial) {
-      SILValue result = v.getValue();
       if (v.getType().isAddress())
-        result = SGF.B.createUncheckedAddrCast(Loc, result, loweredResultTy);
-      else
-        result = SGF.B.createUncheckedBitCast(Loc, result, loweredResultTy);
-      return ManagedValue(result, v.getCleanup());
+        return SGF.B.createUncheckedAddrCast(Loc, v, loweredResultTy);
+      return SGF.B.createUncheckedBitCast(Loc, v, loweredResultTy);
     }
 
     auto transformOptionalPayload =
diff --git a/lib/SILGen/SwitchEnumBuilder.cpp b/lib/SILGen/SwitchEnumBuilder.cpp
index 935d043..901091b 100644
--- a/lib/SILGen/SwitchEnumBuilder.cpp
+++ b/lib/SILGen/SwitchEnumBuilder.cpp
@@ -106,7 +106,7 @@
       input = builder.createOwnedPHIArgument(optional.getType());
     }
     handler(input, presentScope);
-    assert(!builder.hasValidInsertionPoint());
+    builder.clearInsertionPoint();
   }
 
   for (NormalCaseData &caseData : caseDataArray) {
@@ -133,7 +133,7 @@
       }
     }
     handler(input, presentScope);
-    assert(!builder.hasValidInsertionPoint());
+    builder.clearInsertionPoint();
   }
 
   // If we are asked to create a default block and it is specified that the
@@ -154,6 +154,6 @@
       input = builder.createOwnedPHIArgument(optional.getType());
     }
     handler(input, presentScope);
-    assert(!builder.hasValidInsertionPoint());
+    builder.clearInsertionPoint();
   }
 }
diff --git a/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp b/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp
index ce6ff666..82f1ef1 100644
--- a/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp
+++ b/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp
@@ -191,11 +191,7 @@
 //===----------------------------------------------------------------------===//
 
 namespace {
-  enum class DIKind : unsigned char {
-    No,
-    Yes,
-    Partial
-  };
+enum class DIKind : uint8_t { No, Yes, Partial };
 } // end anonymous namespace
 
 /// This implements the lattice merge operation for 2 optional DIKinds.
diff --git a/lib/Sema/ConstraintSystem.h b/lib/Sema/ConstraintSystem.h
index 6a3ee66..972c02e 100644
--- a/lib/Sema/ConstraintSystem.h
+++ b/lib/Sema/ConstraintSystem.h
@@ -2666,7 +2666,7 @@
 
 private:
   /// The kind of bindings that are permitted.
-  enum class AllowedBindingKind : unsigned char {
+  enum class AllowedBindingKind : uint8_t {
     /// Only the exact type.
     Exact,
     /// Supertypes of the specified type.
@@ -2676,7 +2676,7 @@
   };
 
   /// The kind of literal binding found.
-  enum class LiteralBindingKind : unsigned char {
+  enum class LiteralBindingKind : uint8_t {
     None,
     Collection,
     Float,
diff --git a/lib/Sema/TypeCheckProtocol.h b/lib/Sema/TypeCheckProtocol.h
index d4cf20d..e1a41e6 100644
--- a/lib/Sema/TypeCheckProtocol.h
+++ b/lib/Sema/TypeCheckProtocol.h
@@ -148,7 +148,7 @@
 
 /// \brief The result of matching a particular declaration to a given
 /// requirement.
-enum class MatchKind : unsigned char {
+enum class MatchKind : uint8_t {
   /// \brief The witness matched the requirement exactly.
   ExactMatch,
 
diff --git a/stdlib/public/Platform/Platform.swift b/stdlib/public/Platform/Platform.swift
index a71d299..05b6ee4 100644
--- a/stdlib/public/Platform/Platform.swift
+++ b/stdlib/public/Platform/Platform.swift
@@ -57,9 +57,10 @@
   }
 }
 
-extension DarwinBoolean : Equatable {}
-public func ==(lhs: DarwinBoolean, rhs: DarwinBoolean) -> Bool {
-  return lhs.boolValue == rhs.boolValue
+extension DarwinBoolean : Equatable {
+  public static func ==(lhs: DarwinBoolean, rhs: DarwinBoolean) -> Bool {
+    return lhs.boolValue == rhs.boolValue
+  }
 }
 
 public // COMPILER_INTRINSIC
diff --git a/stdlib/public/SDK/CoreMedia/CMTime.swift b/stdlib/public/SDK/CoreMedia/CMTime.swift
index a37a8ba..ecfb1cf 100644
--- a/stdlib/public/SDK/CoreMedia/CMTime.swift
+++ b/stdlib/public/SDK/CoreMedia/CMTime.swift
@@ -99,34 +99,36 @@
   return time.hasBeenRounded
 }
 
-// CMTimeAdd
-public func + (addend1: CMTime, addend2: CMTime) -> CMTime {
-  return CMTimeAdd(addend1, addend2)
+extension CMTime {
+  // CMTimeAdd
+  public static func + (addend1: CMTime, addend2: CMTime) -> CMTime {
+    return CMTimeAdd(addend1, addend2)
+  }
+  
+  // CMTimeSubtract
+  public static func - (minuend: CMTime, subtrahend: CMTime) -> CMTime {
+    return CMTimeSubtract(minuend, subtrahend)
+  }
 }
 
-// CMTimeSubtract
-public func - (minuend: CMTime, subtrahend: CMTime) -> CMTime {
-  return CMTimeSubtract(minuend, subtrahend)
-}
-
-extension CMTime : Equatable, Comparable {}
-
 // CMTimeCompare
-public func < (time1: CMTime, time2: CMTime) -> Bool {
-  return CMTimeCompare(time1, time2) < 0
-}
-public func <= (time1: CMTime, time2: CMTime) -> Bool {
-  return CMTimeCompare(time1, time2) <= 0
-}
-public func > (time1: CMTime, time2: CMTime) -> Bool {
-  return CMTimeCompare(time1, time2) > 0
-}
-public func >= (time1: CMTime, time2: CMTime) -> Bool {
-  return CMTimeCompare(time1, time2) >= 0
-}
-public func == (time1: CMTime, time2: CMTime) -> Bool {
-  return CMTimeCompare(time1, time2) == 0
-}
-public func != (time1: CMTime, time2: CMTime) -> Bool {
-  return CMTimeCompare(time1, time2) != 0
+extension CMTime : Equatable, Comparable {
+  public static func < (time1: CMTime, time2: CMTime) -> Bool {
+    return CMTimeCompare(time1, time2) < 0
+  }
+  public static func <= (time1: CMTime, time2: CMTime) -> Bool {
+    return CMTimeCompare(time1, time2) <= 0
+  }
+  public static func > (time1: CMTime, time2: CMTime) -> Bool {
+    return CMTimeCompare(time1, time2) > 0
+  }
+  public static func >= (time1: CMTime, time2: CMTime) -> Bool {
+    return CMTimeCompare(time1, time2) >= 0
+  }
+  public static func == (time1: CMTime, time2: CMTime) -> Bool {
+    return CMTimeCompare(time1, time2) == 0
+  }
+  public static func != (time1: CMTime, time2: CMTime) -> Bool {
+    return CMTimeCompare(time1, time2) != 0
+  }
 }
diff --git a/stdlib/public/SDK/CoreMedia/CMTimeRange.swift b/stdlib/public/SDK/CoreMedia/CMTimeRange.swift
index 6050e0e..c27974d 100644
--- a/stdlib/public/SDK/CoreMedia/CMTimeRange.swift
+++ b/stdlib/public/SDK/CoreMedia/CMTimeRange.swift
@@ -74,14 +74,13 @@
   return range.isEmpty
 }
 
-extension CMTimeRange : Equatable {}
-
 // CMTimeRangeEqual
-public func == (range1: CMTimeRange, range2: CMTimeRange) -> Bool {
-  return CMTimeRangeEqual(range1, range2)
+extension CMTimeRange : Equatable {
+  public static func == (range1: CMTimeRange, range2: CMTimeRange) -> Bool {
+    return CMTimeRangeEqual(range1, range2)
+  }
+  
+  public static func != (range1: CMTimeRange, range2: CMTimeRange) -> Bool {
+    return !CMTimeRangeEqual(range1, range2)
+  }  
 }
-
-public func != (range1: CMTimeRange, range2: CMTimeRange) -> Bool {
-  return !CMTimeRangeEqual(range1, range2)
-}
-
diff --git a/stdlib/public/SDK/Dispatch/Dispatch.swift b/stdlib/public/SDK/Dispatch/Dispatch.swift
index edeaafb..b507306 100644
--- a/stdlib/public/SDK/Dispatch/Dispatch.swift
+++ b/stdlib/public/SDK/Dispatch/Dispatch.swift
@@ -114,10 +114,10 @@
 		self.qosClass = qosClass
 		self.relativePriority = relativePriority
 	}
-}
 
-public func ==(a: DispatchQoS, b: DispatchQoS) -> Bool {
-	return a.qosClass == b.qosClass && a.relativePriority == b.relativePriority
+	public static func ==(a: DispatchQoS, b: DispatchQoS) -> Bool {
+		return a.qosClass == b.qosClass && a.relativePriority == b.relativePriority
+	}
 }
 
 /// 
diff --git a/stdlib/public/SDK/ObjectiveC/ObjectiveC.swift b/stdlib/public/SDK/ObjectiveC/ObjectiveC.swift
index dbf43f1..9639638 100644
--- a/stdlib/public/SDK/ObjectiveC/ObjectiveC.swift
+++ b/stdlib/public/SDK/ObjectiveC/ObjectiveC.swift
@@ -112,11 +112,11 @@
   }
 }
 
-public func ==(lhs: Selector, rhs: Selector) -> Bool {
-  return sel_isEqual(lhs, rhs)
-}
-
 extension Selector : Equatable, Hashable {
+  public static func ==(lhs: Selector, rhs: Selector) -> Bool {
+    return sel_isEqual(lhs, rhs)
+  }
+
   /// The hash value.
   ///
   /// **Axiom:** `x == y` implies `x.hashValue == y.hashValue`
@@ -199,6 +199,10 @@
 // FIXME: what about NSObjectProtocol?
 
 extension NSObject : Equatable, Hashable {
+  public static func == (lhs: NSObject, rhs: NSObject) -> Bool {
+    return lhs.isEqual(rhs)
+  }
+
   /// The hash value.
   ///
   /// **Axiom:** `x == y` implies `x.hashValue == y.hashValue`
@@ -212,10 +216,6 @@
   }
 }
 
-public func == (lhs: NSObject, rhs: NSObject) -> Bool {
-  return lhs.isEqual(rhs)
-}
-
 extension NSObject : CVarArg {
   /// Transform `self` into a series of machine words that can be
   /// appropriately interpreted by C varargs
diff --git a/stdlib/public/SDK/UIKit/UIKit.swift b/stdlib/public/SDK/UIKit/UIKit.swift
index abf0015..531631a 100644
--- a/stdlib/public/SDK/UIKit/UIKit.swift
+++ b/stdlib/public/SDK/UIKit/UIKit.swift
@@ -39,24 +39,24 @@
 // Equatable types.
 //===----------------------------------------------------------------------===//
 
-@_transparent // @fragile
-public func == (lhs: UIEdgeInsets, rhs: UIEdgeInsets) -> Bool {
-  return lhs.top == rhs.top &&
-         lhs.left == rhs.left &&
-         lhs.bottom == rhs.bottom &&
-         lhs.right == rhs.right
+extension UIEdgeInsets : Equatable {
+  @_transparent // @fragile
+  public static func == (lhs: UIEdgeInsets, rhs: UIEdgeInsets) -> Bool {
+    return lhs.top == rhs.top &&
+           lhs.left == rhs.left &&
+           lhs.bottom == rhs.bottom &&
+           lhs.right == rhs.right
+  }
 }
 
-extension UIEdgeInsets : Equatable {}
-
-@_transparent // @fragile
-public func == (lhs: UIOffset, rhs: UIOffset) -> Bool {
-  return lhs.horizontal == rhs.horizontal &&
-         lhs.vertical == rhs.vertical
+extension UIOffset : Equatable {
+  @_transparent // @fragile
+  public static func == (lhs: UIOffset, rhs: UIOffset) -> Bool {
+    return lhs.horizontal == rhs.horizontal &&
+           lhs.vertical == rhs.vertical
+  }
 }
 
-extension UIOffset : Equatable {}
-
 //===----------------------------------------------------------------------===//
 // Numeric backed types
 //===----------------------------------------------------------------------===//
diff --git a/stdlib/public/SwiftOnoneSupport/SwiftOnoneSupport.swift b/stdlib/public/SwiftOnoneSupport/SwiftOnoneSupport.swift
index ce1b1ff..8966c21 100644
--- a/stdlib/public/SwiftOnoneSupport/SwiftOnoneSupport.swift
+++ b/stdlib/public/SwiftOnoneSupport/SwiftOnoneSupport.swift
@@ -25,7 +25,7 @@
       var a = [Element](repeating: sampleValue, count: 1)
 
       // Read array element
-      let _ =  a[0]
+      _ = a[0]
 
       // Set array elements
       for j in 1..<a.count {
@@ -42,7 +42,7 @@
       a[0] = sampleValue
 
       // Get count and capacity
-      let _ = a.count + a.capacity
+      _ = a.count + a.capacity
 
       // Iterate over array
       for e in a {
@@ -63,7 +63,7 @@
       a.reserveCapacity(100)
 
       // Sort array
-      let _ = a.sorted { (a: Element, b: Element) in a < b }
+      _ = a.sorted { (a: Element, b: Element) in a < b }
       a.sort { (a: Element, b: Element) in a < b }
 
       // force specialization of append.
@@ -80,7 +80,7 @@
       var a = [Element](repeating: sampleValue, count: 1)
 
       // Read array element
-      let _ =  a[0]
+      _ = a[0]
 
       // Set array elements
       for j in 0..<a.count {
@@ -96,7 +96,7 @@
       a[0] = sampleValue
 
       // Get length and capacity
-      let _ = a.count + a.capacity
+      _ = a.count + a.capacity
 
       // Iterate over array
       for e in a {
diff --git a/stdlib/public/runtime/Demangle.cpp b/stdlib/public/runtime/Demangle.cpp
index 760dd58..4a3f522 100644
--- a/stdlib/public/runtime/Demangle.cpp
+++ b/stdlib/public/runtime/Demangle.cpp
@@ -279,6 +279,11 @@
     description = structType->Description;
     break;
   }
+  case MetadataKind::ForeignClass: {
+    auto foreignType = static_cast<const ForeignClassMetadata *>(type);
+    description = foreignType->Description;
+    break;
+  }
   default:
     return nullptr;
   }
@@ -349,6 +354,7 @@
   case MetadataKind::Enum:
   case MetadataKind::Optional:
   case MetadataKind::Struct:
+  case MetadataKind::ForeignClass:
     return _buildDemanglingForNominalType(type, Dem);
   case MetadataKind::ObjCClassWrapper: {
 #if SWIFT_OBJC_INTEROP
@@ -367,10 +373,6 @@
     return nullptr;
 #endif
   }
-  case MetadataKind::ForeignClass: {
-    auto foreign = static_cast<const ForeignClassMetadata *>(type);
-    return Dem.demangleType(foreign->getName());
-  }
   case MetadataKind::Existential: {
     auto exis = static_cast<const ExistentialTypeMetadata *>(type);
     
diff --git a/stdlib/public/runtime/KnownMetadata.cpp b/stdlib/public/runtime/KnownMetadata.cpp
index 05e2c37..7b88495 100644
--- a/stdlib/public/runtime/KnownMetadata.cpp
+++ b/stdlib/public/runtime/KnownMetadata.cpp
@@ -191,3 +191,4 @@
     nullptr                    // Labels
   }
 };
+
diff --git a/stdlib/public/runtime/Metadata.cpp b/stdlib/public/runtime/Metadata.cpp
index 6426937..6fb851a 100644
--- a/stdlib/public/runtime/Metadata.cpp
+++ b/stdlib/public/runtime/Metadata.cpp
@@ -30,7 +30,6 @@
 #include <algorithm>
 #include <cctype>
 #include <condition_variable>
-#include <iostream>
 #include <new>
 #if defined(_WIN32)
 #define WIN32_LEAN_AND_MEAN
@@ -2296,6 +2295,36 @@
 static const ValueWitnessTable OpaqueExistentialValueWitnesses_1 =
   ValueWitnessTableForBox<OpaqueExistentialBox<1>>::table;
 
+/// The standard metadata for Any.
+const FullMetadata<ExistentialTypeMetadata> swift::
+METADATA_SYM(ANY_MANGLING) = {
+  { &OpaqueExistentialValueWitnesses_0 }, // ValueWitnesses
+  ExistentialTypeMetadata(
+    ExistentialTypeFlags() // Flags
+      .withNumWitnessTables(0)
+      .withClassConstraint(ProtocolClassConstraint::Any)
+      .withHasSuperclass(false)
+      .withSpecialProtocol(SpecialProtocol::None)),
+};
+
+/// The standard metadata for AnyObject.
+const FullMetadata<ExistentialTypeMetadata> swift::
+METADATA_SYM(ANYOBJECT_MANGLING) = {
+  {
+#if SWIFT_OBJC_INTEROP
+    &VALUE_WITNESS_SYM(BO)
+#else
+    &VALUE_WITNESS_SYM(Bo)
+#endif
+  },
+  ExistentialTypeMetadata(
+    ExistentialTypeFlags() // Flags
+      .withNumWitnessTables(0)
+      .withClassConstraint(ProtocolClassConstraint::Class)
+      .withHasSuperclass(false)
+      .withSpecialProtocol(SpecialProtocol::None)),
+};
+
 /// The uniquing structure for opaque existential value witness tables.
 static SimpleGlobalCache<OpaqueExistentialValueWitnessTableCacheEntry>
 OpaqueExistentialValueWitnessTables;
@@ -2616,10 +2645,20 @@
                                   size_t numProtocols,
                                   const ProtocolDescriptor * const *protocols) {
 
+  // The empty compositions Any and AnyObject have fixed metadata.
+  if (numProtocols == 0 && !superclassConstraint) {
+    switch (classConstraint) {
+    case ProtocolClassConstraint::Any:
+      return &METADATA_SYM(ANY_MANGLING);
+    case ProtocolClassConstraint::Class:
+      return &METADATA_SYM(ANYOBJECT_MANGLING);
+    }
+  }
+
   // We entrust that the compiler emitting the call to
   // swift_getExistentialTypeMetadata always sorts the `protocols` array using
   // a globally stable ordering that's consistent across modules.
-
+  
   // Ensure that the "class constraint" bit is set whenever we have a
   // superclass or a one of the protocols is class-bound.
   assert(classConstraint == ProtocolClassConstraint::Class ||
@@ -2709,28 +2748,42 @@
 /***************************************************************************/
 
 namespace {
-  /// A string whose data is globally-allocated.
-  struct GlobalString {
-    StringRef Data;
-    /*implicit*/ GlobalString(StringRef data) : Data(data) {}
+  /// A reference to a context descriptor, used as a uniquing key.
+  struct ContextDescriptorKey {
+    const TypeContextDescriptor *Data;
   };
 } // end anonymous namespace
 
 template <>
-struct llvm::DenseMapInfo<GlobalString> {
-  static GlobalString getEmptyKey() {
-    return StringRef((const char*) 0, 0);
+struct llvm::DenseMapInfo<ContextDescriptorKey> {
+  static ContextDescriptorKey getEmptyKey() {
+    return ContextDescriptorKey{(const TypeContextDescriptor*) 0};
   }
-  static GlobalString getTombstoneKey() {
-    return StringRef((const char*) 1, 0);
+  static ContextDescriptorKey getTombstoneKey() {
+    return ContextDescriptorKey{(const TypeContextDescriptor*) 1};
   }
-  static unsigned getHashValue(const GlobalString &val) {
+  static unsigned getHashValue(ContextDescriptorKey val) {
+    if ((uintptr_t)val.Data <= 1) {
+      return llvm::hash_value(val.Data);
+    }
+
+    // Hash by name.
+    // In full generality, we'd get a better hash by walking up the entire
+    // descriptor tree and hashing names all along the way, and we'd be faster
+    // if we special cased unique keys by hashing pointers. In practice, this
+    // is only used to unique foreign metadata records, which only ever appear
+    // in the "C" or "ObjC" special context, and are never unique.
+    
     // llvm::hash_value(StringRef) is, unfortunately, defined out of
     // line in a library we otherwise would not need to link against.
-    return llvm::hash_combine_range(val.Data.begin(), val.Data.end());
+    StringRef name(val.Data->Name.get());
+    return llvm::hash_combine_range(name.begin(), name.end());
   }
-  static bool isEqual(const GlobalString &lhs, const GlobalString &rhs) {
-    return lhs.Data == rhs.Data;
+  static bool isEqual(ContextDescriptorKey lhs, ContextDescriptorKey rhs) {
+    if ((uintptr_t)lhs.Data <= 1 || (uintptr_t)rhs.Data <= 1) {
+      return lhs.Data == rhs.Data;
+    }
+    return equalContexts(lhs.Data, rhs.Data);
   }
 };
 
@@ -2740,7 +2793,7 @@
 struct ForeignTypeState {
   Mutex Lock;
   ConditionVariable InitializationWaiters;
-  llvm::DenseMap<GlobalString, const ForeignTypeMetadata *> Types;
+  llvm::DenseMap<ContextDescriptorKey, const ForeignTypeMetadata *> Types;
 };
 } // end anonymous namespace
 
@@ -2756,7 +2809,9 @@
 
   // Okay, check the global map.
   auto &foreignTypes = ForeignTypes.get();
-  GlobalString key(nonUnique->getName());
+  ContextDescriptorKey key{nonUnique->getTypeContextDescriptor()};
+  assert(key.Data
+         && "all foreign metadata should have a type context descriptor");
   bool hasInit = cache.hasInitializationFunction();
 
   const ForeignTypeMetadata *uniqueMetadata;
diff --git a/test/ClangImporter/plus_zero_objc_ir.swift b/test/ClangImporter/plus_zero_objc_ir.swift
index 4ea8181..c31afe7 100644
--- a/test/ClangImporter/plus_zero_objc_ir.swift
+++ b/test/ClangImporter/plus_zero_objc_ir.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %build-clang-importer-objc-overlays
 // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -I %S/Inputs/custom-modules -emit-ir -g -o - -primary-file %s | %FileCheck %s
diff --git a/test/ClangImporter/plus_zero_optional.swift b/test/ClangImporter/plus_zero_optional.swift
index f36c2af..2143b38 100644
--- a/test/ClangImporter/plus_zero_optional.swift
+++ b/test/ClangImporter/plus_zero_optional.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/custom-modules -enable-sil-ownership -emit-silgen -o - %s | %FileCheck %s
 
 // REQUIRES: objc_interop
diff --git a/test/ClangImporter/plus_zero_serialization-sil.swift b/test/ClangImporter/plus_zero_serialization-sil.swift
index 2c063a6..fb5a358 100644
--- a/test/ClangImporter/plus_zero_serialization-sil.swift
+++ b/test/ClangImporter/plus_zero_serialization-sil.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -emit-module-path %t/Test.swiftmodule -emit-sil -o /dev/null -module-name Test %s -sdk "" -import-objc-header %S/Inputs/serialization-sil.h -enable-sil-ownership
 // RUN: %target-sil-func-extractor %t/Test.swiftmodule -sil-print-debuginfo  -func='$S4Test16testPartialApplyyySoAA_pF' -o - | %FileCheck %s
diff --git a/test/DebugInfo/plus_zero_closure-multivalue.swift b/test/DebugInfo/plus_zero_closure-multivalue.swift
index 7310711..4f0d363 100644
--- a/test/DebugInfo/plus_zero_closure-multivalue.swift
+++ b/test/DebugInfo/plus_zero_closure-multivalue.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // rdar://problem/23727705:
 // RUN-DISABLED: %target-swift-frontend -O %s -disable-llvm-optzns -emit-ir -g -o - | %FileCheck %s
 import StdlibUnittest
@@ -36,8 +37,8 @@
 // Verify that a reabstraction thunk does not have a line number.
 // CHECK-O0-NOT: DW_OP_bit_piece
 // CHECK-O0-NOT: DW_OP_bit_piece
-// CHECK-O0: !DILocalVariable(name: "a", arg: 1{{.*}} line: 18,
+// CHECK-O0: !DILocalVariable(name: "a", arg: 1{{.*}} line: 19,
 // CHECK-O0-NOT: DW_OP_bit_piece
-// CHECK-O0: !DILocalVariable(name: "b", arg: 2{{.*}} line: 18,
+// CHECK-O0: !DILocalVariable(name: "b", arg: 2{{.*}} line: 19,
 // CHECK-O0-NOT: DW_OP_bit_piece
 // CHECK-O0: !DISubprogram(linkageName: "$SS2SSbs5Error_pIgggdzo_S2SSbsAA_pIegnndzo_TR",
diff --git a/test/DebugInfo/plus_zero_generic_args.swift b/test/DebugInfo/plus_zero_generic_args.swift
index e4de262..090929a 100644
--- a/test/DebugInfo/plus_zero_generic_args.swift
+++ b/test/DebugInfo/plus_zero_generic_args.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -primary-file %s -emit-ir -verify -g -o - | %FileCheck %s
 
 func markUsed<T>(_ t: T) {}
diff --git a/test/DebugInfo/plus_zero_resilience.swift b/test/DebugInfo/plus_zero_resilience.swift
index 0e50528..cedfa85 100644
--- a/test/DebugInfo/plus_zero_resilience.swift
+++ b/test/DebugInfo/plus_zero_resilience.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 //
 // Compile the external swift module.
diff --git a/test/Driver/batch_mode_aux_file_order.swift b/test/Driver/batch_mode_aux_file_order.swift
new file mode 100644
index 0000000..5366371
--- /dev/null
+++ b/test/Driver/batch_mode_aux_file_order.swift
@@ -0,0 +1,20 @@
+// When multiple additional-outputs on the same command-line are no longer
+// supported (i.e. when we've moved to mandatory use of output file maps for
+// communicating multiple additional-outputs to frontends) this test will no
+// longer make sense, and should be removed.
+//
+// RUN: %empty-directory(%t)
+// RUN: touch %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/file-04.swift %t/file-05.swift
+// RUN: touch %t/file-06.swift %t/file-07.swift %t/file-08.swift %t/file-09.swift
+//
+// RUN: %swiftc_driver -enable-batch-mode -driver-batch-seed 1 -driver-print-jobs -driver-skip-execution -j 3 -emit-module -module-name foo %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/file-04.swift %t/file-05.swift %t/file-06.swift %t/file-07.swift %t/file-08.swift %t/file-09.swift >%t/out.txt
+// RUN: %FileCheck %s <%t/out.txt
+//
+// Each batch should get 3 primaries; check that each has 3 modules _in the same numeric order_.
+//
+// CHECK: {{.*}}/swift {{.*}}-primary-file {{[^ ]*}}/file-[[A1:[0-9]+]].swift {{.*}}-primary-file {{[^ ]*}}/file-[[A2:[0-9]+]].swift {{.*}}-primary-file {{[^ ]*}}/file-[[A3:[0-9]+]].swift
+// CHECK-SAME: -o {{.*}}/file-[[A1]]-{{[a-z0-9]+}}.swiftmodule -o {{.*}}/file-[[A2]]-{{[a-z0-9]+}}.swiftmodule -o {{.*}}/file-[[A3]]-{{[a-z0-9]+}}.swiftmodule
+// CHECK: {{.*}}/swift {{.*}}-primary-file {{[^ ]*}}/file-[[B1:[0-9]+]].swift {{.*}}-primary-file {{[^ ]*}}/file-[[B2:[0-9]+]].swift {{.*}}-primary-file {{[^ ]*}}/file-[[B3:[0-9]+]].swift
+// CHECK-SAME: -o {{.*}}/file-[[B1]]-{{[a-z0-9]+}}.swiftmodule -o {{.*}}/file-[[B2]]-{{[a-z0-9]+}}.swiftmodule -o {{.*}}/file-[[B3]]-{{[a-z0-9]+}}.swiftmodule
+// CHECK: {{.*}}/swift {{.*}}-primary-file {{[^ ]*}}/file-[[C1:[0-9]+]].swift {{.*}}-primary-file {{[^ ]*}}/file-[[C2:[0-9]+]].swift {{.*}}-primary-file {{[^ ]*}}/file-[[C3:[0-9]+]].swift
+// CHECK-SAME: -o {{.*}}/file-[[C1]]-{{[a-z0-9]+}}.swiftmodule -o {{.*}}/file-[[C2]]-{{[a-z0-9]+}}.swiftmodule -o {{.*}}/file-[[C3]]-{{[a-z0-9]+}}.swiftmodule
diff --git a/test/Frontend/crash.swift b/test/Frontend/crash.swift
new file mode 100644
index 0000000..455f8fa
--- /dev/null
+++ b/test/Frontend/crash.swift
@@ -0,0 +1,14 @@
+// RUN: echo %s > %t.filelist.txt
+// RUN: not --crash %target-swift-frontend -typecheck -debug-crash-after-parse -filelist %t.filelist.txt 2>&1 | %FileCheck %s
+
+// Check that we see the contents of the input file list in the crash log.
+// CHECK-LABEL: Stack dump
+// CHECK-NEXT: Program arguments: {{.*swift(c?)}} -frontend
+// CHECK-NEXT: Contents of {{.*}}.filelist.txt:
+// CHECK-NEXT: ---
+// CHECK-NEXT: test/Frontend/crash.swift{{$}}
+// CHECK-NEXT: ---
+
+func anchor() {}
+anchor()
+
diff --git a/test/IRGen/access_control.sil b/test/IRGen/access_control.sil
index eabd2f4..9da2a39 100644
--- a/test/IRGen/access_control.sil
+++ b/test/IRGen/access_control.sil
@@ -4,23 +4,19 @@
 import Swift
 
 public struct PublicStruct { var x: Int }
-// CHECK: @"$S14access_control12PublicStructVWV" = internal constant
 // CHECK: @"$S14access_control12PublicStructVMn" = {{(protected )?}}constant
 // CHECK: @"$S14access_control12PublicStructVMf" = internal constant
 
 internal struct InternalStruct { var x: Int }
-// CHECK: @"$S14access_control14InternalStructVWV" = internal constant
 // CHECK: @"$S14access_control14InternalStructVMn" = hidden constant
 // CHECK: @"$S14access_control14InternalStructVMf" = internal constant
 
 private struct PrivateStruct { var x: Int }
-// CHECK: @"$S14access_control13PrivateStruct33_8F630B0A1EEF3ED34B761E3ED76C95A8LLVWV" = internal constant
 // CHECK: @"$S14access_control13PrivateStruct33_8F630B0A1EEF3ED34B761E3ED76C95A8LLVMn" = hidden constant
 // CHECK: @"$S14access_control13PrivateStruct33_8F630B0A1EEF3ED34B761E3ED76C95A8LLVMf" = internal constant
 
 func local() {
   struct LocalStruct { var x: Int }
-  // CHECK: @"$S14access_control5localyyF11LocalStructL_VWV" = internal constant
   // CHECK: @"$S14access_control5localyyF11LocalStructL_VMn" = hidden constant
   // CHECK: @"$S14access_control5localyyF11LocalStructL_VMf" = internal constant
 }
diff --git a/test/IRGen/big_types_corner_cases.swift b/test/IRGen/big_types_corner_cases.swift
index 14b8a1e..9f98aa9 100644
--- a/test/IRGen/big_types_corner_cases.swift
+++ b/test/IRGen/big_types_corner_cases.swift
@@ -47,8 +47,8 @@
 ]
 
 // CHECK-LABEL: define{{( protected)?}} internal swiftcc void @"$S22big_types_corner_cases21OptionalInoutFuncTypeC7executeyys5Error_pSgFyyXEfU_"(%T22big_types_corner_cases9BigStructVSg* nocapture dereferenceable({{.*}}), %T22big_types_corner_cases21OptionalInoutFuncTypeC*, %T22big_types_corner_cases9BigStructVSgs5Error_pSgIegcx_Sg* nocapture dereferenceable({{.*}})
-// CHECK: call void @"$SSqWy
-// CHECK: call void @"$SSqWe
+// CHECK: call void @"$S22big_types_corner_cases9BigStructVSgs5Error_pSgIegcx_SgWy"
+// CHECK: call void @"$S22big_types_corner_cases9BigStructVSgs5Error_pSgIegcx_SgWe"
 // CHECK: ret void
 
 public func f1_returns_BigType(_ x: BigStruct) -> BigStruct {
diff --git a/test/IRGen/cf.sil b/test/IRGen/cf.sil
index e4a8735..f25ffc6 100644
--- a/test/IRGen/cf.sil
+++ b/test/IRGen/cf.sil
@@ -10,20 +10,14 @@
 // CHECK: [[MUTABLE_REFRIGERATOR:%TSo24CCMutableRefrigeratorRefa]] = type
 // CHECK: [[OBJC:%objc_object]] = type
 
-// CHECK: [[REFRIGERATOR_NAME:@.*]] = private constant [23 x i8] c"So17CCRefrigeratorRefa\00"
-
 // CHECK-32: @"$SSo17CCRefrigeratorRefaN" = linkonce_odr hidden global <{ {{.*}} }> <{
-// CHECK-32-SAME: [[REFRIGERATOR_NAME]] to i32
 // CHECK-32-SAME: i32 0,
 // CHECK-32-SAME: i8** @"$SBOWV", i32 16, {{.*}}"$SSo17CCRefrigeratorRefaMn", [[TYPE]]* null, i8* null, i8* null, i8* null }>
 
 // CHECK-64: @"$SSo17CCRefrigeratorRefaN" = linkonce_odr hidden global <{ {{.*}} }> <{
-// CHECK-64-SAME: i32 0,
-// CHECK-64-SAME: i32 trunc {{.*}} [[REFRIGERATOR_NAME]] to i64
 // CHECK-64-SAME: i64 0,
 // CHECK-64-SAME: i8** @"$SBOWV", i64 16, {{.*}}"$SSo17CCRefrigeratorRefaMn", [[TYPE]]* null, i8* null, i8* null, i8* null }>
 
-// CHECK: [[MUTABLE_REFRIGERATOR_MANGLED_NAME:@.*]] = private constant [30 x i8] c"So24CCMutableRefrigeratorRefa\00"
 // CHECK: [[MUTABLE_REFRIGERATOR_NAME:@.*]] = private constant [25 x i8] c"CCMutableRefrigeratorRef\00"
 
 // CHECK-64: @"$SSo24CCMutableRefrigeratorRefaMn" = linkonce_odr hidden constant
@@ -33,7 +27,7 @@
 
 // CHECK-64: @"$SSo24CCMutableRefrigeratorRefaN" = linkonce_odr hidden global <{ {{.*}} }> <{
 // CHECK-64-SAME: @initialize_metadata_CCMutableRefrigerator
-// CHECK-64-SAME: i32 trunc {{.*}} [[MUTABLE_REFRIGERATOR_MANGLED_NAME]] to i64
+// CHECK-64-SAME: i32 0,
 // CHECK-64-SAME: i64 1,
 // CHECK-64-SAME: i8** @"$SBOWV", i64 16, {{.*}}"$SSo24CCMutableRefrigeratorRefaMn", [[TYPE]]* bitcast{{.*}}@"$SSo17CCRefrigeratorRefaN{{.*}} to %swift.type*), i8* null, i8* null, i8* null }>
 
@@ -63,8 +57,8 @@
 // CHECK-NEXT: ret void
 
 // CHECK:    define linkonce_odr hidden [[TYPE]]* @"$SSo17CCRefrigeratorRefaMa"()
-// CHECK-32:    call [[TYPE]]* @swift_getForeignTypeMetadata([[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$SSo17CCRefrigeratorRefaN" to i8*), i32 12) to [[TYPE]]*))
-// CHECK-64:    call [[TYPE]]* @swift_getForeignTypeMetadata([[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$SSo17CCRefrigeratorRefaN" to i8*), i64 24) to [[TYPE]]*))
+// CHECK-32:    call [[TYPE]]* @swift_getForeignTypeMetadata([[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$SSo17CCRefrigeratorRefaN" to i8*), i32 8) to [[TYPE]]*))
+// CHECK-64:    call [[TYPE]]* @swift_getForeignTypeMetadata([[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$SSo17CCRefrigeratorRefaN" to i8*), i64 16) to [[TYPE]]*))
 
 // CHECK:    define private void @initialize_metadata_CCMutableRefrigerator(%swift.type*)
 // CHECK-64:   [[T0:%.*]] = bitcast %swift.type* %0 to i8**
diff --git a/test/IRGen/class_metadata.swift b/test/IRGen/class_metadata.swift
index 9344172..e1c978b 100644
--- a/test/IRGen/class_metadata.swift
+++ b/test/IRGen/class_metadata.swift
@@ -80,13 +80,13 @@
 //   Instantiation pattern.
 // CHECK-SAME: i32 {{.*}} @"$S14class_metadata1CCMP"
 //   Generic parameter count.
-// CHECK-SAME: i32 1,
+// CHECK-SAME: i16 1,
 //   Generic requirement count.
-// CHECK-SAME: i32 0,
+// CHECK-SAME: i16 0,
 //   Key generic arguments count.
-// CHECK-SAME: i32 1,
+// CHECK-SAME: i16 1,
 //   Extra generic arguments count.
-// CHECK-SAME: i32 0,
+// CHECK-SAME: i16 0,
 //   Generic parameter descriptor #1: flags. -128 == 0x80 == Key
 // CHECK-SAME: i8 -128,
 ///  Padding.
diff --git a/test/IRGen/enum.sil b/test/IRGen/enum.sil
index 8a0bd9d..50b6ec2 100644
--- a/test/IRGen/enum.sil
+++ b/test/IRGen/enum.sil
@@ -119,7 +119,7 @@
 // --       generic instantiation pattern
 // CHECK-SAME:   @"$S4enum16DynamicSingletonOMP"
 // --       generic parameters, requirements, key, extra
-// CHECK-SAME:   i32 1, i32 0, i32 1, i32 0
+// CHECK-SAME:   i16 1, i16 0, i16 1, i16 0
 // --       generic param
 // CHECK-SAME:   i8 -128,
 // CHECK-SAME: }>
diff --git a/test/IRGen/enum_function.sil b/test/IRGen/enum_function.sil
index 36a9b86..571ca11b 100644
--- a/test/IRGen/enum_function.sil
+++ b/test/IRGen/enum_function.sil
@@ -16,7 +16,7 @@
 // CHECK-32:  define hidden swiftcc void @test1([[WORD:i32]], [[WORD]])
 sil hidden @test1 : $@convention(thin) (@owned Optional<() -> ()>) -> () {
 bb0(%0 : $Optional<() -> ()>):
-  // CHECK: call void @"$SSqWy"
+  // CHECK: call void @"$SIey_SgWy"
   retain_value %0 : $Optional<() -> ()>
 
   // CHECK: icmp eq i64 %0, 0
diff --git a/test/IRGen/foreign_types.sil b/test/IRGen/foreign_types.sil
index da66e54..b82a51f 100644
--- a/test/IRGen/foreign_types.sil
+++ b/test/IRGen/foreign_types.sil
@@ -16,8 +16,7 @@
 // CHECK-SAME: @"$SSo12AmazingColorVMa"
 
 // CHECK-LABEL: @"$SSo14HasNestedUnionV18__Unnamed_struct_sVN" = linkonce_odr hidden global
-// CHECK-SAME:  [[INT:i[0-9]+]] sub ([[INT]] ptrtoint
-// CHECK-SAME:  [[INT]] 0,
+// CHECK-SAME:  [[INT:i[0-9]+]] 0,
 // CHECK-SAME:  @"$SSo14HasNestedUnionV18__Unnamed_struct_sVWV"
 // CHECK-SAME:  [[INT]] 1,
 // CHECK-SAME:  @"$SSo14HasNestedUnionV18__Unnamed_struct_sVMn"
diff --git a/test/IRGen/generic_classes.sil b/test/IRGen/generic_classes.sil
index 7b55b34..935367d 100644
--- a/test/IRGen/generic_classes.sil
+++ b/test/IRGen/generic_classes.sil
@@ -34,7 +34,7 @@
 // --       template instantiation pattern
 // CHECK-SAME:   @"$S15generic_classes11RootGenericCMP"
 // --       generic parameters, requirements, key arguments, extra arguments
-// CHECK-SAME:   i32 1, i32 0, i32 1, i32 0
+// CHECK-SAME:   i16 1, i16 0, i16 1, i16 0
 // --       vtable offset
 // CHECK-SAME:   i32 11,
 // --       vtable size
diff --git a/test/IRGen/generic_classes_objc.sil b/test/IRGen/generic_classes_objc.sil
index 9823a83..6343d41 100644
--- a/test/IRGen/generic_classes_objc.sil
+++ b/test/IRGen/generic_classes_objc.sil
@@ -69,6 +69,6 @@
 protocol P2 { }
 
 // CHECK: @"$S20generic_classes_objc16Generic3WithReqsCMn" = hidden constant
-// CHECK-SAME: i32 3, i32 3, i32 3, i32 2
+// CHECK-SAME: i16 3, i16 3, i16 3, i16 2
 class Generic3WithReqs<T: P1, U: P2, V: P2> { }
-sil_vtable Generic3WithReqs { }
\ No newline at end of file
+sil_vtable Generic3WithReqs { }
diff --git a/test/IRGen/generic_structs.sil b/test/IRGen/generic_structs.sil
index c6b67a3..f76883c 100644
--- a/test/IRGen/generic_structs.sil
+++ b/test/IRGen/generic_structs.sil
@@ -50,7 +50,7 @@
 // CHECK-SAME:   [{{[0-9]+}} x i8*]* @"$S15generic_structs13SingleDynamicVMI"
 // CHECK-SAME:   @"$S15generic_structs13SingleDynamicVMP"
 // --       generic params, requirements, key args, extra args
-// CHECK-SAME:   i32 1, i32 0, i32 1, i32 0
+// CHECK-SAME:   i16 1, i16 0, i16 1, i16 0
 // --       generic parameters
 // CHECK-SAME:   <i8 0x80>
 // CHECK-SAME: }>
@@ -73,7 +73,7 @@
 // --       field offset vector offset
 // CHECK-SAME: i32 6,
 // --       generic params, requirements, key args, extra args
-// CHECK-SAME: i32 2, i32 2, i32 2, i32 2,
+// CHECK-SAME: i16 2, i16 2, i16 2, i16 2,
 // --       generic parameters
 // CHECK-SAME: <i8 0x80>, <i8 0x80>,
 // --       generic requirement
diff --git a/test/IRGen/generic_types.swift b/test/IRGen/generic_types.swift
index ec61a28..945ba35 100644
--- a/test/IRGen/generic_types.swift
+++ b/test/IRGen/generic_types.swift
@@ -32,13 +32,13 @@
 // -- instantiation pattern
 // CHECK-SAME:   @"$S13generic_types1ACMP"
 // -- num generic params
-// CHECK-SAME:   i32 1,
+// CHECK-SAME:   i16 1,
 // -- num generic requirement
-// CHECK-SAME:   i32 0,
+// CHECK-SAME:   i16 0,
 // -- num key arguments
-// CHECK-SAME:   i32 1,
+// CHECK-SAME:   i16 1,
 // -- num extra arguments
-// CHECK-SAME:   i32 0,
+// CHECK-SAME:   i16 0,
 // -- parameter descriptor 1
 // CHECK-SAME:   i8 -128,
 
diff --git a/test/IRGen/lazy_metadata.swift b/test/IRGen/lazy_metadata.swift
index 9085e70..3c4a7fe 100644
--- a/test/IRGen/lazy_metadata.swift
+++ b/test/IRGen/lazy_metadata.swift
@@ -13,13 +13,6 @@
 // CHECK-DAG: @"$S4test7StructDVMF" =
 // CHECK-DAG: @"$S4test7StructEVMF" =
 
-// value witness tables
-// CHECK-DAG: @"$S4test7StructAVWV" =
-// CHECK-DAG: @"$S4test7StructBVWV" =
-// CHECK-DAG: @"$S4test7StructCVWV" =
-// CHECK-DEAD-NOT: @"$S4test7StructDVWV"
-// CHECK-DAG: @"$S4test7StructEVWV" =
-
 // nominal type descriptors
 // CHECK-DAG: @"$S4test7StructAVMn" =
 // CHECK-DAG: @"$S4test7StructBVMn" =
diff --git a/test/IRGen/local_types.swift b/test/IRGen/local_types.swift
index 9ccc51c..b5579bb 100644
--- a/test/IRGen/local_types.swift
+++ b/test/IRGen/local_types.swift
@@ -9,14 +9,14 @@
 import local_types_helper
 
 public func singleFunc() {
-  // CHECK-DAG: @"$S11local_types10singleFuncyyF06SingleD6StructL_VWV" = internal constant
+  // CHECK-DAG: @"$S11local_types10singleFuncyyF06SingleD6StructL_VMf" = internal constant
   struct SingleFuncStruct {
     let i: Int
   }
 }
 
 public let singleClosure: () -> () = {
-  // CHECK-DAG: @"$S11local_types13singleClosureyycvpfiyycfU_06SingleD6StructL_VWV" = internal constant
+  // CHECK-DAG: @"$S11local_types13singleClosureyycvpfiyycfU_06SingleD6StructL_VMf" = internal constant
   struct SingleClosureStruct {
     let i: Int
   }
@@ -24,7 +24,7 @@
 
 public struct PatternStruct {
   public var singlePattern: Int = ({
-    // CHECK-DAG: @"$S11local_types13PatternStructV06singleC0SivpfiSiyXEfU_06SinglecD0L_VWV" = internal constant
+    // CHECK-DAG: @"$S11local_types13PatternStructV06singleC0SivpfiSiyXEfU_06SinglecD0L_VMf" = internal constant
     struct SinglePatternStruct {
       let i: Int
     }
@@ -33,7 +33,7 @@
 }
 
 public func singleDefaultArgument(i: Int = {
-  // CHECK-DAG: @"$S11local_types21singleDefaultArgument1iySi_tFfA_SiycfU_06SingledE6StructL_VWV" = internal constant
+  // CHECK-DAG: @"$S11local_types21singleDefaultArgument1iySi_tFfA_SiycfU_06SingledE6StructL_VMf" = internal constant
   struct SingleDefaultArgumentStruct {
     let i: Int
   }
diff --git a/test/IRGen/plus_zero_big_types_corner_cases.swift b/test/IRGen/plus_zero_big_types_corner_cases.swift
index 05b8339..257dc49 100644
--- a/test/IRGen/plus_zero_big_types_corner_cases.swift
+++ b/test/IRGen/plus_zero_big_types_corner_cases.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -enable-large-loadable-types %s -emit-ir | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: optimized_stdlib
 // UNSUPPORTED: resilient_stdlib
diff --git a/test/IRGen/plus_zero_builtins.swift b/test/IRGen/plus_zero_builtins.swift
index b4479ad..4bb33e0 100644
--- a/test/IRGen/plus_zero_builtins.swift
+++ b/test/IRGen/plus_zero_builtins.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -parse-stdlib -primary-file %s -emit-ir -o - -disable-objc-attr-requires-foundation-module | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-runtime
 
 // REQUIRES: CPU=x86_64
diff --git a/test/IRGen/plus_zero_class_bounded_generics.swift b/test/IRGen/plus_zero_class_bounded_generics.swift
index 304f545..6a536fd 100644
--- a/test/IRGen/plus_zero_class_bounded_generics.swift
+++ b/test/IRGen/plus_zero_class_bounded_generics.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -emit-ir -primary-file %s -disable-objc-attr-requires-foundation-module | %FileCheck %s
 
 // REQUIRES: CPU=x86_64
diff --git a/test/IRGen/plus_zero_enum_resilience.swift b/test/IRGen/plus_zero_enum_resilience.swift
index 8332486..599e35cb 100644
--- a/test/IRGen/plus_zero_enum_resilience.swift
+++ b/test/IRGen/plus_zero_enum_resilience.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
 // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_enum.swiftmodule -module-name=resilient_enum -I %t %S/../Inputs/resilient_enum.swift
diff --git a/test/IRGen/plus_zero_generic_metatypes.swift b/test/IRGen/plus_zero_generic_metatypes.swift
index 0249939..0880594 100644
--- a/test/IRGen/plus_zero_generic_metatypes.swift
+++ b/test/IRGen/plus_zero_generic_metatypes.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %swift -target x86_64-apple-macosx10.9 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 %s
 // RUN: %swift -target i386-apple-ios7.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 %s
 // RUN: %swift -target x86_64-apple-ios7.0 -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 %s
diff --git a/test/IRGen/plus_zero_generic_metatypes_arm.swift b/test/IRGen/plus_zero_generic_metatypes_arm.swift
index ad87734..758ec0c 100644
--- a/test/IRGen/plus_zero_generic_metatypes_arm.swift
+++ b/test/IRGen/plus_zero_generic_metatypes_arm.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %swift -target armv7-apple-ios7.0 -module-name generic_metatypes -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 %s
 // RUN: %swift -target arm64-apple-ios7.0 -emit-ir -module-name generic_metatypes -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 %s
 // RUN: %swift -target armv7-apple-tvos9.0 -emit-ir -module-name generic_metatypes -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 %s
diff --git a/test/IRGen/plus_zero_generic_tuples.swift b/test/IRGen/plus_zero_generic_tuples.swift
index c45781d..3ca9a82 100644
--- a/test/IRGen/plus_zero_generic_tuples.swift
+++ b/test/IRGen/plus_zero_generic_tuples.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir -primary-file %s | %FileCheck %s
 
 // Make sure that optimization passes don't choke on storage types for generic tuples
diff --git a/test/IRGen/plus_zero_keypaths.sil b/test/IRGen/plus_zero_keypaths.sil
index 7cafbd0..0f26931 100644
--- a/test/IRGen/plus_zero_keypaths.sil
+++ b/test/IRGen/plus_zero_keypaths.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // -- Convert <i32 0x...> constants to decimal constants that LLVM will print
 // RUN: %utils/chex.py < %s > %t/keypaths.sil
diff --git a/test/IRGen/plus_zero_keypaths_objc.sil b/test/IRGen/plus_zero_keypaths_objc.sil
index 1504309..3ef5026 100644
--- a/test/IRGen/plus_zero_keypaths_objc.sil
+++ b/test/IRGen/plus_zero_keypaths_objc.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %utils/chex.py < %s > %t/keypaths_objc.sil
 // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-ir %t/keypaths_objc.sil | %FileCheck %t/keypaths_objc.sil --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
diff --git a/test/IRGen/plus_zero_lowered_optional_self_metadata.sil b/test/IRGen/plus_zero_lowered_optional_self_metadata.sil
index 005e8bb..6180497 100644
--- a/test/IRGen/plus_zero_lowered_optional_self_metadata.sil
+++ b/test/IRGen/plus_zero_lowered_optional_self_metadata.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s
 sil_stage canonical
 
diff --git a/test/IRGen/plus_zero_objc.swift b/test/IRGen/plus_zero_objc.swift
index 634a5a6..4a316d7 100644
--- a/test/IRGen/plus_zero_objc.swift
+++ b/test/IRGen/plus_zero_objc.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %build-irgen-test-overlays
 // RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -primary-file %s -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck %s
diff --git a/test/IRGen/plus_zero_objc_retainAutoreleasedReturnValue.swift b/test/IRGen/plus_zero_objc_retainAutoreleasedReturnValue.swift
index 67bf5d9..f4e530c 100644
--- a/test/IRGen/plus_zero_objc_retainAutoreleasedReturnValue.swift
+++ b/test/IRGen/plus_zero_objc_retainAutoreleasedReturnValue.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -target x86_64-apple-macosx10.12 -assume-parsing-unqualified-ownership-sil -import-objc-header %S/Inputs/StaticInline.h %s -emit-ir | %FileCheck %s
 // RUN: %target-swift-frontend -O -target x86_64-apple-macosx10.12 -assume-parsing-unqualified-ownership-sil -import-objc-header %S/Inputs/StaticInline.h %s -emit-ir | %FileCheck %s --check-prefix=OPT
 
diff --git a/test/IRGen/plus_zero_runtime_calling_conventions.swift b/test/IRGen/plus_zero_runtime_calling_conventions.swift
index 8322258..117a08d 100644
--- a/test/IRGen/plus_zero_runtime_calling_conventions.swift
+++ b/test/IRGen/plus_zero_runtime_calling_conventions.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -parse-as-library -emit-ir %s | %FileCheck %s
 // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -parse-as-library -O -emit-ir %s | %FileCheck --check-prefix=OPT-CHECK %s
 
diff --git a/test/IRGen/plus_zero_struct_resilience.swift b/test/IRGen/plus_zero_struct_resilience.swift
index 6f0bdf7..aa8a4ca 100644
--- a/test/IRGen/plus_zero_struct_resilience.swift
+++ b/test/IRGen/plus_zero_struct_resilience.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
 // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_enum.swiftmodule -module-name=resilient_enum -I %t %S/../Inputs/resilient_enum.swift
diff --git a/test/IRGen/weak.sil b/test/IRGen/weak.sil
index 6f23e84..178111b 100644
--- a/test/IRGen/weak.sil
+++ b/test/IRGen/weak.sil
@@ -77,7 +77,7 @@
 // CHECK-NEXT: store i8** [[TMPTAB]], i8*** [[T0]], align 8
 // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds { [[WEAK]], i8** }, { [[WEAK]], i8** }* [[X]], i32 0, i32 0
 // CHECK-NEXT: call [[WEAK]]* @swift_unknownWeakAssign([[WEAK]]* returned [[T0]], [[UNKNOWN]]* [[TMPOBJ]])
-// CHECK: call void @"$SSqWe"
+// CHECK: call void @"$S4weak1P_pSgWe"
 
 sil @test_weak_alloc_stack : $@convention(thin) (Optional<P>) -> () {
 bb0(%0 : $Optional<P>):
diff --git a/test/Reflection/plus_zero_capture_descriptors.sil b/test/Reflection/plus_zero_capture_descriptors.sil
index dab2c61..937feb6 100644
--- a/test/Reflection/plus_zero_capture_descriptors.sil
+++ b/test/Reflection/plus_zero_capture_descriptors.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // REQUIRES: no_asan
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift %s -emit-module -emit-library -module-name capture_descriptors -o %t/capture_descriptors.%target-dylib-extension
diff --git a/test/SIL/Parser/plus_zero_apply_with_substitution.sil b/test/SIL/Parser/plus_zero_apply_with_substitution.sil
index a63e3c0..287d85e 100644
--- a/test/SIL/Parser/plus_zero_apply_with_substitution.sil
+++ b/test/SIL/Parser/plus_zero_apply_with_substitution.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend %s -emit-silgen | %FileCheck %s
 
 // rdar://14443287
diff --git a/test/SIL/Parser/plus_zero_bound_generic.sil b/test/SIL/Parser/plus_zero_bound_generic.sil
index c535ee7..2d054ac 100644
--- a/test/SIL/Parser/plus_zero_bound_generic.sil
+++ b/test/SIL/Parser/plus_zero_bound_generic.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend %s -emit-silgen | %FileCheck %s
 
 // rdar://14443287
diff --git a/test/SIL/Parser/plus_zero_generic_signature_with_depth.swift b/test/SIL/Parser/plus_zero_generic_signature_with_depth.swift
index f25a2a4..a3699f9 100644
--- a/test/SIL/Parser/plus_zero_generic_signature_with_depth.swift
+++ b/test/SIL/Parser/plus_zero_generic_signature_with_depth.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend %s -emit-silgen | %target-sil-opt | %FileCheck %s
 
 protocol mmGeneratorType {
diff --git a/test/SIL/Parser/plus_zero_keypath.sil b/test/SIL/Parser/plus_zero_keypath.sil
index 7c9b0a0..7b94b57 100644
--- a/test/SIL/Parser/plus_zero_keypath.sil
+++ b/test/SIL/Parser/plus_zero_keypath.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-sil-opt %s | %target-sil-opt | %FileCheck %s
 
 sil_stage canonical
diff --git a/test/SIL/Serialization/plus_zero_deserialize_generic.sil b/test/SIL/Serialization/plus_zero_deserialize_generic.sil
index d8aa071..10a9db5 100644
--- a/test/SIL/Serialization/plus_zero_deserialize_generic.sil
+++ b/test/SIL/Serialization/plus_zero_deserialize_generic.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/def_generic.swift
 // RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -linker -I %t %s | %FileCheck %s
diff --git a/test/SIL/Serialization/plus_zero_deserialize_generic_marker.sil b/test/SIL/Serialization/plus_zero_deserialize_generic_marker.sil
index bb3984d..53a1ccd 100644
--- a/test/SIL/Serialization/plus_zero_deserialize_generic_marker.sil
+++ b/test/SIL/Serialization/plus_zero_deserialize_generic_marker.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/def_generic_marker.swift
 // RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -linker -I %t %s | %FileCheck %s
diff --git a/test/SIL/Serialization/plus_zero_keypath.sil b/test/SIL/Serialization/plus_zero_keypath.sil
index 00a9747..7f9a33f 100644
--- a/test/SIL/Serialization/plus_zero_keypath.sil
+++ b/test/SIL/Serialization/plus_zero_keypath.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // First parse this and then emit a *.sib. Then read in the *.sib, then recreate
 // RUN: %empty-directory(%t)
 // RUN: %target-sil-opt %s -emit-sib -o %t/tmp.sib -module-name boxes
diff --git a/test/SILGen/plus_zero_access_marker_gen.swift b/test/SILGen/plus_zero_access_marker_gen.swift
index 6781648..ee71398 100644
--- a/test/SILGen/plus_zero_access_marker_gen.swift
+++ b/test/SILGen/plus_zero_access_marker_gen.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -parse-as-library -Xllvm -sil-full-demangle -enforce-exclusivity=checked -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name access_marker_gen -parse-as-library -Xllvm -sil-full-demangle -enforce-exclusivity=checked -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 func modify<T>(_ x: inout T) {}
 
diff --git a/test/SILGen/plus_zero_accessors.swift b/test/SILGen/plus_zero_accessors.swift
index 1f8a135..814e0ee 100644
--- a/test/SILGen/plus_zero_accessors.swift
+++ b/test/SILGen/plus_zero_accessors.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name accessors -Xllvm -sil-full-demangle -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 // Hold a reference to do to magically become non-POD.
 class Reference {}
diff --git a/test/SILGen/plus_zero_address_only_types.swift b/test/SILGen/plus_zero_address_only_types.swift
index e270074..878219f 100644
--- a/test/SILGen/plus_zero_address_only_types.swift
+++ b/test/SILGen/plus_zero_address_only_types.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -enable-sil-ownership -parse-as-library -parse-stdlib -emit-silgen %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name address_only_types -enable-sil-ownership -parse-as-library -parse-stdlib -emit-silgen %s | %FileCheck %s
 
 precedencegroup AssignmentPrecedence { assignment: true }
 
diff --git a/test/SILGen/plus_zero_addressors.swift b/test/SILGen/plus_zero_addressors.swift
index 10cdb59..6dbf9ca 100644
--- a/test/SILGen/plus_zero_addressors.swift
+++ b/test/SILGen/plus_zero_addressors.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -enable-sil-ownership -parse-stdlib -emit-sil %s | %FileCheck %s
 // RUN: %target-swift-frontend -enable-sil-ownership -parse-stdlib -emit-silgen %s | %FileCheck %s -check-prefix=SILGEN
 // RUN: %target-swift-frontend -enable-sil-ownership -parse-stdlib -emit-ir %s
diff --git a/test/SILGen/plus_zero_apply_abstraction_nested.swift b/test/SILGen/plus_zero_apply_abstraction_nested.swift
index f1143d9..89d75eb 100644
--- a/test/SILGen/plus_zero_apply_abstraction_nested.swift
+++ b/test/SILGen/plus_zero_apply_abstraction_nested.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -enable-sil-ownership -emit-silgen %s | %FileCheck %s
 
 infix operator ~> { precedence 255 associativity left }
diff --git a/test/SILGen/plus_zero_argument_labels.swift b/test/SILGen/plus_zero_argument_labels.swift
index 95bb1d6..8ea28c8 100644
--- a/test/SILGen/plus_zero_argument_labels.swift
+++ b/test/SILGen/plus_zero_argument_labels.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name argument_labels -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 public struct X { }
 public struct Y { }
diff --git a/test/SILGen/plus_zero_argument_shuffle_swift3.swift b/test/SILGen/plus_zero_argument_shuffle_swift3.swift
index d76bb29..7cdda82 100644
--- a/test/SILGen/plus_zero_argument_shuffle_swift3.swift
+++ b/test/SILGen/plus_zero_argument_shuffle_swift3.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s -swift-version 3 | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name argument_shuffle_swift3 -emit-silgen -enable-sil-ownership %s -swift-version 3 | %FileCheck %s
 
 func fn(_: Any) {}
 
diff --git a/test/SILGen/plus_zero_array_literal_abstraction.swift b/test/SILGen/plus_zero_array_literal_abstraction.swift
index d7f1e36..57e6b6d 100644
--- a/test/SILGen/plus_zero_array_literal_abstraction.swift
+++ b/test/SILGen/plus_zero_array_literal_abstraction.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name array_literal_abstraction -emit-silgen %s | %FileCheck %s
 
 // Verify that reabstraction happens when forming container literals.
 // <rdar://problem/16039286>
diff --git a/test/SILGen/plus_zero_auto_closures.swift b/test/SILGen/plus_zero_auto_closures.swift
index 0adc57e..2fffe7a 100644
--- a/test/SILGen/plus_zero_auto_closures.swift
+++ b/test/SILGen/plus_zero_auto_closures.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -parse-stdlib -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name auto_closures  -parse-stdlib -emit-silgen %s | %FileCheck %s
 
 struct Bool {}
 var false_ = Bool()
diff --git a/test/SILGen/plus_zero_borrow.swift b/test/SILGen/plus_zero_borrow.swift
index 5dcec6f..43a128e 100644
--- a/test/SILGen/plus_zero_borrow.swift
+++ b/test/SILGen/plus_zero_borrow.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -enable-sil-ownership -parse-stdlib -emit-silgen %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name borrow -enable-sil-ownership -parse-stdlib -emit-silgen %s | %FileCheck %s
 
 import Swift
 
diff --git a/test/SILGen/plus_zero_boxed_existentials.swift b/test/SILGen/plus_zero_boxed_existentials.swift
index 70b4197..2a544be 100644
--- a/test/SILGen/plus_zero_boxed_existentials.swift
+++ b/test/SILGen/plus_zero_boxed_existentials.swift
@@ -1,6 +1,7 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen %s | %FileCheck %s
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen %s | %FileCheck %s --check-prefix=GUARANTEED
+
+// RUN: %target-swift-frontend -module-name boxed_existentials -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name boxed_existentials -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen %s | %FileCheck %s --check-prefix=GUARANTEED
 
 func test_type_lowering(_ x: Error) { }
 // CHECK-LABEL: sil hidden @$S18boxed_existentials18test_type_loweringyys5Error_pF : $@convention(thin) (@guaranteed Error) -> () {
diff --git a/test/SILGen/plus_zero_call_chain_reabstraction.swift b/test/SILGen/plus_zero_call_chain_reabstraction.swift
index 123c453..c9d8e6f 100644
--- a/test/SILGen/plus_zero_call_chain_reabstraction.swift
+++ b/test/SILGen/plus_zero_call_chain_reabstraction.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name call_chain_reabstraction -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 struct A {
         func g<U>(_ recur: (A, U) -> U) -> (A, U) -> U {
diff --git a/test/SILGen/plus_zero_capture_typed_boxes.swift b/test/SILGen/plus_zero_capture_typed_boxes.swift
index c33dad1..995cd61 100644
--- a/test/SILGen/plus_zero_capture_typed_boxes.swift
+++ b/test/SILGen/plus_zero_capture_typed_boxes.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name capture_typed_boxes -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 func foo(_ x: Int) -> () -> Int {
   var x = x
diff --git a/test/SILGen/plus_zero_casts.swift b/test/SILGen/plus_zero_casts.swift
index 6944bbd..13a3763 100644
--- a/test/SILGen/plus_zero_casts.swift
+++ b/test/SILGen/plus_zero_casts.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name casts -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 class B { }
 class D : B { }
diff --git a/test/SILGen/plus_zero_cf.swift b/test/SILGen/plus_zero_cf.swift
index ac4e227..215bc08 100644
--- a/test/SILGen/plus_zero_cf.swift
+++ b/test/SILGen/plus_zero_cf.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -import-cf-types -sdk %S/Inputs %s -emit-silgen -o - | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name cf -import-cf-types -sdk %S/Inputs %s -emit-silgen -o - | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_class_bound_protocols.swift b/test/SILGen/plus_zero_class_bound_protocols.swift
index a6b66b8..3cf9139 100644
--- a/test/SILGen/plus_zero_class_bound_protocols.swift
+++ b/test/SILGen/plus_zero_class_bound_protocols.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -parse-stdlib -parse-as-library -module-name Swift -emit-silgen %s | %FileCheck %s
 
 enum Optional<T> {
diff --git a/test/SILGen/plus_zero_class_resilience.swift b/test/SILGen/plus_zero_class_resilience.swift
index 5421688..c456a99 100644
--- a/test/SILGen/plus_zero_class_resilience.swift
+++ b/test/SILGen/plus_zero_class_resilience.swift
@@ -1,8 +1,9 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
 // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_class.swiftmodule -module-name=resilient_class -I %t %S/../Inputs/resilient_class.swift
-// RUN: %target-swift-frontend -I %t -emit-silgen -enable-sil-ownership -enable-resilience %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name class_resilience -I %t -emit-silgen -enable-sil-ownership -enable-resilience %s | %FileCheck %s
 
 import resilient_class
 
diff --git a/test/SILGen/plus_zero_closures.swift b/test/SILGen/plus_zero_closures.swift
index 2442f4b..1707dbd 100644
--- a/test/SILGen/plus_zero_closures.swift
+++ b/test/SILGen/plus_zero_closures.swift
@@ -1,6 +1,7 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -enable-sil-ownership -parse-stdlib -parse-as-library -emit-silgen %s | %FileCheck %s
-// RUN: %target-swift-frontend -enable-sil-ownership -parse-stdlib -parse-as-library -emit-silgen  %s | %FileCheck %s --check-prefix=GUARANTEED
+
+// RUN: %target-swift-frontend -module-name closures -enable-sil-ownership -parse-stdlib -parse-as-library -emit-silgen %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name closures -enable-sil-ownership -parse-stdlib -parse-as-library -emit-silgen  %s | %FileCheck %s --check-prefix=GUARANTEED
 
 import Swift
 
diff --git a/test/SILGen/plus_zero_collection_downcast.swift b/test/SILGen/plus_zero_collection_downcast.swift
index 30f16af..eacfa6f 100644
--- a/test/SILGen/plus_zero_collection_downcast.swift
+++ b/test/SILGen/plus_zero_collection_downcast.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -sdk %S/Inputs -I %S/Inputs -enable-source-import %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name collection_downcast -emit-silgen -sdk %S/Inputs -I %S/Inputs -enable-source-import %s | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_collection_subtype_downcast.swift b/test/SILGen/plus_zero_collection_subtype_downcast.swift
index 251eb9e..ec141d0 100644
--- a/test/SILGen/plus_zero_collection_subtype_downcast.swift
+++ b/test/SILGen/plus_zero_collection_subtype_downcast.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -sdk %S/Inputs %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name collection_subtype_downcast -emit-silgen -enable-sil-ownership -sdk %S/Inputs %s | %FileCheck %s
 
 struct S { var x, y: Int }
 
diff --git a/test/SILGen/plus_zero_collection_subtype_upcast.swift b/test/SILGen/plus_zero_collection_subtype_upcast.swift
index a0d1a13..88338c0 100644
--- a/test/SILGen/plus_zero_collection_subtype_upcast.swift
+++ b/test/SILGen/plus_zero_collection_subtype_upcast.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -sdk %S/Inputs %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name collection_subtype_upcast -emit-silgen -enable-sil-ownership -sdk %S/Inputs %s | %FileCheck %s
 
 struct S { var x, y: Int }
 
diff --git a/test/SILGen/plus_zero_collection_upcast.swift b/test/SILGen/plus_zero_collection_upcast.swift
index c0bb574..90e4985 100644
--- a/test/SILGen/plus_zero_collection_upcast.swift
+++ b/test/SILGen/plus_zero_collection_upcast.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -sdk %S/Inputs -I %S/Inputs -enable-source-import %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name collection_upcast -emit-silgen -sdk %S/Inputs -I %S/Inputs -enable-source-import %s | %FileCheck %s
 
 // FIXME: rdar://problem/19648117 Needs splitting objc parts out
 // XFAIL: linux
diff --git a/test/SILGen/plus_zero_constrained_extensions.swift b/test/SILGen/plus_zero_constrained_extensions.swift
index 4bf0015..9b28d7f 100644
--- a/test/SILGen/plus_zero_constrained_extensions.swift
+++ b/test/SILGen/plus_zero_constrained_extensions.swift
@@ -1,7 +1,8 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -primary-file %s | %FileCheck %s
-// RUN: %target-swift-frontend -emit-sil -O -primary-file %s > /dev/null
-// RUN: %target-swift-frontend -emit-ir -primary-file %s > /dev/null
+
+// RUN: %target-swift-frontend -module-name constrained_extensions -emit-silgen -enable-sil-ownership -primary-file %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name constrained_extensions -emit-sil -O -primary-file %s > /dev/null
+// RUN: %target-swift-frontend -module-name constrained_extensions -emit-ir -primary-file %s > /dev/null
 
 extension Array where Element == Int {
   // CHECK-LABEL: sil @$SSa22constrained_extensionsSiRszlE1xSaySiGyt_tcfC : $@convention(method) (@thin Array<Int>.Type) -> @owned Array<Int>
diff --git a/test/SILGen/plus_zero_default_arguments.swift b/test/SILGen/plus_zero_default_arguments.swift
index ad5ff0e..645a1f5 100644
--- a/test/SILGen/plus_zero_default_arguments.swift
+++ b/test/SILGen/plus_zero_default_arguments.swift
@@ -1,9 +1,10 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 3 %s | %FileCheck %s
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 3 %s | %FileCheck %s --check-prefix=NEGATIVE
 
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 4 %s | %FileCheck %s
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 4 %s | %FileCheck %s --check-prefix=NEGATIVE
+// RUN: %target-swift-frontend -module-name default_arguments -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 3 %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name default_arguments -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 3 %s | %FileCheck %s --check-prefix=NEGATIVE
+
+// RUN: %target-swift-frontend -module-name default_arguments -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 4 %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name default_arguments -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 4 %s | %FileCheck %s --check-prefix=NEGATIVE
 
 // __FUNCTION__ used as top-level parameter produces the module name.
 // CHECK-LABEL: sil @main
diff --git a/test/SILGen/plus_zero_default_arguments_generic.swift b/test/SILGen/plus_zero_default_arguments_generic.swift
index b382f5b..1477fcc 100644
--- a/test/SILGen/plus_zero_default_arguments_generic.swift
+++ b/test/SILGen/plus_zero_default_arguments_generic.swift
@@ -1,6 +1,7 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -swift-version 3 %s | %FileCheck %s
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -swift-version 4 %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name default_arguments_generic -emit-silgen -enable-sil-ownership -swift-version 3 %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name default_arguments_generic -emit-silgen -enable-sil-ownership -swift-version 4 %s | %FileCheck %s
 
 func foo<T: ExpressibleByIntegerLiteral>(_: T.Type, x: T = 0) { }
 
diff --git a/test/SILGen/plus_zero_default_arguments_serialized.swift b/test/SILGen/plus_zero_default_arguments_serialized.swift
index 1472952..8da51e7 100644
--- a/test/SILGen/plus_zero_default_arguments_serialized.swift
+++ b/test/SILGen/plus_zero_default_arguments_serialized.swift
@@ -1,12 +1,13 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -emit-module-path %t/default_arguments_other.swiftmodule -emit-module -swift-version 4 -primary-file %S/Inputs/default_arguments_other.swift
 
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 3 -I %t %s | %FileCheck %s --check-prefix=SWIFT3 --check-prefix=CHECK
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 4 -I %t %s | %FileCheck %s --check-prefix=SWIFT4 --check-prefix=CHECK
+// RUN: %target-swift-frontend -module-name default_arguments_serialized -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 3 -I %t %s | %FileCheck %s --check-prefix=SWIFT3 --check-prefix=CHECK
+// RUN: %target-swift-frontend -module-name default_arguments_serialized -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 4 -I %t %s | %FileCheck %s --check-prefix=SWIFT4 --check-prefix=CHECK
 
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-sil -O -swift-version 3 -I %t %s | %FileCheck %s --check-prefix=OPT
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-sil -O -swift-version 4 -I %t %s | %FileCheck %s --check-prefix=OPT
+// RUN: %target-swift-frontend -module-name default_arguments_serialized -Xllvm -sil-full-demangle -enable-sil-ownership -emit-sil -O -swift-version 3 -I %t %s | %FileCheck %s --check-prefix=OPT
+// RUN: %target-swift-frontend -module-name default_arguments_serialized -Xllvm -sil-full-demangle -enable-sil-ownership -emit-sil -O -swift-version 4 -I %t %s | %FileCheck %s --check-prefix=OPT
 
 // Check that default arguments are serialized in Swift 4 mode.
 
diff --git a/test/SILGen/plus_zero_dependent_member_lowering.swift b/test/SILGen/plus_zero_dependent_member_lowering.swift
index be5785f..b051e99 100644
--- a/test/SILGen/plus_zero_dependent_member_lowering.swift
+++ b/test/SILGen/plus_zero_dependent_member_lowering.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name dependent_member_lowering -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 protocol P {
   associatedtype A
diff --git a/test/SILGen/plus_zero_downcast_reabstraction.swift b/test/SILGen/plus_zero_downcast_reabstraction.swift
index 52608d2..a16c28f 100644
--- a/test/SILGen/plus_zero_downcast_reabstraction.swift
+++ b/test/SILGen/plus_zero_downcast_reabstraction.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name downcast_reabstraction -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 // CHECK-LABEL: sil hidden @$S22downcast_reabstraction19condFunctionFromAnyyyypF
 // CHECK:         checked_cast_addr_br take_always Any in [[IN:%.*]] : $*Any to () -> () in [[OUT:%.*]] : $*@callee_guaranteed (@in_guaranteed ()) -> @out (), [[YES:bb[0-9]+]], [[NO:bb[0-9]+]]
diff --git a/test/SILGen/plus_zero_dynamic.swift b/test/SILGen/plus_zero_dynamic.swift
index 2376ae7..344a6ab 100644
--- a/test/SILGen/plus_zero_dynamic.swift
+++ b/test/SILGen/plus_zero_dynamic.swift
@@ -1,9 +1,10 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %build-silgen-test-overlays
 
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -Xllvm -sil-full-demangle -primary-file %s %S/Inputs/dynamic_other.swift -emit-silgen | %FileCheck %s
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -Xllvm -sil-full-demangle -primary-file %s %S/Inputs/dynamic_other.swift -emit-sil -verify
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -module-name dynamic -Xllvm -sil-full-demangle -primary-file %s %S/Inputs/dynamic_other.swift -emit-silgen | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -module-name dynamic -Xllvm -sil-full-demangle -primary-file %s %S/Inputs/dynamic_other.swift -emit-sil -verify
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_dynamic_lookup.swift b/test/SILGen/plus_zero_dynamic_lookup.swift
index 64062f5..83317fa 100644
--- a/test/SILGen/plus_zero_dynamic_lookup.swift
+++ b/test/SILGen/plus_zero_dynamic_lookup.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -parse-as-library -emit-silgen -disable-objc-attr-requires-foundation-module %s | %FileCheck %s
 // RUN: %target-swift-frontend -parse-as-library -emit-silgen -disable-objc-attr-requires-foundation-module  %s | %FileCheck %s --check-prefix=GUARANTEED
 
diff --git a/test/SILGen/plus_zero_dynamic_lookup_throws.swift b/test/SILGen/plus_zero_dynamic_lookup_throws.swift
index 6b2a455..e5ee3c0 100644
--- a/test/SILGen/plus_zero_dynamic_lookup_throws.swift
+++ b/test/SILGen/plus_zero_dynamic_lookup_throws.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %build-clang-importer-objc-overlays
 
diff --git a/test/SILGen/plus_zero_dynamic_self.swift b/test/SILGen/plus_zero_dynamic_self.swift
index d02f276..855d20d 100644
--- a/test/SILGen/plus_zero_dynamic_self.swift
+++ b/test/SILGen/plus_zero_dynamic_self.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s -disable-objc-attr-requires-foundation-module | %FileCheck %s
 // RUN: %target-swift-frontend -emit-sil -O %s -disable-objc-attr-requires-foundation-module
 // RUN: %target-swift-frontend -emit-ir %s -disable-objc-attr-requires-foundation-module
diff --git a/test/SILGen/plus_zero_enum.swift b/test/SILGen/plus_zero_enum.swift
index 53a818c..d68f765 100644
--- a/test/SILGen/plus_zero_enum.swift
+++ b/test/SILGen/plus_zero_enum.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -parse-stdlib -parse-as-library -emit-silgen -enable-sil-ownership -module-name Swift %s | %FileCheck %s
 
 precedencegroup AssignmentPrecedence { assignment: true }
diff --git a/test/SILGen/plus_zero_enum_resilience.swift b/test/SILGen/plus_zero_enum_resilience.swift
index 7b5ac8a..cb50fa7 100644
--- a/test/SILGen/plus_zero_enum_resilience.swift
+++ b/test/SILGen/plus_zero_enum_resilience.swift
@@ -1,8 +1,9 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
 // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_enum.swiftmodule -module-name=resilient_enum -I %t %S/../Inputs/resilient_enum.swift
-// RUN: %target-swift-frontend -I %t -enable-sil-ownership -emit-silgen -enable-resilience %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name enum_resilience -I %t -enable-sil-ownership -emit-silgen -enable-resilience %s | %FileCheck %s
 
 import resilient_enum
 
diff --git a/test/SILGen/plus_zero_erasure_reabstraction.swift b/test/SILGen/plus_zero_erasure_reabstraction.swift
index 1c2c0eb..b426126 100644
--- a/test/SILGen/plus_zero_erasure_reabstraction.swift
+++ b/test/SILGen/plus_zero_erasure_reabstraction.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 struct Foo {}
diff --git a/test/SILGen/plus_zero_existential_erasure.swift b/test/SILGen/plus_zero_existential_erasure.swift
index a60024f..4286322 100644
--- a/test/SILGen/plus_zero_existential_erasure.swift
+++ b/test/SILGen/plus_zero_existential_erasure.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name existential_erasure -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 protocol P {
   func downgrade(_ m68k: Bool) -> Self
diff --git a/test/SILGen/plus_zero_expressions.swift b/test/SILGen/plus_zero_expressions.swift
index 293c8fe..19634f9 100644
--- a/test/SILGen/plus_zero_expressions.swift
+++ b/test/SILGen/plus_zero_expressions.swift
@@ -1,7 +1,8 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: echo "public var x = Int()" | %target-swift-frontend -module-name FooBar -emit-module -o %t -
-// RUN: %target-swift-frontend -parse-stdlib -emit-silgen -enable-sil-ownership %s -I%t -disable-access-control | %FileCheck %s
+// RUN: %target-swift-frontend -parse-stdlib -module-name expressions -emit-silgen -enable-sil-ownership %s -I%t -disable-access-control | %FileCheck %s
 
 import Swift
 import FooBar
diff --git a/test/SILGen/plus_zero_extensions_objc.swift b/test/SILGen/plus_zero_extensions_objc.swift
index 24a9cb7..d84b0ee 100644
--- a/test/SILGen/plus_zero_extensions_objc.swift
+++ b/test/SILGen/plus_zero_extensions_objc.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -sdk %S/Inputs %s -I %S/Inputs -enable-source-import -emit-silgen -enable-sil-ownership | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name extensions_objc -sdk %S/Inputs %s -I %S/Inputs -enable-source-import -emit-silgen -enable-sil-ownership | %FileCheck %s
 //
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_external_definitions.swift b/test/SILGen/plus_zero_external_definitions.swift
index eed168f..0f6017d 100644
--- a/test/SILGen/plus_zero_external_definitions.swift
+++ b/test/SILGen/plus_zero_external_definitions.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -sdk %S/Inputs %s -emit-silgen -enable-sil-ownership | %FileCheck %s
 
 // REQUIRES: objc_interop
diff --git a/test/SILGen/plus_zero_final.swift b/test/SILGen/plus_zero_final.swift
index 3e9133b..7452af7 100644
--- a/test/SILGen/plus_zero_final.swift
+++ b/test/SILGen/plus_zero_final.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name final -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 class TestClass {
 
diff --git a/test/SILGen/plus_zero_force_cast_chained_optional.swift b/test/SILGen/plus_zero_force_cast_chained_optional.swift
index d903e82..d01c859 100644
--- a/test/SILGen/plus_zero_force_cast_chained_optional.swift
+++ b/test/SILGen/plus_zero_force_cast_chained_optional.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name force_cast_chained_optional -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 class Foo {
   var bar: Bar!
diff --git a/test/SILGen/plus_zero_foreach.swift b/test/SILGen/plus_zero_foreach.swift
index 7a3589b..2c8fbff 100644
--- a/test/SILGen/plus_zero_foreach.swift
+++ b/test/SILGen/plus_zero_foreach.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name foreach -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 //////////////////
 // Declarations //
diff --git a/test/SILGen/plus_zero_foreign_errors.swift b/test/SILGen/plus_zero_foreign_errors.swift
index d004d8f..eb7c0bc 100644
--- a/test/SILGen/plus_zero_foreign_errors.swift
+++ b/test/SILGen/plus_zero_foreign_errors.swift
@@ -1,7 +1,8 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %build-clang-importer-objc-overlays
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-silgen -parse-as-library %s | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -module-name foreign_errors -emit-silgen -parse-as-library %s | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_function_conversion.swift b/test/SILGen/plus_zero_function_conversion.swift
index a3dc163..eaefe6e 100644
--- a/test/SILGen/plus_zero_function_conversion.swift
+++ b/test/SILGen/plus_zero_function_conversion.swift
@@ -1,6 +1,7 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -primary-file %s | %FileCheck %s
-// RUN: %target-swift-frontend -emit-ir -enable-sil-ownership -primary-file %s
+
+// RUN: %target-swift-frontend -module-name function_conversion -emit-silgen -enable-sil-ownership -primary-file %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name function_conversion -emit-ir -enable-sil-ownership -primary-file %s
 
 // Check SILGen against various FunctionConversionExprs emitted by Sema.
 
diff --git a/test/SILGen/plus_zero_function_conversion_objc.swift b/test/SILGen/plus_zero_function_conversion_objc.swift
index 3314382..1dc64e6 100644
--- a/test/SILGen/plus_zero_function_conversion_objc.swift
+++ b/test/SILGen/plus_zero_function_conversion_objc.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -sdk %S/Inputs %s -I %S/Inputs -enable-sil-ownership -enable-source-import -emit-silgen -verify | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name function_conversion_objc -sdk %S/Inputs %s -I %S/Inputs -enable-sil-ownership -enable-source-import -emit-silgen -verify | %FileCheck %s
 
 import Foundation
 
diff --git a/test/SILGen/plus_zero_functions.swift b/test/SILGen/plus_zero_functions.swift
index e43048d..dbc6c1c 100644
--- a/test/SILGen/plus_zero_functions.swift
+++ b/test/SILGen/plus_zero_functions.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -parse-stdlib -parse-as-library -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name functions -Xllvm -sil-full-demangle -parse-stdlib -parse-as-library -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 import Swift // just for Optional
 
diff --git a/test/SILGen/plus_zero_generic_casts.swift b/test/SILGen/plus_zero_generic_casts.swift
index 1f857b0..bd9c2cd 100644
--- a/test/SILGen/plus_zero_generic_casts.swift
+++ b/test/SILGen/plus_zero_generic_casts.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen -enable-sil-ownership %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-runtime %s
+
+// RUN: %target-swift-frontend -module-name generic_casts -Xllvm -sil-full-demangle -emit-silgen -enable-sil-ownership %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-runtime %s
 
 protocol ClassBound : class {}
 protocol NotClassBound {}
diff --git a/test/SILGen/plus_zero_generic_closures.swift b/test/SILGen/plus_zero_generic_closures.swift
index 174912d..6e211c5 100644
--- a/test/SILGen/plus_zero_generic_closures.swift
+++ b/test/SILGen/plus_zero_generic_closures.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -parse-stdlib -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name generic_closures  -parse-stdlib -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 import Swift
 
diff --git a/test/SILGen/plus_zero_generic_property_base_lifetime.swift b/test/SILGen/plus_zero_generic_property_base_lifetime.swift
index 17f3823..0ac207d 100644
--- a/test/SILGen/plus_zero_generic_property_base_lifetime.swift
+++ b/test/SILGen/plus_zero_generic_property_base_lifetime.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen %s -disable-objc-attr-requires-foundation-module -enable-sil-ownership | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name generic_property_base_lifetime -emit-silgen %s -disable-objc-attr-requires-foundation-module -enable-sil-ownership | %FileCheck %s
 
 protocol ProtocolA: class {
     var intProp: Int { get set }
diff --git a/test/SILGen/plus_zero_generic_tuples.swift b/test/SILGen/plus_zero_generic_tuples.swift
index d3053a1..53193e6 100644
--- a/test/SILGen/plus_zero_generic_tuples.swift
+++ b/test/SILGen/plus_zero_generic_tuples.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -parse-as-library -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name generic_tuples -emit-silgen -parse-as-library -enable-sil-ownership %s | %FileCheck %s
 
 
 func dup<T>(_ x: T) -> (T, T) { return (x,x) }
diff --git a/test/SILGen/plus_zero_generic_witness.swift b/test/SILGen/plus_zero_generic_witness.swift
index a450270..f5998e7 100644
--- a/test/SILGen/plus_zero_generic_witness.swift
+++ b/test/SILGen/plus_zero_generic_witness.swift
@@ -1,6 +1,7 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
-// RUN: %target-swift-frontend -emit-ir -enable-sil-ownership %s
+
+// RUN: %target-swift-frontend -module-name generic_witness -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name generic_witness -emit-ir -enable-sil-ownership %s
 
 protocol Runcible {
   func runce<A>(_ x: A)
diff --git a/test/SILGen/plus_zero_guaranteed_normal_args.swift b/test/SILGen/plus_zero_guaranteed_normal_args.swift
index fdcec6c..da3ca90 100644
--- a/test/SILGen/plus_zero_guaranteed_normal_args.swift
+++ b/test/SILGen/plus_zero_guaranteed_normal_args.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -parse-as-library -module-name Swift -parse-stdlib -emit-silgen -enable-sil-ownership -enable-guaranteed-normal-arguments %s | %FileCheck %s
 
 // This test checks specific codegen related to normal arguments being passed at
diff --git a/test/SILGen/plus_zero_guaranteed_self.swift b/test/SILGen/plus_zero_guaranteed_self.swift
index f8f4faa..2a6c85d 100644
--- a/test/SILGen/plus_zero_guaranteed_self.swift
+++ b/test/SILGen/plus_zero_guaranteed_self.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen %s -disable-objc-attr-requires-foundation-module -enable-sil-ownership | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name guaranteed_self -Xllvm -sil-full-demangle -emit-silgen %s -disable-objc-attr-requires-foundation-module -enable-sil-ownership | %FileCheck %s
 
 protocol Fooable {
   init()
diff --git a/test/SILGen/plus_zero_if_while_binding.swift b/test/SILGen/plus_zero_if_while_binding.swift
index 4152501..1c1ec5a 100644
--- a/test/SILGen/plus_zero_if_while_binding.swift
+++ b/test/SILGen/plus_zero_if_while_binding.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name if_while_binding -Xllvm -sil-full-demangle -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 func foo() -> String? { return "" }
 func bar() -> String? { return "" }
diff --git a/test/SILGen/plus_zero_implicitly_unwrapped_optional.swift b/test/SILGen/plus_zero_implicitly_unwrapped_optional.swift
index 55f3112..e172739 100644
--- a/test/SILGen/plus_zero_implicitly_unwrapped_optional.swift
+++ b/test/SILGen/plus_zero_implicitly_unwrapped_optional.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name implicitly_unwrapped_optional -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 func foo(f f: (() -> ())!) {
   var f: (() -> ())! = f
diff --git a/test/SILGen/plus_zero_indirect_enum.swift b/test/SILGen/plus_zero_indirect_enum.swift
index 2d609f0..4c8e0a2 100644
--- a/test/SILGen/plus_zero_indirect_enum.swift
+++ b/test/SILGen/plus_zero_indirect_enum.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-print-debuginfo -emit-silgen %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name indirect_enum -Xllvm -sil-print-debuginfo -emit-silgen %s | %FileCheck %s
 
 indirect enum TreeA<T> {
   case Nil
diff --git a/test/SILGen/plus_zero_inlineable_attribute.swift b/test/SILGen/plus_zero_inlineable_attribute.swift
index 097ea60..cfe3797 100644
--- a/test/SILGen/plus_zero_inlineable_attribute.swift
+++ b/test/SILGen/plus_zero_inlineable_attribute.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -emit-verbose-sil %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name inlineable_attribute -emit-silgen -enable-sil-ownership -emit-verbose-sil %s | %FileCheck %s
 
 // CHECK-LABEL: sil [serialized] @$S20inlineable_attribute15fragileFunctionyyF : $@convention(thin) () -> ()
 @_inlineable public func fragileFunction() {
diff --git a/test/SILGen/plus_zero_inlineable_attribute_objc.swift b/test/SILGen/plus_zero_inlineable_attribute_objc.swift
index a963567..60a07a2 100644
--- a/test/SILGen/plus_zero_inlineable_attribute_objc.swift
+++ b/test/SILGen/plus_zero_inlineable_attribute_objc.swift
@@ -1,8 +1,9 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %build-silgen-test-overlays
 
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -Xllvm -sil-full-demangle -primary-file %s -emit-silgen | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -module-name inlineable_attribute_objc -Xllvm -sil-full-demangle -primary-file %s -emit-silgen | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_keypath_application.swift b/test/SILGen/plus_zero_keypath_application.swift
index 1dbd44e..5922afe 100644
--- a/test/SILGen/plus_zero_keypath_application.swift
+++ b/test/SILGen/plus_zero_keypath_application.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 class A {}
diff --git a/test/SILGen/plus_zero_keypaths.swift b/test/SILGen/plus_zero_keypaths.swift
index db06785..d95a3dc 100644
--- a/test/SILGen/plus_zero_keypaths.swift
+++ b/test/SILGen/plus_zero_keypaths.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name keypaths -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 struct S<T> {
   var x: T
diff --git a/test/SILGen/plus_zero_let_decls.swift b/test/SILGen/plus_zero_let_decls.swift
index d0f7379..6c27b28 100644
--- a/test/SILGen/plus_zero_let_decls.swift
+++ b/test/SILGen/plus_zero_let_decls.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name let_decls -Xllvm -sil-full-demangle -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 func takeClosure(_ a : () -> Int) {}
 
diff --git a/test/SILGen/plus_zero_lifetime.swift b/test/SILGen/plus_zero_lifetime.swift
index c4434d2..c238b78 100644
--- a/test/SILGen/plus_zero_lifetime.swift
+++ b/test/SILGen/plus_zero_lifetime.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -parse-as-library -emit-silgen -primary-file %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name lifetime -Xllvm -sil-full-demangle -parse-as-library -emit-silgen -primary-file %s | %FileCheck %s
 
 struct Buh<T> {
   var x: Int {
diff --git a/test/SILGen/plus_zero_mangling.swift b/test/SILGen/plus_zero_mangling.swift
index a0357ce..8d5d973 100644
--- a/test/SILGen/plus_zero_mangling.swift
+++ b/test/SILGen/plus_zero_mangling.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-silgen -enable-sil-ownership | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name mangling -Xllvm -sil-full-demangle -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-silgen -enable-sil-ownership | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_materializeForSet.swift b/test/SILGen/plus_zero_materializeForSet.swift
index 6b9f8c3..6e350c8 100644
--- a/test/SILGen/plus_zero_materializeForSet.swift
+++ b/test/SILGen/plus_zero_materializeForSet.swift
@@ -1,6 +1,7 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen %s | %FileCheck %s
-// RUN: %target-swift-frontend -emit-silgen -enforce-exclusivity=unchecked %s | %FileCheck --check-prefix=UNCHECKED %s
+
+// RUN: %target-swift-frontend -module-name materializeForSet -emit-silgen %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name materializeForSet -emit-silgen -enforce-exclusivity=unchecked %s | %FileCheck --check-prefix=UNCHECKED %s
 
 class Base {
   var stored: Int = 0
diff --git a/test/SILGen/plus_zero_metatype_abstraction.swift b/test/SILGen/plus_zero_metatype_abstraction.swift
index 8dfa81f..55c2296 100644
--- a/test/SILGen/plus_zero_metatype_abstraction.swift
+++ b/test/SILGen/plus_zero_metatype_abstraction.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -module-name Swift -parse-stdlib %s | %FileCheck %s
 
 enum Optional<Wrapped> {
diff --git a/test/SILGen/plus_zero_multi_file.swift b/test/SILGen/plus_zero_multi_file.swift
index aaccbcc..d6ee120 100644
--- a/test/SILGen/plus_zero_multi_file.swift
+++ b/test/SILGen/plus_zero_multi_file.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -primary-file %s %S/Inputs/multi_file_helper.swift | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name multi_file -emit-silgen -enable-sil-ownership -primary-file %s %S/Inputs/multi_file_helper.swift | %FileCheck %s
 
 func markUsed<T>(_ t: T) {}
 
diff --git a/test/SILGen/plus_zero_nested_generics.swift b/test/SILGen/plus_zero_nested_generics.swift
index 32abb9f..032e824 100644
--- a/test/SILGen/plus_zero_nested_generics.swift
+++ b/test/SILGen/plus_zero_nested_generics.swift
@@ -1,8 +1,9 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -enable-sil-ownership -Xllvm -sil-full-demangle -emit-silgen  -parse-as-library %s | %FileCheck %s
-// RUN: %target-swift-frontend -enable-sil-ownership -Xllvm -sil-full-demangle -emit-sil -parse-as-library %s > /dev/null
-// RUN: %target-swift-frontend -enable-sil-ownership -Xllvm -sil-full-demangle -emit-sil -O -parse-as-library %s > /dev/null
-// RUN: %target-swift-frontend -enable-sil-ownership -Xllvm -sil-full-demangle -emit-ir -parse-as-library %s > /dev/null
+
+// RUN: %target-swift-frontend -module-name nested_generics -enable-sil-ownership -Xllvm -sil-full-demangle -emit-silgen  -parse-as-library %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name nested_generics -enable-sil-ownership -Xllvm -sil-full-demangle -emit-sil -parse-as-library %s > /dev/null
+// RUN: %target-swift-frontend -module-name nested_generics -enable-sil-ownership -Xllvm -sil-full-demangle -emit-sil -O -parse-as-library %s > /dev/null
+// RUN: %target-swift-frontend -module-name nested_generics -enable-sil-ownership -Xllvm -sil-full-demangle -emit-ir -parse-as-library %s > /dev/null
 
 // TODO:
 // - test generated SIL -- mostly we're just testing mangling here
diff --git a/test/SILGen/plus_zero_nested_types_referencing_nested_functions.swift b/test/SILGen/plus_zero_nested_types_referencing_nested_functions.swift
index a0aa92e..b22c70a 100644
--- a/test/SILGen/plus_zero_nested_types_referencing_nested_functions.swift
+++ b/test/SILGen/plus_zero_nested_types_referencing_nested_functions.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name nested_types_referencing_nested_functions -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 do {
   func foo() { bar(2) }
diff --git a/test/SILGen/plus_zero_newtype.swift b/test/SILGen/plus_zero_newtype.swift
index 778e1bb..9754f28 100644
--- a/test/SILGen/plus_zero_newtype.swift
+++ b/test/SILGen/plus_zero_newtype.swift
@@ -1,7 +1,8 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -sdk %S/Inputs -I %S/Inputs -enable-source-import  %s | %FileCheck %s -check-prefix=CHECK-RAW
 
-// RUN: %target-swift-frontend -emit-sil -sdk %S/Inputs -I %S/Inputs -enable-source-import  %s | %FileCheck %s -check-prefix=CHECK-CANONICAL
+// RUN: %target-swift-frontend -module-name newtype -emit-silgen -sdk %S/Inputs -I %S/Inputs -enable-source-import  %s | %FileCheck %s -check-prefix=CHECK-RAW
+
+// RUN: %target-swift-frontend -module-name newtype -emit-sil -sdk %S/Inputs -I %S/Inputs -enable-source-import  %s | %FileCheck %s -check-prefix=CHECK-CANONICAL
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_noescape_reabstraction.swift b/test/SILGen/plus_zero_noescape_reabstraction.swift
index 36d8a93..4b6f37c 100644
--- a/test/SILGen/plus_zero_noescape_reabstraction.swift
+++ b/test/SILGen/plus_zero_noescape_reabstraction.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name noescape_reabstraction -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 struct S {}
 
diff --git a/test/SILGen/plus_zero_objc_attr_NSManaged.swift b/test/SILGen/plus_zero_objc_attr_NSManaged.swift
index 4b51e9f..50d2dae 100644
--- a/test/SILGen/plus_zero_objc_attr_NSManaged.swift
+++ b/test/SILGen/plus_zero_objc_attr_NSManaged.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -sdk %S/Inputs %s -I %S/Inputs -enable-source-import -emit-silgen -enable-sil-ownership | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name objc_attr_NSManaged -sdk %S/Inputs %s -I %S/Inputs -enable-source-import -emit-silgen -enable-sil-ownership | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_objc_attr_NSManaged_multi.swift b/test/SILGen/plus_zero_objc_attr_NSManaged_multi.swift
index c1c9a5f..4ea9911 100644
--- a/test/SILGen/plus_zero_objc_attr_NSManaged_multi.swift
+++ b/test/SILGen/plus_zero_objc_attr_NSManaged_multi.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -sdk %S/Inputs -primary-file %s %S/objc_attr_NSManaged.swift -I %S/Inputs -enable-source-import -emit-silgen -enable-sil-ownership | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name objc_attr_NSManaged_multi -sdk %S/Inputs -primary-file %s %S/objc_attr_NSManaged.swift -I %S/Inputs -enable-source-import -emit-silgen -enable-sil-ownership | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_objc_blocks_bridging.swift b/test/SILGen/plus_zero_objc_blocks_bridging.swift
index 06b79c0..46dfd8d 100644
--- a/test/SILGen/plus_zero_objc_blocks_bridging.swift
+++ b/test/SILGen/plus_zero_objc_blocks_bridging.swift
@@ -1,8 +1,9 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %build-silgen-test-overlays
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -verify -emit-silgen -I %S/Inputs -disable-objc-attr-requires-foundation-module -enable-sil-ownership %s | %FileCheck %s
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -verify -emit-silgen -I %S/Inputs -disable-objc-attr-requires-foundation-module -enable-sil-ownership  %s | %FileCheck %s --check-prefix=GUARANTEED
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -module-name objc_blocks_bridging -verify -emit-silgen -I %S/Inputs -disable-objc-attr-requires-foundation-module -enable-sil-ownership %s | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -module-name objc_blocks_bridging -verify -emit-silgen -I %S/Inputs -disable-objc-attr-requires-foundation-module -enable-sil-ownership  %s | %FileCheck %s --check-prefix=GUARANTEED
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_objc_bridged_results.swift b/test/SILGen/plus_zero_objc_bridged_results.swift
index 862c5b1..6d97f1a 100644
--- a/test/SILGen/plus_zero_objc_bridged_results.swift
+++ b/test/SILGen/plus_zero_objc_bridged_results.swift
@@ -1,8 +1,9 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %build-silgen-test-overlays
 
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -emit-silgen %s -Xllvm -sil-print-debuginfo -import-objc-header %S/Inputs/objc_bridged_results.h -enable-sil-ownership | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -module-name objc_bridged_results -emit-silgen %s -Xllvm -sil-print-debuginfo -import-objc-header %S/Inputs/objc_bridged_results.h -enable-sil-ownership | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_objc_bridging.swift b/test/SILGen/plus_zero_objc_bridging.swift
index c4c6e1a..e79401c 100644
--- a/test/SILGen/plus_zero_objc_bridging.swift
+++ b/test/SILGen/plus_zero_objc_bridging.swift
@@ -1,8 +1,9 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %build-silgen-test-overlays
 // RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -emit-module -o %t -I %S/../Inputs/ObjCBridging %S/../Inputs/ObjCBridging/Appliances.swift
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -I %S/../Inputs/ObjCBridging -Xllvm -sil-full-demangle -emit-silgen %s -enable-sil-ownership | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-cpu --check-prefix=CHECK-%target-os-%target-cpu
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -module-name objc_bridging -I %S/../Inputs/ObjCBridging -Xllvm -sil-full-demangle -emit-silgen %s -enable-sil-ownership | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-cpu --check-prefix=CHECK-%target-os-%target-cpu
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_objc_bridging_any.swift b/test/SILGen/plus_zero_objc_bridging_any.swift
index 6e994ee..3ab1549 100644
--- a/test/SILGen/plus_zero_objc_bridging_any.swift
+++ b/test/SILGen/plus_zero_objc_bridging_any.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -Xllvm -sil-print-debuginfo -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -module-name objc_bridging_any -Xllvm -sil-print-debuginfo -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 // REQUIRES: objc_interop
 
 import Foundation
diff --git a/test/SILGen/plus_zero_objc_bridging_peephole.swift b/test/SILGen/plus_zero_objc_bridging_peephole.swift
index 8797bc5..55bba58 100644
--- a/test/SILGen/plus_zero_objc_bridging_peephole.swift
+++ b/test/SILGen/plus_zero_objc_bridging_peephole.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -module-name objc_bridging_peephole -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 // REQUIRES: objc_interop
 
 import Foundation
diff --git a/test/SILGen/plus_zero_objc_currying.swift b/test/SILGen/plus_zero_objc_currying.swift
index 8094585..9f1f9eb 100644
--- a/test/SILGen/plus_zero_objc_currying.swift
+++ b/test/SILGen/plus_zero_objc_currying.swift
@@ -1,7 +1,8 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %build-silgen-test-overlays
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -enable-sil-ownership -emit-silgen %s | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -module-name objc_currying -enable-sil-ownership -emit-silgen %s | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_objc_dictionary_bridging.swift b/test/SILGen/plus_zero_objc_dictionary_bridging.swift
index cee9ad3..48b24f9 100644
--- a/test/SILGen/plus_zero_objc_dictionary_bridging.swift
+++ b/test/SILGen/plus_zero_objc_dictionary_bridging.swift
@@ -1,8 +1,9 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %build-silgen-test-overlays
 
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -module-name objc_dictionary_bridging -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_objc_error.swift b/test/SILGen/plus_zero_objc_error.swift
index e48d19c..226aac3b 100644
--- a/test/SILGen/plus_zero_objc_error.swift
+++ b/test/SILGen/plus_zero_objc_error.swift
@@ -1,8 +1,9 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %build-clang-importer-objc-overlays
 
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -module-name objc_error -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_objc_extensions.swift b/test/SILGen/plus_zero_objc_extensions.swift
index 96a4c49..1e5ca90 100644
--- a/test/SILGen/plus_zero_objc_extensions.swift
+++ b/test/SILGen/plus_zero_objc_extensions.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -enable-sil-ownership -emit-silgen -sdk %S/Inputs/ -I %S/Inputs -enable-source-import %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name objc_extensions -enable-sil-ownership -emit-silgen -sdk %S/Inputs/ -I %S/Inputs -enable-source-import %s | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_objc_imported_generic.swift b/test/SILGen/plus_zero_objc_imported_generic.swift
index f874ba7..958bede 100644
--- a/test/SILGen/plus_zero_objc_imported_generic.swift
+++ b/test/SILGen/plus_zero_objc_imported_generic.swift
@@ -1,7 +1,8 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen %s -enable-sil-ownership | %FileCheck %s
+
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -module-name objc_imported_generic -emit-silgen %s -enable-sil-ownership | %FileCheck %s
 // For integration testing, ensure we get through IRGen too.
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-ir -verify -DIRGEN_INTEGRATION_TEST %s
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -module-name objc_imported_generic -emit-ir -verify -DIRGEN_INTEGRATION_TEST %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_objc_ownership_conventions.swift b/test/SILGen/plus_zero_objc_ownership_conventions.swift
index 3ef9bb6..e8c95f7 100644
--- a/test/SILGen/plus_zero_objc_ownership_conventions.swift
+++ b/test/SILGen/plus_zero_objc_ownership_conventions.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-silgen -enable-sil-ownership | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name objc_ownership_conventions -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-silgen -enable-sil-ownership | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_objc_protocol_native_thunk.swift b/test/SILGen/plus_zero_objc_protocol_native_thunk.swift
index 3d75ecf..767561d 100644
--- a/test/SILGen/plus_zero_objc_protocol_native_thunk.swift
+++ b/test/SILGen/plus_zero_objc_protocol_native_thunk.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_objc_protocols.swift b/test/SILGen/plus_zero_objc_protocols.swift
index 5052509..fe8d618 100644
--- a/test/SILGen/plus_zero_objc_protocols.swift
+++ b/test/SILGen/plus_zero_objc_protocols.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-silgen -disable-objc-attr-requires-foundation-module -enable-sil-ownership | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name objc_protocols -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-silgen -disable-objc-attr-requires-foundation-module -enable-sil-ownership | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_objc_set_bridging.swift b/test/SILGen/plus_zero_objc_set_bridging.swift
index 3c790c1..c4fdbc4 100644
--- a/test/SILGen/plus_zero_objc_set_bridging.swift
+++ b/test/SILGen/plus_zero_objc_set_bridging.swift
@@ -1,8 +1,9 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %build-silgen-test-overlays
 
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -emit-silgen %s -enable-sil-ownership | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -module-name objc_set_bridging -emit-silgen %s -enable-sil-ownership | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_objc_thunks.swift b/test/SILGen/plus_zero_objc_thunks.swift
index 0a40a32..e9b1f0f 100644
--- a/test/SILGen/plus_zero_objc_thunks.swift
+++ b/test/SILGen/plus_zero_objc_thunks.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -Xllvm -sil-print-debuginfo -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-silgen -emit-verbose-sil -enable-sil-ownership | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name objc_thunks -Xllvm -sil-full-demangle -Xllvm -sil-print-debuginfo -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-silgen -emit-verbose-sil -enable-sil-ownership | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_opaque_ownership.swift b/test/SILGen/plus_zero_opaque_ownership.swift
index 09bc70b..5a0651f 100644
--- a/test/SILGen/plus_zero_opaque_ownership.swift
+++ b/test/SILGen/plus_zero_opaque_ownership.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -enable-sil-opaque-values -enable-sil-ownership -emit-sorted-sil -Xllvm -sil-full-demangle -emit-silgen -parse-stdlib -parse-as-library -module-name Swift %s | %FileCheck %s
 // RUN: %target-swift-frontend -target x86_64-apple-macosx10.9 -enable-sil-opaque-values -enable-sil-ownership -emit-sorted-sil -Xllvm -sil-full-demangle -emit-silgen -parse-stdlib -parse-as-library -module-name Swift %s | %FileCheck --check-prefix=CHECK-OSX %s
 
diff --git a/test/SILGen/plus_zero_opaque_values_silgen.swift b/test/SILGen/plus_zero_opaque_values_silgen.swift
index 1c7f8f7..0d8ff59 100644
--- a/test/SILGen/plus_zero_opaque_values_silgen.swift
+++ b/test/SILGen/plus_zero_opaque_values_silgen.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -enable-sil-opaque-values -emit-sorted-sil -Xllvm -sil-full-demangle -emit-silgen %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-runtime
 
 // UNSUPPORTED: resilient_stdlib
diff --git a/test/SILGen/plus_zero_opaque_values_silgen_lib.swift b/test/SILGen/plus_zero_opaque_values_silgen_lib.swift
index fa43ee0..ffd9aa6 100644
--- a/test/SILGen/plus_zero_opaque_values_silgen_lib.swift
+++ b/test/SILGen/plus_zero_opaque_values_silgen_lib.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -enable-sil-ownership -enable-sil-opaque-values -emit-sorted-sil -Xllvm -sil-full-demangle -parse-stdlib -parse-as-library -emit-silgen -module-name Swift %s | %FileCheck %s
 // UNSUPPORTED: resilient_stdlib
 
diff --git a/test/SILGen/plus_zero_optional-cast.swift b/test/SILGen/plus_zero_optional-cast.swift
index 0c0ca83..6bff640 100644
--- a/test/SILGen/plus_zero_optional-cast.swift
+++ b/test/SILGen/plus_zero_optional-cast.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 class A {}
diff --git a/test/SILGen/plus_zero_optional.swift b/test/SILGen/plus_zero_optional.swift
index 038a0ab..944e77a 100644
--- a/test/SILGen/plus_zero_optional.swift
+++ b/test/SILGen/plus_zero_optional.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name optional -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 func testCall(_ f: (() -> ())?) {
   f?()
diff --git a/test/SILGen/plus_zero_optional_lvalue.swift b/test/SILGen/plus_zero_optional_lvalue.swift
index d2a4f17..5ed54db1b 100644
--- a/test/SILGen/plus_zero_optional_lvalue.swift
+++ b/test/SILGen/plus_zero_optional_lvalue.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name optional_lvalue -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 // CHECK-LABEL: sil hidden @$S15optional_lvalue07assign_a1_B0yySiSgz_SitF
 // CHECK:         [[WRITE:%.*]] = begin_access [modify] [unknown] %0 : $*Optional<Int>
diff --git a/test/SILGen/plus_zero_partial_apply_generic.swift b/test/SILGen/plus_zero_partial_apply_generic.swift
index dc1f4c5..318ffb0 100644
--- a/test/SILGen/plus_zero_partial_apply_generic.swift
+++ b/test/SILGen/plus_zero_partial_apply_generic.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name partial_apply_generic -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 protocol Panda {
   associatedtype Cuddles : Foo
diff --git a/test/SILGen/plus_zero_partial_apply_protocol.swift b/test/SILGen/plus_zero_partial_apply_protocol.swift
index ba46add..7977418 100644
--- a/test/SILGen/plus_zero_partial_apply_protocol.swift
+++ b/test/SILGen/plus_zero_partial_apply_protocol.swift
@@ -1,6 +1,7 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -enable-sil-ownership -emit-silgen -primary-file %s | %FileCheck %s
-// RUN: %target-swift-frontend -enable-sil-ownership -emit-ir -primary-file %s
+
+// RUN: %target-swift-frontend -module-name partial_apply_protocol -enable-sil-ownership -emit-silgen -primary-file %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name partial_apply_protocol -enable-sil-ownership -emit-ir -primary-file %s
 
 protocol Clonable {
   func clone() -> Self
diff --git a/test/SILGen/plus_zero_partial_apply_protocol_class_refinement_method.swift b/test/SILGen/plus_zero_partial_apply_protocol_class_refinement_method.swift
index ec4c8be..cfaae00 100644
--- a/test/SILGen/plus_zero_partial_apply_protocol_class_refinement_method.swift
+++ b/test/SILGen/plus_zero_partial_apply_protocol_class_refinement_method.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name partial_apply_protocol_class_refinement_method -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 protocol P { func foo() }
 protocol Q: class, P {}
diff --git a/test/SILGen/plus_zero_partial_apply_super.swift b/test/SILGen/plus_zero_partial_apply_super.swift
index 0a823f1..583f755 100644
--- a/test/SILGen/plus_zero_partial_apply_super.swift
+++ b/test/SILGen/plus_zero_partial_apply_super.swift
@@ -1,8 +1,9 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -enable-sil-ownership -I %t -emit-module -emit-module-path=%t/resilient_struct.swiftmodule -module-name resilient_struct %S/../Inputs/resilient_struct.swift
-// RUN: %target-swift-frontend -enable-sil-ownership -I %t -emit-module -emit-module-path=%t/resilient_class.swiftmodule -module-name resilient_class %S/../Inputs/resilient_class.swift
-// RUN: %target-swift-frontend -enable-sil-ownership -enable-resilience -emit-silgen -parse-as-library -I %t %s | %FileCheck %s
+// RUN: %target-swift-frontend -I %t -emit-module -emit-module-path=%t/resilient_struct.swiftmodule -module-name resilient_struct %S/../Inputs/resilient_struct.swift
+// RUN: %target-swift-frontend -I %t -emit-module -emit-module-path=%t/resilient_class.swiftmodule -module-name resilient_class %S/../Inputs/resilient_class.swift
+// RUN: %target-swift-frontend -module-name partial_apply_super -enable-resilience -emit-silgen -parse-as-library -I %t %s | %FileCheck %s
 
 import resilient_class
 
diff --git a/test/SILGen/plus_zero_pgo_checked_cast.swift b/test/SILGen/plus_zero_pgo_checked_cast.swift
index a479e87..735e164 100644
--- a/test/SILGen/plus_zero_pgo_checked_cast.swift
+++ b/test/SILGen/plus_zero_pgo_checked_cast.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift %s -profile-generate -Xfrontend -disable-incremental-llvm-codegen -module-name pgo_checked_cast -o %t/main
 // RUN: env LLVM_PROFILE_FILE=%t/default.profraw %target-run %t/main
diff --git a/test/SILGen/plus_zero_pgo_switchenum.swift b/test/SILGen/plus_zero_pgo_switchenum.swift
index 405912d..ca7e710 100644
--- a/test/SILGen/plus_zero_pgo_switchenum.swift
+++ b/test/SILGen/plus_zero_pgo_switchenum.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift %s -Xfrontend -enable-sil-ownership -profile-generate -Xfrontend -disable-incremental-llvm-codegen -module-name pgo_switchenum -o %t/main
 // RUN: env LLVM_PROFILE_FILE=%t/default.profraw %target-run %t/main
diff --git a/test/SILGen/plus_zero_pointer_conversion.swift b/test/SILGen/plus_zero_pointer_conversion.swift
index a07a9cf..0ab761d 100644
--- a/test/SILGen/plus_zero_pointer_conversion.swift
+++ b/test/SILGen/plus_zero_pointer_conversion.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -enable-sil-ownership -emit-silgen -sdk %S/Inputs -I %S/Inputs -enable-source-import %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name pointer_conversion -emit-silgen -sdk %S/Inputs -I %S/Inputs -enable-source-import %s | %FileCheck %s
 
 // FIXME: rdar://problem/19648117 Needs splitting objc parts out
 // XFAIL: linux
diff --git a/test/SILGen/plus_zero_properties.swift b/test/SILGen/plus_zero_properties.swift
index d7ec472..e7398e7 100644
--- a/test/SILGen/plus_zero_properties.swift
+++ b/test/SILGen/plus_zero_properties.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -parse-as-library -emit-silgen -disable-objc-attr-requires-foundation-module %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name properties -Xllvm -sil-full-demangle -parse-as-library -emit-silgen -disable-objc-attr-requires-foundation-module %s | %FileCheck %s
 
 var zero: Int = 0
 
diff --git a/test/SILGen/plus_zero_property_abstraction.swift b/test/SILGen/plus_zero_property_abstraction.swift
index ab74768..33991ac 100644
--- a/test/SILGen/plus_zero_property_abstraction.swift
+++ b/test/SILGen/plus_zero_property_abstraction.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -enable-sil-ownership -emit-silgen %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name property_abstraction -enable-sil-ownership -emit-silgen %s | %FileCheck %s
 
 struct Int {
   mutating func foo() {}
diff --git a/test/SILGen/plus_zero_protocol_extensions.swift b/test/SILGen/plus_zero_protocol_extensions.swift
index ec1dd26..2dd16f1 100644
--- a/test/SILGen/plus_zero_protocol_extensions.swift
+++ b/test/SILGen/plus_zero_protocol_extensions.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -disable-objc-attr-requires-foundation-module -emit-silgen %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name protocol_extensions -disable-objc-attr-requires-foundation-module -emit-silgen %s | %FileCheck %s
 
 public protocol P1 {
   func reqP1a()
diff --git a/test/SILGen/plus_zero_protocol_optional.swift b/test/SILGen/plus_zero_protocol_optional.swift
index 25e1dd6..671c5d4 100644
--- a/test/SILGen/plus_zero_protocol_optional.swift
+++ b/test/SILGen/plus_zero_protocol_optional.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -parse-as-library -emit-silgen -disable-objc-attr-requires-foundation-module -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name protocol_optional -parse-as-library -emit-silgen -disable-objc-attr-requires-foundation-module -enable-sil-ownership %s | %FileCheck %s
 
 @objc protocol P1 {
   @objc optional func method(_ x: Int)
diff --git a/test/SILGen/plus_zero_protocol_resilience.swift b/test/SILGen/plus_zero_protocol_resilience.swift
index df24b0f..bb682ac 100644
--- a/test/SILGen/plus_zero_protocol_resilience.swift
+++ b/test/SILGen/plus_zero_protocol_resilience.swift
@@ -1,7 +1,8 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module -enable-sil-ownership -enable-resilience -emit-module-path=%t/resilient_protocol.swiftmodule -module-name=resilient_protocol %S/../Inputs/resilient_protocol.swift
-// RUN: %target-swift-frontend -I %t -emit-silgen -enable-sil-ownership -enable-resilience %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name protocol_resilience -emit-module -enable-sil-ownership -enable-resilience -emit-module-path=%t/resilient_protocol.swiftmodule -module-name=resilient_protocol %S/../Inputs/resilient_protocol.swift
+// RUN: %target-swift-frontend -module-name protocol_resilience -I %t -emit-silgen -enable-sil-ownership -enable-resilience %s | %FileCheck %s
 
 import resilient_protocol
 
diff --git a/test/SILGen/plus_zero_protocols.swift b/test/SILGen/plus_zero_protocols.swift
index 20cb940..728ea06 100644
--- a/test/SILGen/plus_zero_protocols.swift
+++ b/test/SILGen/plus_zero_protocols.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name protocols -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 //===----------------------------------------------------------------------===//
 // Calling Existential Subscripts
diff --git a/test/SILGen/plus_zero_reabstract-tuple.swift b/test/SILGen/plus_zero_reabstract-tuple.swift
index 8553bba..75a3b50 100644
--- a/test/SILGen/plus_zero_reabstract-tuple.swift
+++ b/test/SILGen/plus_zero_reabstract-tuple.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -enable-sil-ownership -emit-silgen -verify %s | %FileCheck %s
 
 // SR-3090:
diff --git a/test/SILGen/plus_zero_reabstract.swift b/test/SILGen/plus_zero_reabstract.swift
index 03389c7..6c37099 100644
--- a/test/SILGen/plus_zero_reabstract.swift
+++ b/test/SILGen/plus_zero_reabstract.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name reabstract -Xllvm -sil-full-demangle -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 func takeFn<T>(_ f : (T) -> T?) {}
 func liftOptional(_ x : Int) -> Int? { return x }
diff --git a/test/SILGen/plus_zero_reabstract_lvalue.swift b/test/SILGen/plus_zero_reabstract_lvalue.swift
index 66a9907..1905f4c 100644
--- a/test/SILGen/plus_zero_reabstract_lvalue.swift
+++ b/test/SILGen/plus_zero_reabstract_lvalue.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 struct MyMetatypeIsThin {}
diff --git a/test/SILGen/plus_zero_result_abstraction.swift b/test/SILGen/plus_zero_result_abstraction.swift
index af83741..81911dc 100644
--- a/test/SILGen/plus_zero_result_abstraction.swift
+++ b/test/SILGen/plus_zero_result_abstraction.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name result_abstraction -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 struct S {}
 struct R {}
diff --git a/test/SILGen/plus_zero_retaining_globals.swift b/test/SILGen/plus_zero_retaining_globals.swift
index 481a643..fd48daf 100644
--- a/test/SILGen/plus_zero_retaining_globals.swift
+++ b/test/SILGen/plus_zero_retaining_globals.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -import-objc-header %S/Inputs/globals.h -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -module-name retaining_globals -import-objc-header %S/Inputs/globals.h -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 // REQUIRES: objc_interop
 
 
diff --git a/test/SILGen/plus_zero_rethrows.swift b/test/SILGen/plus_zero_rethrows.swift
index 0b5dfe7..e9cadab 100644
--- a/test/SILGen/plus_zero_rethrows.swift
+++ b/test/SILGen/plus_zero_rethrows.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -enable-sil-ownership -emit-sil -verify %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name rethrows -enable-sil-ownership -emit-sil -verify %s | %FileCheck %s
 
 @discardableResult
 func rethrower(_ fn: () throws -> Int) rethrows -> Int {
diff --git a/test/SILGen/plus_zero_scalar_to_tuple_args.swift b/test/SILGen/plus_zero_scalar_to_tuple_args.swift
index b6bfb8a..438095c 100644
--- a/test/SILGen/plus_zero_scalar_to_tuple_args.swift
+++ b/test/SILGen/plus_zero_scalar_to_tuple_args.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name scalar_to_tuple_args -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 func inoutWithDefaults(_ x: inout Int, y: Int = 0, z: Int = 0) {}
 func inoutWithCallerSideDefaults(_ x: inout Int, y: Int = #line) {}
diff --git a/test/SILGen/plus_zero_shared.swift b/test/SILGen/plus_zero_shared.swift
index 46ec6da..0889de8 100644
--- a/test/SILGen/plus_zero_shared.swift
+++ b/test/SILGen/plus_zero_shared.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen %s -disable-objc-attr-requires-foundation-module -enable-sil-ownership | %FileCheck %s
 
 // REQUIRES: owned_parameters
diff --git a/test/SILGen/plus_zero_sil_locations.swift b/test/SILGen/plus_zero_sil_locations.swift
index 7d6b12c..3c8546d 100644
--- a/test/SILGen/plus_zero_sil_locations.swift
+++ b/test/SILGen/plus_zero_sil_locations.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -Xllvm -sil-print-debuginfo -emit-verbose-sil -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name sil_locations -emit-silgen -Xllvm -sil-print-debuginfo -emit-verbose-sil -enable-sil-ownership %s | %FileCheck %s
 
 // FIXME: Not sure if this an ideal source info for the branch - 
 // it points to if, not the last instruction in the block.
@@ -77,7 +78,7 @@
 func useTemplateTest() -> Int {
   return templateTest(5);
   // CHECK-LABEL: sil hidden @$S13sil_locations15useTemplateTestSiyF
-  // CHECK: function_ref @$SSi2{{[_0-9a-zA-Z]*}}fC :{{.*}}, loc "{{.*}}":78
+  // CHECK: function_ref @$SSi2{{[_0-9a-zA-Z]*}}fC :{{.*}}, loc "{{.*}}":79
 }
 
 func foo(_ x: Int) -> Int {
diff --git a/test/SILGen/plus_zero_source_location.swift b/test/SILGen/plus_zero_source_location.swift
index b61fef9..979e3fb 100644
--- a/test/SILGen/plus_zero_source_location.swift
+++ b/test/SILGen/plus_zero_source_location.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -Xllvm -sil-print-debuginfo -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name source_location -Xllvm -sil-full-demangle -Xllvm -sil-print-debuginfo -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 func printSourceLocation(file: String = #file, line: Int = #line) {}
 
diff --git a/test/SILGen/plus_zero_specialize_attr.swift b/test/SILGen/plus_zero_specialize_attr.swift
index 7ee8a18..71f73c3 100644
--- a/test/SILGen/plus_zero_specialize_attr.swift
+++ b/test/SILGen/plus_zero_specialize_attr.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -emit-verbose-sil %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name specialize_attr -emit-silgen -enable-sil-ownership -emit-verbose-sil %s | %FileCheck %s
 
 // CHECK-LABEL: @_specialize(exported: false, kind: full, where T == Int, U == Float)
 // CHECK-NEXT: func specializeThis<T, U>(_ t: T, u: U)
diff --git a/test/SILGen/plus_zero_statements.swift b/test/SILGen/plus_zero_statements.swift
index d3fe1bd..fbfea10 100644
--- a/test/SILGen/plus_zero_statements.swift
+++ b/test/SILGen/plus_zero_statements.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -parse-as-library -emit-silgen -enable-sil-ownership -verify %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name statements -Xllvm -sil-full-demangle -parse-as-library -emit-silgen -enable-sil-ownership -verify %s | %FileCheck %s
 
 class MyClass { 
   func foo() { }
diff --git a/test/SILGen/plus_zero_struct_resilience.swift b/test/SILGen/plus_zero_struct_resilience.swift
index b11d502..eb68e0e 100644
--- a/test/SILGen/plus_zero_struct_resilience.swift
+++ b/test/SILGen/plus_zero_struct_resilience.swift
@@ -1,7 +1,8 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -enable-sil-ownership -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
-// RUN: %target-swift-frontend -I %t -enable-sil-ownership -emit-silgen -enable-resilience %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name struct_resilience -emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -enable-sil-ownership -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
+// RUN: %target-swift-frontend -module-name struct_resilience -I %t -enable-sil-ownership -emit-silgen -enable-resilience %s | %FileCheck %s
 
 import resilient_struct
 
diff --git a/test/SILGen/plus_zero_subclass_existentials.swift b/test/SILGen/plus_zero_subclass_existentials.swift
index 0189ede..cdef1fd 100644
--- a/test/SILGen/plus_zero_subclass_existentials.swift
+++ b/test/SILGen/plus_zero_subclass_existentials.swift
@@ -1,6 +1,7 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen -parse-as-library -primary-file %s -verify | %FileCheck %s
-// RUN: %target-swift-frontend -emit-ir -parse-as-library -primary-file %s
+
+// RUN: %target-swift-frontend -module-name subclass_existentials -Xllvm -sil-full-demangle -emit-silgen -parse-as-library -primary-file %s -verify | %FileCheck %s
+// RUN: %target-swift-frontend -module-name subclass_existentials -emit-ir -parse-as-library -primary-file %s
 
 // Note: we pass -verify above to ensure there are no spurious
 // compiler warnings relating to casts.
diff --git a/test/SILGen/plus_zero_super.swift b/test/SILGen/plus_zero_super.swift
index 5184967..bbd8219 100644
--- a/test/SILGen/plus_zero_super.swift
+++ b/test/SILGen/plus_zero_super.swift
@@ -1,8 +1,9 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -I %t -emit-module -emit-module-path=%t/resilient_struct.swiftmodule -module-name resilient_struct %S/../Inputs/resilient_struct.swift
 // RUN: %target-swift-frontend -I %t -emit-module -emit-module-path=%t/resilient_class.swiftmodule -module-name resilient_class %S/../Inputs/resilient_class.swift
-// RUN: %target-swift-frontend -emit-silgen -parse-as-library -I %t %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name super -emit-silgen -parse-as-library -I %t %s | %FileCheck %s
 
 import resilient_class
 
diff --git a/test/SILGen/plus_zero_switch.swift b/test/SILGen/plus_zero_switch.swift
index e81e078..6c13049 100644
--- a/test/SILGen/plus_zero_switch.swift
+++ b/test/SILGen/plus_zero_switch.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name switch -emit-silgen %s | %FileCheck %s
 
 func markUsed<T>(_ t: T) {}
 
diff --git a/test/SILGen/plus_zero_switch_abstraction.swift b/test/SILGen/plus_zero_switch_abstraction.swift
index 86ebbc9..aec5b2e 100644
--- a/test/SILGen/plus_zero_switch_abstraction.swift
+++ b/test/SILGen/plus_zero_switch_abstraction.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -parse-stdlib %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name switch_abstraction -emit-silgen -enable-sil-ownership -parse-stdlib %s | %FileCheck %s
 
 struct A {}
 
diff --git a/test/SILGen/plus_zero_switch_isa.swift b/test/SILGen/plus_zero_switch_isa.swift
index 7ad4e70..1a50b5c 100644
--- a/test/SILGen/plus_zero_switch_isa.swift
+++ b/test/SILGen/plus_zero_switch_isa.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name switch_isa -emit-silgen %s | %FileCheck %s
 
 func markUsed<T>(_ t: T) {}
 
diff --git a/test/SILGen/plus_zero_switch_multiple_entry_address_only.swift b/test/SILGen/plus_zero_switch_multiple_entry_address_only.swift
index 1e70918..0d3cbca 100644
--- a/test/SILGen/plus_zero_switch_multiple_entry_address_only.swift
+++ b/test/SILGen/plus_zero_switch_multiple_entry_address_only.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend %s -emit-silgen | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name switch_multiple_entry_address_only %s -emit-silgen | %FileCheck %s
 
 enum E {
 case a(Any)
diff --git a/test/SILGen/plus_zero_switch_var.swift b/test/SILGen/plus_zero_switch_var.swift
index becf093..4ae81d4 100644
--- a/test/SILGen/plus_zero_switch_var.swift
+++ b/test/SILGen/plus_zero_switch_var.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name switch_var -emit-silgen %s | %FileCheck %s
 
 // TODO: Implement tuple equality in the library.
 // BLOCKED: <rdar://problem/13822406>
diff --git a/test/SILGen/plus_zero_testable-multifile-other.swift b/test/SILGen/plus_zero_testable-multifile-other.swift
index b517849..ffec7ac 100644
--- a/test/SILGen/plus_zero_testable-multifile-other.swift
+++ b/test/SILGen/plus_zero_testable-multifile-other.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // This test is paired with testable-multifile.swift.
 
 // RUN: %empty-directory(%t)
diff --git a/test/SILGen/plus_zero_tuples.swift b/test/SILGen/plus_zero_tuples.swift
index c0e0a3d..3427db0 100644
--- a/test/SILGen/plus_zero_tuples.swift
+++ b/test/SILGen/plus_zero_tuples.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name tuples -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 class C {}
 
 enum Foo {
diff --git a/test/SILGen/plus_zero_types.swift b/test/SILGen/plus_zero_types.swift
index ff5aae4..f8903b5 100644
--- a/test/SILGen/plus_zero_types.swift
+++ b/test/SILGen/plus_zero_types.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -parse-as-library -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 class C {
diff --git a/test/SILGen/plus_zero_unmanaged.swift b/test/SILGen/plus_zero_unmanaged.swift
index 0a8d7b2..b3217ff 100644
--- a/test/SILGen/plus_zero_unmanaged.swift
+++ b/test/SILGen/plus_zero_unmanaged.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -enable-sil-ownership -emit-sil %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name unmanaged -enable-sil-ownership -emit-sil %s | %FileCheck %s
 
 class C {}
 
diff --git a/test/SILGen/plus_zero_unmanaged_ownership.swift b/test/SILGen/plus_zero_unmanaged_ownership.swift
index 8384266..3b8850f 100644
--- a/test/SILGen/plus_zero_unmanaged_ownership.swift
+++ b/test/SILGen/plus_zero_unmanaged_ownership.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -enable-sil-ownership -parse-stdlib -module-name Swift -emit-silgen %s | %FileCheck %s
 
 class C {}
diff --git a/test/SILGen/plus_zero_unowned.swift b/test/SILGen/plus_zero_unowned.swift
index ff712fb..7845c73 100644
--- a/test/SILGen/plus_zero_unowned.swift
+++ b/test/SILGen/plus_zero_unowned.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name unowned -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 func takeClosure(_ fn: () -> Int) {}
 
diff --git a/test/SILGen/plus_zero_vtable_thunks_reabstraction_final.swift b/test/SILGen/plus_zero_vtable_thunks_reabstraction_final.swift
index 4cd5aee..197e0a3 100644
--- a/test/SILGen/plus_zero_vtable_thunks_reabstraction_final.swift
+++ b/test/SILGen/plus_zero_vtable_thunks_reabstraction_final.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name vtable_thunks_reabstraction_final -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 protocol Fooable {
   func foo(_ x: Int) -> Int?
diff --git a/test/SILGen/plus_zero_vtables_objc.swift b/test/SILGen/plus_zero_vtables_objc.swift
index ef5fbb0..d05a728 100644
--- a/test/SILGen/plus_zero_vtables_objc.swift
+++ b/test/SILGen/plus_zero_vtables_objc.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -enable-sil-ownership -sdk %S/Inputs -emit-silgen -I %S/Inputs -enable-source-import %s -disable-objc-attr-requires-foundation-module | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name vtables_objc -enable-sil-ownership -sdk %S/Inputs -emit-silgen -I %S/Inputs -enable-source-import %s -disable-objc-attr-requires-foundation-module | %FileCheck %s
 
 // REQUIRES: objc_interop
 
diff --git a/test/SILGen/plus_zero_weak.swift b/test/SILGen/plus_zero_weak.swift
index 919a55f..039a2ab 100644
--- a/test/SILGen/plus_zero_weak.swift
+++ b/test/SILGen/plus_zero_weak.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name weak -Xllvm -sil-full-demangle -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 class C {
   func f() -> Int { return 42 }
diff --git a/test/SILGen/plus_zero_weak_multiple_modules.swift b/test/SILGen/plus_zero_weak_multiple_modules.swift
index 2c97546..19160ab 100644
--- a/test/SILGen/plus_zero_weak_multiple_modules.swift
+++ b/test/SILGen/plus_zero_weak_multiple_modules.swift
@@ -1,7 +1,8 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -emit-module -emit-module-path=%t/weak_other.swiftmodule -module-name=weak_other %S/Inputs/weak_other.swift
-// RUN: %target-swift-frontend -I %t -emit-silgen -enable-sil-ownership %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-runtime
+// RUN: %target-swift-frontend -module-name weak_multiple_modules -I %t -emit-silgen -enable-sil-ownership %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-runtime
 
 import weak_other
 
diff --git a/test/SILGen/plus_zero_without_actually_escaping.swift b/test/SILGen/plus_zero_without_actually_escaping.swift
index cce3e9c..c588d4e 100644
--- a/test/SILGen/plus_zero_without_actually_escaping.swift
+++ b/test/SILGen/plus_zero_without_actually_escaping.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name without_actually_escaping -emit-silgen -enable-sil-ownership %s | %FileCheck %s
 
 var escapeHatch: Any = 0
 
diff --git a/test/SILGen/plus_zero_witness_same_type.swift b/test/SILGen/plus_zero_witness_same_type.swift
index 93335d1..3658e49 100644
--- a/test/SILGen/plus_zero_witness_same_type.swift
+++ b/test/SILGen/plus_zero_witness_same_type.swift
@@ -1,6 +1,7 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
-// RUN: %target-swift-frontend -enable-sil-ownership -emit-ir %s
+
+// RUN: %target-swift-frontend -module-name witness_same_type -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+// RUN: %target-swift-frontend -module-name witness_same_type -enable-sil-ownership -emit-ir %s
 
 protocol Fooable {
   associatedtype Bar
diff --git a/test/SILGen/plus_zero_witness_tables.swift b/test/SILGen/plus_zero_witness_tables.swift
index e188c03..6b46ffe 100644
--- a/test/SILGen/plus_zero_witness_tables.swift
+++ b/test/SILGen/plus_zero_witness_tables.swift
@@ -1,9 +1,10 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -I %S/Inputs -enable-source-import %s -disable-objc-attr-requires-foundation-module > %t.sil
+
+// RUN: %target-swift-frontend -module-name witness_tables -emit-silgen -enable-sil-ownership -I %S/Inputs -enable-source-import %s -disable-objc-attr-requires-foundation-module > %t.sil
 // RUN: %FileCheck -check-prefix=TABLE -check-prefix=TABLE-ALL %s < %t.sil
 // RUN: %FileCheck -check-prefix=SYMBOL %s < %t.sil
 
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -I %S/Inputs -enable-source-import %s -disable-objc-attr-requires-foundation-module -enable-testing > %t.testable.sil
+// RUN: %target-swift-frontend -module-name witness_tables -emit-silgen -enable-sil-ownership -I %S/Inputs -enable-source-import %s -disable-objc-attr-requires-foundation-module -enable-testing > %t.testable.sil
 // RUN: %FileCheck -check-prefix=TABLE-TESTABLE -check-prefix=TABLE-ALL %s < %t.testable.sil
 // RUN: %FileCheck -check-prefix=SYMBOL-TESTABLE %s < %t.testable.sil
 
diff --git a/test/SILGen/plus_zero_witnesses.swift b/test/SILGen/plus_zero_witnesses.swift
index f618418..4ba0428 100644
--- a/test/SILGen/plus_zero_witnesses.swift
+++ b/test/SILGen/plus_zero_witnesses.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen %s -disable-objc-attr-requires-foundation-module -enable-sil-ownership | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name witnesses -Xllvm -sil-full-demangle -emit-silgen %s -disable-objc-attr-requires-foundation-module -enable-sil-ownership | %FileCheck %s
 
 infix operator <~> {}
 
diff --git a/test/SILGen/plus_zero_witnesses_class.swift b/test/SILGen/plus_zero_witnesses_class.swift
index 3ec494b..2bae1fe 100644
--- a/test/SILGen/plus_zero_witnesses_class.swift
+++ b/test/SILGen/plus_zero_witnesses_class.swift
@@ -1,5 +1,6 @@
 // REQUIRES: plus_zero_runtime
-// RUN: %target-swift-frontend -enable-sil-ownership -emit-silgen %s | %FileCheck %s
+
+// RUN: %target-swift-frontend -module-name witnesses_class -enable-sil-ownership -emit-silgen %s | %FileCheck %s
 
 protocol Fooable: class {
   func foo()
diff --git a/test/SILOptimizer/Inputs/plus_zero_TestMod.sil b/test/SILOptimizer/Inputs/plus_zero_TestMod.sil
index 62126fb..d0e1d1b 100644
--- a/test/SILOptimizer/Inputs/plus_zero_TestMod.sil
+++ b/test/SILOptimizer/Inputs/plus_zero_TestMod.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // Test module for the specialize_cg_update_crash.sil test.
 
 sil_stage canonical
diff --git a/test/SILOptimizer/plus_zero_access_enforcement_noescape.swift b/test/SILOptimizer/plus_zero_access_enforcement_noescape.swift
index 07fb511..37eb3c2 100644
--- a/test/SILOptimizer/plus_zero_access_enforcement_noescape.swift
+++ b/test/SILOptimizer/plus_zero_access_enforcement_noescape.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -enable-sil-ownership -enforce-exclusivity=checked -Onone -emit-sil -swift-version 4 -verify -parse-as-library %s
 // RUN: %target-swift-frontend -enable-sil-ownership -enforce-exclusivity=checked -Onone -emit-sil -swift-version 3 -parse-as-library %s | %FileCheck %s
 // REQUIRES: asserts
diff --git a/test/SILOptimizer/plus_zero_access_marker_mandatory.swift b/test/SILOptimizer/plus_zero_access_marker_mandatory.swift
index dde3001..6bc68ea 100644
--- a/test/SILOptimizer/plus_zero_access_marker_mandatory.swift
+++ b/test/SILOptimizer/plus_zero_access_marker_mandatory.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -enable-sil-ownership -parse-as-library -Xllvm -sil-full-demangle -emit-sil -Onone -enforce-exclusivity=checked %s | %FileCheck %s
 
 public struct S {
diff --git a/test/SILOptimizer/plus_zero_access_marker_verify.swift b/test/SILOptimizer/plus_zero_access_marker_verify.swift
index 7b31d78..ad65c82 100644
--- a/test/SILOptimizer/plus_zero_access_marker_verify.swift
+++ b/test/SILOptimizer/plus_zero_access_marker_verify.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -enable-verify-exclusivity -enforce-exclusivity=checked -enable-sil-ownership -emit-silgen -swift-version 4 -parse-as-library %s | %FileCheck %s
 // RUN: %target-swift-frontend -enable-verify-exclusivity -enforce-exclusivity=checked -enable-sil-ownership -Onone -emit-sil -swift-version 4 -parse-as-library %s
 // RUN: %target-swift-frontend -enable-verify-exclusivity -enforce-exclusivity=checked -enable-sil-ownership -O -emit-sil -swift-version 4 -parse-as-library %s
diff --git a/test/SILOptimizer/plus_zero_array_element_propagation.sil b/test/SILOptimizer/plus_zero_array_element_propagation.sil
index 8973b9a..7363872 100644
--- a/test/SILOptimizer/plus_zero_array_element_propagation.sil
+++ b/test/SILOptimizer/plus_zero_array_element_propagation.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -array-element-propagation %s | %FileCheck %s
 sil_stage canonical
 
diff --git a/test/SILOptimizer/plus_zero_bridged_casts_folding.swift b/test/SILOptimizer/plus_zero_bridged_casts_folding.swift
index 5ef60d6..55d2938 100644
--- a/test/SILOptimizer/plus_zero_bridged_casts_folding.swift
+++ b/test/SILOptimizer/plus_zero_bridged_casts_folding.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -O -emit-sil %s | %FileCheck %s
 
 // REQUIRES: objc_interop
diff --git a/test/SILOptimizer/plus_zero_capture_promotion_generic_context.sil b/test/SILOptimizer/plus_zero_capture_promotion_generic_context.sil
index 8f08930..9fc8f6f 100644
--- a/test/SILOptimizer/plus_zero_capture_promotion_generic_context.sil
+++ b/test/SILOptimizer/plus_zero_capture_promotion_generic_context.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-sil -O -Xllvm -sil-fso-enable-generics=false %s | %FileCheck %s
 
 sil_stage raw
diff --git a/test/SILOptimizer/plus_zero_capture_promotion_generic_context_ownership.sil b/test/SILOptimizer/plus_zero_capture_promotion_generic_context_ownership.sil
index 77ac818..9049baf 100644
--- a/test/SILOptimizer/plus_zero_capture_promotion_generic_context_ownership.sil
+++ b/test/SILOptimizer/plus_zero_capture_promotion_generic_context_ownership.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -enable-sil-ownership -emit-sil -O -Xllvm -sil-fso-enable-generics=false %s | %FileCheck %s
 
 sil_stage raw
diff --git a/test/SILOptimizer/plus_zero_cast_folding_no_bridging.sil b/test/SILOptimizer/plus_zero_cast_folding_no_bridging.sil
index 4b4c661..fa01ca5 100644
--- a/test/SILOptimizer/plus_zero_cast_folding_no_bridging.sil
+++ b/test/SILOptimizer/plus_zero_cast_folding_no_bridging.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -O -emit-sil %s | %FileCheck %s
 // REQUIRES: objc_interop
 
diff --git a/test/SILOptimizer/plus_zero_cast_folding_objc_generics.swift b/test/SILOptimizer/plus_zero_cast_folding_objc_generics.swift
index effe201..a7b1826 100644
--- a/test/SILOptimizer/plus_zero_cast_folding_objc_generics.swift
+++ b/test/SILOptimizer/plus_zero_cast_folding_objc_generics.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -O -emit-sil %s | %FileCheck %s
 // REQUIRES: objc_interop
 
diff --git a/test/SILOptimizer/plus_zero_cast_folding_objc_no_foundation.swift b/test/SILOptimizer/plus_zero_cast_folding_objc_no_foundation.swift
index 5648147..86a36d4 100644
--- a/test/SILOptimizer/plus_zero_cast_folding_objc_no_foundation.swift
+++ b/test/SILOptimizer/plus_zero_cast_folding_objc_no_foundation.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -O -emit-sil %s | %FileCheck %s
 // REQUIRES: objc_interop
 
diff --git a/test/SILOptimizer/plus_zero_devirt_covariant_return.swift b/test/SILOptimizer/plus_zero_devirt_covariant_return.swift
index 8c12f8d..7bc2716 100644
--- a/test/SILOptimizer/plus_zero_devirt_covariant_return.swift
+++ b/test/SILOptimizer/plus_zero_devirt_covariant_return.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -Xllvm -sil-full-demangle -O -Xllvm -disable-sil-cm-rr-cm=0   -Xllvm -sil-inline-generics=false -primary-file %s -emit-sil -sil-inline-threshold 1000 -Xllvm -sil-disable-pass=ObjectOutliner -sil-verify-all | %FileCheck %s
 
 // Make sure that we can dig all the way through the class hierarchy and
diff --git a/test/SILOptimizer/plus_zero_devirt_default_case.swift b/test/SILOptimizer/plus_zero_devirt_default_case.swift
index c6eeaa8..1551296 100644
--- a/test/SILOptimizer/plus_zero_devirt_default_case.swift
+++ b/test/SILOptimizer/plus_zero_devirt_default_case.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -O -module-name devirt_default_case -emit-sil %s | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-NORMAL %s
 // RUN: %target-swift-frontend -O -module-name devirt_default_case -emit-sil -enable-testing %s | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-TESTABLE %s
 
diff --git a/test/SILOptimizer/plus_zero_devirt_nested_class.swift b/test/SILOptimizer/plus_zero_devirt_nested_class.swift
index 936d6d9..81f6153 100644
--- a/test/SILOptimizer/plus_zero_devirt_nested_class.swift
+++ b/test/SILOptimizer/plus_zero_devirt_nested_class.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -emit-sil -O %s | %FileCheck %s
 
 fileprivate class Outer<T> {
diff --git a/test/SILOptimizer/plus_zero_devirt_protocol_method_invocations.swift b/test/SILOptimizer/plus_zero_devirt_protocol_method_invocations.swift
index 2b1a325..f4c6008 100644
--- a/test/SILOptimizer/plus_zero_devirt_protocol_method_invocations.swift
+++ b/test/SILOptimizer/plus_zero_devirt_protocol_method_invocations.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -O -emit-sil %s | %FileCheck %s
 
 protocol PPP {
diff --git a/test/SILOptimizer/plus_zero_devirt_speculative_nested.swift b/test/SILOptimizer/plus_zero_devirt_speculative_nested.swift
index bc6a9e8..ac4abd1 100644
--- a/test/SILOptimizer/plus_zero_devirt_speculative_nested.swift
+++ b/test/SILOptimizer/plus_zero_devirt_speculative_nested.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend %s -parse-as-library -O -emit-sil | %FileCheck %s
 // RUN: %target-swift-frontend %s -parse-as-library -Osize -emit-sil
 //
diff --git a/test/SILOptimizer/plus_zero_devirt_value_metatypes.swift b/test/SILOptimizer/plus_zero_devirt_value_metatypes.swift
index b324eab..548a292 100644
--- a/test/SILOptimizer/plus_zero_devirt_value_metatypes.swift
+++ b/test/SILOptimizer/plus_zero_devirt_value_metatypes.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -emit-sil -O %s | %FileCheck %s
 
 open class A {
diff --git a/test/SILOptimizer/plus_zero_devirt_witness_method_conformance.swift b/test/SILOptimizer/plus_zero_devirt_witness_method_conformance.swift
index f3da042..b0c74dd 100644
--- a/test/SILOptimizer/plus_zero_devirt_witness_method_conformance.swift
+++ b/test/SILOptimizer/plus_zero_devirt_witness_method_conformance.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -O -emit-ir  -primary-file %s | %FileCheck %s
 // This is a swift file because the crash doesn't reproduce with SIL.
 @inline(never)
diff --git a/test/SILOptimizer/plus_zero_let_properties_opts.swift b/test/SILOptimizer/plus_zero_let_properties_opts.swift
index 12be391..abff5e4 100644
--- a/test/SILOptimizer/plus_zero_let_properties_opts.swift
+++ b/test/SILOptimizer/plus_zero_let_properties_opts.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend %s -O -emit-sil | %FileCheck -check-prefix=CHECK-WMO %s
 // RUN: %target-swift-frontend -primary-file %s -O -emit-sil | %FileCheck %s
 
diff --git a/test/SILOptimizer/plus_zero_mandatory_inlining.swift b/test/SILOptimizer/plus_zero_mandatory_inlining.swift
index 3dec6cb..9bebff3 100644
--- a/test/SILOptimizer/plus_zero_mandatory_inlining.swift
+++ b/test/SILOptimizer/plus_zero_mandatory_inlining.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -enable-sil-ownership -sil-verify-all -primary-file %s -emit-sil -o - -verify | %FileCheck %s
 
 // These tests are deliberately shallow, because I do not want to depend on the
diff --git a/test/SILOptimizer/plus_zero_performance_inliner.sil b/test/SILOptimizer/plus_zero_performance_inliner.sil
index e19b0c9..b36dd6d 100644
--- a/test/SILOptimizer/plus_zero_performance_inliner.sil
+++ b/test/SILOptimizer/plus_zero_performance_inliner.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all %s -inline -sil-combine | %FileCheck %s
 
 sil_stage canonical
diff --git a/test/SILOptimizer/plus_zero_spec_archetype_method.swift b/test/SILOptimizer/plus_zero_spec_archetype_method.swift
index f76cf39..0ebf230 100644
--- a/test/SILOptimizer/plus_zero_spec_archetype_method.swift
+++ b/test/SILOptimizer/plus_zero_spec_archetype_method.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -O -Xllvm -sil-disable-pass=FunctionSignatureOpts -disable-arc-opts -emit-sil -primary-file %s | %FileCheck %s
 
 // We can't deserialize apply_inst with subst lists. When radar://14443304
diff --git a/test/SILOptimizer/plus_zero_specialize_anyobject.swift b/test/SILOptimizer/plus_zero_specialize_anyobject.swift
index 5d5326c..647c362 100644
--- a/test/SILOptimizer/plus_zero_specialize_anyobject.swift
+++ b/test/SILOptimizer/plus_zero_specialize_anyobject.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend  -O -sil-inline-threshold 0 -emit-sil -primary-file %s | %FileCheck %s
 
 // rdar://problem/20338028
diff --git a/test/SILOptimizer/plus_zero_specialize_cg_update_crash.sil b/test/SILOptimizer/plus_zero_specialize_cg_update_crash.sil
index 01b0190..0762b26 100644
--- a/test/SILOptimizer/plus_zero_specialize_cg_update_crash.sil
+++ b/test/SILOptimizer/plus_zero_specialize_cg_update_crash.sil
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -parse-stdlib -parse-as-library  -module-name TestMod %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
diff --git a/test/SILOptimizer/plus_zero_specialize_checked_cast_branch.swift b/test/SILOptimizer/plus_zero_specialize_checked_cast_branch.swift
index 4f6073d..766c005 100644
--- a/test/SILOptimizer/plus_zero_specialize_checked_cast_branch.swift
+++ b/test/SILOptimizer/plus_zero_specialize_checked_cast_branch.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend  -emit-sil -O -sil-inline-threshold 0 %s -o - | %FileCheck %s
 
 class C {}
diff --git a/test/SILOptimizer/plus_zero_specialize_dynamic_self.swift b/test/SILOptimizer/plus_zero_specialize_dynamic_self.swift
index 4348be6..9c2e44c 100644
--- a/test/SILOptimizer/plus_zero_specialize_dynamic_self.swift
+++ b/test/SILOptimizer/plus_zero_specialize_dynamic_self.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -Xllvm -sil-inline-generics -emit-sil -O -primary-file %s | %FileCheck %s
 
 protocol P {}
diff --git a/test/SILOptimizer/plus_zero_specialize_inherited_multifile.swift b/test/SILOptimizer/plus_zero_specialize_inherited_multifile.swift
index 387094d..f3a5b49 100644
--- a/test/SILOptimizer/plus_zero_specialize_inherited_multifile.swift
+++ b/test/SILOptimizer/plus_zero_specialize_inherited_multifile.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -primary-file %s %S/Inputs/specialize_inherited_multifile.swift -O -emit-sil -sil-verify-all | %FileCheck %s
 
 @_optimize(none) func takesBase<T : Base>(t: T) {}
diff --git a/test/SILOptimizer/plus_zero_specialize_partial_apply.swift b/test/SILOptimizer/plus_zero_specialize_partial_apply.swift
index 9297335..e9498f0 100644
--- a/test/SILOptimizer/plus_zero_specialize_partial_apply.swift
+++ b/test/SILOptimizer/plus_zero_specialize_partial_apply.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // First check the SIL.
 // RUN: %target-swift-frontend -O -Xllvm -sil-disable-pass=FunctionSignatureOpts -module-name=test -emit-sil -primary-file %s | %FileCheck %s
 
diff --git a/test/SILOptimizer/plus_zero_specialize_same_type_constraint.swift b/test/SILOptimizer/plus_zero_specialize_same_type_constraint.swift
index f8db643..ba13e51 100644
--- a/test/SILOptimizer/plus_zero_specialize_same_type_constraint.swift
+++ b/test/SILOptimizer/plus_zero_specialize_same_type_constraint.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend  -O -emit-sil -primary-file %s | %FileCheck %s
 
 protocol FirstChild {}
diff --git a/test/SILOptimizer/plus_zero_specialize_self.swift b/test/SILOptimizer/plus_zero_specialize_self.swift
index b181e3e..5c3cbcf 100644
--- a/test/SILOptimizer/plus_zero_specialize_self.swift
+++ b/test/SILOptimizer/plus_zero_specialize_self.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -Xllvm -sil-full-demangle  -O -sil-inline-threshold 0 -emit-sil -primary-file %s | %FileCheck %s
 
 // CHECK-NOT: generic specialization <Swift.AnyObject, Self> of specialize_self.cast <A, B>(A) -> Swift.Optional<B>
diff --git a/test/SILOptimizer/plus_zero_specialize_self_conforming.swift b/test/SILOptimizer/plus_zero_specialize_self_conforming.swift
index 1c01bc2..e593dde 100644
--- a/test/SILOptimizer/plus_zero_specialize_self_conforming.swift
+++ b/test/SILOptimizer/plus_zero_specialize_self_conforming.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -emit-sil -O -primary-file %s | %FileCheck %s
 
 // REQUIRES: objc_interop
diff --git a/test/SILOptimizer/plus_zero_specialize_unconditional_checked_cast.swift b/test/SILOptimizer/plus_zero_specialize_unconditional_checked_cast.swift
index 6f6977d..663b767 100644
--- a/test/SILOptimizer/plus_zero_specialize_unconditional_checked_cast.swift
+++ b/test/SILOptimizer/plus_zero_specialize_unconditional_checked_cast.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend  -Xllvm -sil-disable-pass=FunctionSignatureOpts -emit-sil -o - -O %s | %FileCheck %s
 
 //////////////////
diff --git a/test/SILOptimizer/plus_zero_specialized_anyobject_conformance.swift b/test/SILOptimizer/plus_zero_specialized_anyobject_conformance.swift
index 5cc511e..306893d 100644
--- a/test/SILOptimizer/plus_zero_specialized_anyobject_conformance.swift
+++ b/test/SILOptimizer/plus_zero_specialized_anyobject_conformance.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend  -O -sil-inline-threshold 0 -emit-sil -primary-file %s | %FileCheck %s
 
 // rdar://problem/31910351
diff --git a/test/Sema/fixed_ambiguities/plus_zero_rdar27198177.swift b/test/Sema/fixed_ambiguities/plus_zero_rdar27198177.swift
index 39fbc60..da42923 100644
--- a/test/Sema/fixed_ambiguities/plus_zero_rdar27198177.swift
+++ b/test/Sema/fixed_ambiguities/plus_zero_rdar27198177.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -emit-sil -verify %s -swift-version 4 | %FileCheck %s
 
 let arr = ["A", "B", "C"]
diff --git a/test/Sema/fixed_ambiguities/plus_zero_rdar33142386.swift b/test/Sema/fixed_ambiguities/plus_zero_rdar33142386.swift
index ea617e2..8bd4385 100644
--- a/test/Sema/fixed_ambiguities/plus_zero_rdar33142386.swift
+++ b/test/Sema/fixed_ambiguities/plus_zero_rdar33142386.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -emit-sil -verify %s -swift-version 4 | %FileCheck %s
 
 let x: String = "ultimate question"
diff --git a/test/Sema/fixed_ambiguities/plus_zero_rdar35623181.swift b/test/Sema/fixed_ambiguities/plus_zero_rdar35623181.swift
index 43e9c26..dcf598f 100644
--- a/test/Sema/fixed_ambiguities/plus_zero_rdar35623181.swift
+++ b/test/Sema/fixed_ambiguities/plus_zero_rdar35623181.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -emit-sil -verify %s | %FileCheck %s
 
 extension Sequence where Element == String {
diff --git a/test/Sema/fixed_ambiguities/plus_zero_rdar36333688.swift b/test/Sema/fixed_ambiguities/plus_zero_rdar36333688.swift
index 81b8f77..7317ec6 100644
--- a/test/Sema/fixed_ambiguities/plus_zero_rdar36333688.swift
+++ b/test/Sema/fixed_ambiguities/plus_zero_rdar36333688.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %target-swift-frontend -emit-sil -verify %s | %FileCheck %s
 
 infix operator +=+ : AdditionPrecedence
diff --git a/test/Serialization/plus_zero_function.swift b/test/Serialization/plus_zero_function.swift
index 0332f22..f7444b1 100644
--- a/test/Serialization/plus_zero_function.swift
+++ b/test/Serialization/plus_zero_function.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/def_func.swift
 // RUN: llvm-bcanalyzer %t/def_func.swiftmodule | %FileCheck %s
diff --git a/test/Serialization/plus_zero_objc.swift b/test/Serialization/plus_zero_objc.swift
index 787e961..1c315b6 100644
--- a/test/Serialization/plus_zero_objc.swift
+++ b/test/Serialization/plus_zero_objc.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/def_objc.swift -disable-objc-attr-requires-foundation-module
 // RUN: llvm-bcanalyzer %t/def_objc.swiftmodule | %FileCheck %s
diff --git a/test/Serialization/plus_zero_serialize_attr.swift b/test/Serialization/plus_zero_serialize_attr.swift
index ea32612..9d89e08 100644
--- a/test/Serialization/plus_zero_serialize_attr.swift
+++ b/test/Serialization/plus_zero_serialize_attr.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -emit-module -parse-as-library -o %t %s
 // RUN: llvm-bcanalyzer %t/serialize_attr.swiftmodule | %FileCheck %s -check-prefix=BCANALYZER
diff --git a/test/Serialization/plus_zero_transparent-std.swift b/test/Serialization/plus_zero_transparent-std.swift
index 0a92f03..b4c7a70 100644
--- a/test/Serialization/plus_zero_transparent-std.swift
+++ b/test/Serialization/plus_zero_transparent-std.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -emit-module -parse-stdlib -o %t %S/Inputs/def_transparent_std.swift
 // RUN: llvm-bcanalyzer %t/def_transparent_std.swiftmodule | %FileCheck %s
diff --git a/test/Serialization/plus_zero_transparent.swift b/test/Serialization/plus_zero_transparent.swift
index 3fd2497..85951b6 100644
--- a/test/Serialization/plus_zero_transparent.swift
+++ b/test/Serialization/plus_zero_transparent.swift
@@ -1,4 +1,5 @@
 // REQUIRES: plus_zero_runtime
+
 // RUN: %empty-directory(%t)
 // RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/def_transparent.swift
 // RUN: llvm-bcanalyzer %t/def_transparent.swiftmodule | %FileCheck %s
diff --git a/tools/SourceKit/include/SourceKit/Support/Logging.h b/tools/SourceKit/include/SourceKit/Support/Logging.h
index 5ee48e1..cf2d19f 100644
--- a/tools/SourceKit/include/SourceKit/Support/Logging.h
+++ b/tools/SourceKit/include/SourceKit/Support/Logging.h
@@ -40,7 +40,7 @@
 /// \endcode
 class Logger : public llvm::RefCountedBase<Logger> {
 public:
-  enum class Level : unsigned char {
+  enum class Level : uint8_t {
     /// \brief No logging.
     None = 0,
     /// \brief Warning level.
diff --git a/utils/build-script-impl b/utils/build-script-impl
index b7e70e3..9a3bcc2 100755
--- a/utils/build-script-impl
+++ b/utils/build-script-impl
@@ -70,7 +70,7 @@
     llvm-num-parallel-lto-link-jobs ""           "The number of parallel link jobs to use when compiling llvm"
     swift-stdlib-build-type     "Debug"          "the CMake build variant for Swift"
     swift-stdlib-enable-assertions "1"           "enable assertions in Swift"
-    swift-stdlib-enable-resilience "1"           "build the Swift stdlib and overlays with resilience enabled"
+    swift-stdlib-enable-resilience "0"           "build the Swift stdlib and overlays with resilience enabled"
     swift-stdlib-use-nonatomic-rc "0"            "build the Swift stdlib and overlays with nonatomic reference count operations enabled"
     lldb-build-type             "Debug"          "the CMake build variant for LLDB"
     lldb-build-with-xcode       "1"              "Use xcodebuild to build LLDB, instead of CMake"
diff --git a/validation-test/stdlib/MicroStdlib/Inputs/RuntimeStubs.c b/validation-test/stdlib/MicroStdlib/Inputs/RuntimeStubs.c
index eaa1120..fc88d14 100644
--- a/validation-test/stdlib/MicroStdlib/Inputs/RuntimeStubs.c
+++ b/validation-test/stdlib/MicroStdlib/Inputs/RuntimeStubs.c
@@ -1,6 +1,9 @@
 int $SBi32_N;
 int $SBi64_N;
 int $SBi8_N;
+int $SBi32_WV;
+int $SBi64_WV;
+int $SBi8_WV;
 void swift_getEnumCaseSinglePayload(void) {}
 void swift_getGenericMetadata(void) {}
 void swift_slowAlloc(void) {}