Merge pull request #17433 from aschwaighofer/silgen_without_actually_escaping_fix

SILGen: createWithoutActuallyEscapingClosure needs to use a substitut…
diff --git a/README.md b/README.md
index 97d1c90..9641d5b 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,10 @@
 |**[Fedora 27](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_fedora_27.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-fedora-27/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-fedora-27)|
 |**[Ubuntu 16.04](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04)|
 |**[Ubuntu 16.04 (TensorFlow)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04_tensorflow.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-tensorflow/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-tensorflow)|
-|**[Ubuntu 16.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/ppc64le_16_04.json)** | PPC64LE |[![Build Status](https://ci-external.swift.org/job/oss-swift-4.1-RA-linux-ubuntu-16.04-ppc64le/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-4.1-RA-linux-ubuntu-16.04-ppc64le)|
+|**[Ubuntu 16.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/ppc64le_ubuntu_16_04.json)** | PPC64LE |[![Build Status](https://ci-external.swift.org/job/oss-swift-4.1-RA-linux-ubuntu-16.04-ppc64le/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-4.1-RA-linux-ubuntu-16.04-ppc64le)|
+|**[Ubuntu 16.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/aarch64_ubuntu_16.04.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-aarch64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-aarch64)|
+|**[Ubuntu 16.04 (Android)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android)|
+
 
 **Welcome to Swift!**
 
diff --git a/docs/CompilerPerformance.md b/docs/CompilerPerformance.md
index 9bb3168..a7b794d 100644
--- a/docs/CompilerPerformance.md
+++ b/docs/CompilerPerformance.md
@@ -103,6 +103,13 @@
     driver is run with the flag `-wmo`, `-whole-module-optimization` or
     `-force-single-frontend-invocation` (all these options are synonymous).
 
+    - **Batch** vs. **single-file** primary-file mode. This distinction refines
+    the behaviour of primary-file mode, with the new batch mode added in the
+    Swift 4.2 release cycle. Batching eliminates much of the overhead of
+    primary-file mode, and will eventually become the default way of running
+    primary-file mode, but until that time it is explicitly enabled by passing
+    the `-enable-batch-mode` flag.
+
   - **Optimizing** vs. **non-optimizing**: this varies depending on whether the
     driver (and thus each frontend) is run with the flags `-O`, `-Osize`, or
     `-Ounchecked` (each of which turn on one or more sets of optimizations), or
@@ -120,39 +127,60 @@
 time very differently depending on their settings, so it's worth understanding
 both dimensions in a bit more detail.
 
-#### Primary-file vs. WMO
+#### Primary-file (with and without batching) vs. WMO
 
 This is the most significant variable in how the compiler behaves, so it's worth
 getting perfectly clear:
 
-  - In **primary-file mode**, the driver runs _one frontend job per file_ in the
-    module, merging the results when all the frontends finish. Each frontend job
-    itself reads _all_ the files in the module, and focuses on one _primary_
-    file among the set it read, which it compiles, lazily analyzing other
-    referenced definitions from the module as needed.
+  - In **primary-file mode**, the driver divides the work it has to do between
+    multiple frontend processes, emitting partial results and merging those
+    results when all the frontends finish. Each frontend job itself reads _all_
+    the files in the module, and focuses on one or more _primary_ file(s) among
+    the set it read, which it compiles, lazily analyzing other referenced
+    definitions from the module as needed.
+    This mode has two sub-modes:
+
+    - In the **single-file** sub-mode, it runs _one frontend job per file_, with
+      each job having a single primary.
+
+    - In the **batch** sub-mode, it runs _one frontend job per CPU_, identifying an
+      equal-sized "batch" of the module's files as primaries.
 
   - In **whole-module optimization (WMO) mode**, the driver runs one frontend
     job for the entire module, no matter what. That frontend reads all the files
     in the module _once_ and compiles them all at once.
 
-For example: if your module has 100 files in it, running `swiftc *.swift` will
-run 100 frontend subprocesses, each of which will parse all 100 inputs (for a
-total of 10,000 parses), and then each subprocess will (in parallel) compile the
-definitions in its single primary file. In contrast, running `swiftc -wmo
-*.swift` will run _one_ frontend subprocess, which then reads all 100 files
-_once_ and compiles the definitions in all of them, in order (serially).
+For example: if your module has 100 files in it:
 
-Why do both modes exist? Because they have different strengths and weaknesses;
+  - Running `swiftc *.swift` will compile in **single-file mode**, and will thus
+    run 100 frontend subprocesses, each of which will parse all 100 inputs (for
+    a total of 10,000 parses), and then each subprocess will (in parallel) 
+    compile the definitions in its single primary file.
+
+  - Running `swiftc -enable-batch-mode *.swift` will compile in **batch** mode,
+    and on a system with 4 CPUs will run 4 frontend subprocesses, each of which
+    will parse all 100 inputs (for a total of 400 parses), and then each subprocess
+    will (in parallel) compile the definitions of 25 primary files (one quarter
+    of the module in each process).
+
+  - Running `swiftc -wmo *.swift` will compile in **whole-module** mode,
+    and will thus run _one_ frontend subprocess, which then reads all 100 files
+    _once_ (for a total of 100 parses) and compiles the definitions in all of them,
+    in order (serially).
+
+Why do multiple modes exist? Because they have different strengths and weaknesses;
 neither is perfect:
 
-  - Primary-file mode's advantages are that the driver can do incremental
-    compilation by only running frontends for files that it thinks are out of
-    date, as well as running multiple frontend jobs at the same time, making use
+  - Primary-file mode's advantages are that the driver can do **incremental
+    compilation** by only running frontends for files that it thinks are out of
+    date, as well as running multiple frontend jobs **in parallel**, making use
     of multiple cores. Its disadvantage is that each frontend job has to read
-    _all the source files_ in the module before focusing on its primary-file of
+    _all the source files_ in the module before focusing on its primary-files of
     interest, which means that a _portion_ of the frontend job's work is being
-    done _quadratically_. Usually this portion is relatively small and fast, but
-    because it's quadratic, it can easily go wrong.
+    done _quadratically_ in the number of jobs. Usually this portion is relatively
+    small and fast, but because it's quadratic, it can easily go wrong. The addition
+    of **batch mode** was specifically to eliminate this quadratic increase in
+    early work.
 
   - WMO mode's advantages are that it can do certain optimizations that only
     work when they are sure they're looking at the entire module, and it avoids
@@ -161,13 +189,17 @@
     parallelism worse (at least before LLVM IR code-generation, which is always
     multithreaded).
 
-Many people get confused by the word `optimization` in the option name
-`-whole-module-optimization`, and assume the option has only to do with enabling
-"very aggressive" optimizations. It does enable such optimizations, but it also
-_significantly changes_ the way the compiler runs, so much so that some other
-people have taken to running the compiler in an unsupported (and somewhat
-unfortunate) hybrid compilation mode `-wmo -Onone`, which combines
-non-optimizing compilation with whole-module compilation.
+Whole-module mode does enable a set of optimizations that are not possible when
+compiling in primary-file mode. In particular, in modules with a lot of private
+dead code, whole-module mode can eliminate the dead code earlier and avoid
+needless work compiling it, making for both smaller output and faster compilation.
+
+It is therefore possible that, in certain cases (such as with limited available
+parallelism / many modules built in parallel), building in whole-module mode
+with optimization disabled can complete in less time than batched primary-file
+mode. This scenario depends on many factors seldom gives a significant advantage,
+and since using it trades-away support for incremental compilation entirely, it
+is not a recommended configuration.
 
 #### Amount of optimization
 
@@ -269,7 +301,7 @@
 Swift compilation performance varies _significantly_ by at least the following
 parameters:
 
-  - WMO vs. primary-file (non-WMO) mode
+  - WMO vs. primary-file (non-WMO) mode, including batching thereof
   - Optimizing vs. non-optimizing mode
   - Quantity of incremental work avoided (if in non-WMO)
   - Quantity of external definitions lazily loaded
@@ -288,7 +320,6 @@
 improvement:
 
   - Incremental mode is over-approximate, runs too many subprocesses.
-  - Name resolution is over-eager, deserializes too many definitions.
   - Too many referenced (non-primary-file) definitions are type-checked beyond
     the point they need to be, during the quadratic phase.
   - Expression type inference solves constraints inefficiently, and can
@@ -516,20 +547,22 @@
     early investigation to see which file in a primary-file-mode compilation is
     taking the majority of time, or is taking more or less time than when
     comparing compilations. Its output looks like this:
+
     ```
     ===-------------------------------------------------------------------------===
-                              Driver Time Compilation
+                                Driver Compilation Time
     ===-------------------------------------------------------------------------===
-    Total Execution Time: 0.0002 seconds (1.3390 wall clock)
+      Total Execution Time: 0.0001 seconds (0.0490 wall clock)
 
-     ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
-     0.0000 ( 87.2%)   0.0001 ( 58.7%)   0.0001 ( 67.5%)   1.0983 ( 82.0%)  compile t.swift
-     0.0000 ( 12.8%)   0.0000 ( 41.3%)   0.0000 ( 32.5%)   0.2407 ( 18.0%)  link t.swift
-     0.0000 (100.0%)   0.0001 (100.0%)   0.0002 (100.0%)   1.3390 (100.0%)  Total
+       ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
+       0.0000 ( 82.0%)   0.0001 ( 59.5%)   0.0001 ( 69.0%)   0.0284 ( 58.0%)  {compile: t-177627.o <= t.swift}
+       0.0000 ( 18.0%)   0.0000 ( 40.5%)   0.0000 ( 31.0%)   0.0206 ( 42.0%)  {link: t <= t-177627.o}
+       0.0001 (100.0%)   0.0001 (100.0%)   0.0001 (100.0%)   0.0490 (100.0%)  Total
     ```
 
   - `-Xfrontend -debug-time-compilation`: asks each frontend to print out timers
     for each phase of its execution. Its output (per-frontend) looks like this:
+
     ```
     ===-------------------------------------------------------------------------===
                                  Swift compilation
@@ -556,6 +589,7 @@
     taken. The output is therefore voluminous, but can help when reducing a
     testcase to the "one bad function" that causes it. The output looks like
     this:
+
     ```
     9.16ms  test.swift:15:6 func find<R>(_ range: R, value: R.Element) -> R where R : IteratorProtocol, R.Element : Eq
     0.28ms  test.swift:27:6 func findIf<R>(_ range: R, predicate: (R.Element) -> Bool) -> R where R : IteratorProtocol
@@ -568,6 +602,7 @@
     `-debug-time-function-bodies`, but prints a separate timer for _every
     expression_ in the program, much more detail than just the functions. The
     output looks like this:
+
     ```
     0.20ms  test.swift:17:16
     1.82ms  test.swift:18:12
@@ -582,6 +617,7 @@
     frontend, printing them out when the frontend exits. By default, most
     statistics are enabled only in assert builds, so in a release build this
     option will do nothing. In an assert build, its output will look like this:
+
     ```
     ===-------------------------------------------------------------------------===
                             ... Statistics Collected ...
@@ -612,6 +648,7 @@
     AST reader, which is operated as a subsystem fo the swift compiler when
     importing definitions from C/ObjC. Its output is added to the end of
     whatever output comes from `-print-stats`, and looks like this:
+
     ```
     *** AST File Statistics:
     1/194 source location entries read (0.515464%)
@@ -630,6 +667,7 @@
   - `-Xfrontend -print-stats -Xfrontend -print-inst-counts`: an extended form of
     `-print-stats` that activates a separate statistic counter for every kind of
     SIL instruction generated during compilation. Its output looks like this:
+
     ```
     ...
     163 sil-instcount                    - Number of AllocStackInst
diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp
index 4f380a3..a221ab8 100644
--- a/lib/ClangImporter/ImportDecl.cpp
+++ b/lib/ClangImporter/ImportDecl.cpp
@@ -4891,13 +4891,18 @@
       Impl.recordImplicitUnwrapForDecl(result,
                                        importedType.isImplicitlyUnwrapped());
 
+      // Recover from a missing getter in no-asserts builds. We're still not
+      // sure under what circumstances this occurs, but we shouldn't crash.
+      auto clangGetter = decl->getGetterMethodDecl();
+      assert(clangGetter && "ObjC property without getter");
+      if (!clangGetter)
+        return nullptr;
+
       // Import the getter.
-      AccessorDecl *getter = nullptr;
-      if (auto clangGetter = decl->getGetterMethodDecl()) {
-        getter = importAccessor(clangGetter, result, AccessorKind::Get, dc);
-        if (!getter)
-          return nullptr;
-      }
+      AccessorDecl *getter = importAccessor(clangGetter, result,
+                                            AccessorKind::Get, dc);
+      if (!getter)
+        return nullptr;
 
       // Import the setter, if there is one.
       AccessorDecl *setter = nullptr;
diff --git a/lib/IDE/TypeReconstruction.cpp b/lib/IDE/TypeReconstruction.cpp
index 949a81f..efeb242 100644
--- a/lib/IDE/TypeReconstruction.cpp
+++ b/lib/IDE/TypeReconstruction.cpp
@@ -786,9 +786,10 @@
       cast<TypeAliasDecl>(generic_type_result._decls.front());
   GenericSignature *signature = genericTypeAlias->getGenericSignature();
   // FIXME: handle conformances.
-  SubstitutionMap subMap =
-      SubstitutionMap::get(signature, template_types_result._types,
-                           ArrayRef<ProtocolConformanceRef>({}));
+  SubstitutionMap subMap;
+  if (signature)
+    subMap = SubstitutionMap::get(signature, template_types_result._types,
+                                  ArrayRef<ProtocolConformanceRef>({}));
   Type parentType;
   if (auto nominal = genericTypeAlias->getDeclContext()
                          ->getAsNominalTypeOrNominalTypeExtensionContext()) {
diff --git a/lib/Sema/TypeCheckGeneric.cpp b/lib/Sema/TypeCheckGeneric.cpp
index bf5b857..d3f9486 100644
--- a/lib/Sema/TypeCheckGeneric.cpp
+++ b/lib/Sema/TypeCheckGeneric.cpp
@@ -307,6 +307,9 @@
   if (req.isInvalid())
     return true;
 
+  // Note that we are resolving within a requirement.
+  options |= TypeResolutionFlags::GenericRequirement;
+
   switch (req.getKind()) {
   case RequirementReprKind::TypeConstraint: {
     // Validate the types.
diff --git a/lib/Sema/TypeCheckType.cpp b/lib/Sema/TypeCheckType.cpp
index 5d8dd09..4045d5a 100644
--- a/lib/Sema/TypeCheckType.cpp
+++ b/lib/Sema/TypeCheckType.cpp
@@ -815,30 +815,32 @@
           (nominal = nominalDC->getAsNominalTypeOrNominalTypeExtensionContext())) {
         // Attempt to refer to 'Self' within a non-protocol nominal
         // type. Fix this by replacing 'Self' with the nominal type name.
-
-        // Retrieve the nominal type and resolve it within this context.
         assert(!isa<ProtocolDecl>(nominal) && "Cannot be a protocol");
-        auto type = resolver->mapTypeIntoContext(
-          dc->getInnermostTypeContext()->getSelfInterfaceType());
-        if (type->hasError())
-          return type;
 
         // Produce a Fix-It replacing 'Self' with the nominal type name.
         auto name = getDeclNameFromContext(dc, nominal);
         tc.diagnose(comp->getIdLoc(), diag::self_in_nominal, name)
           .fixItReplace(comp->getIdLoc(), name);
+
+        // If this is a requirement, replacing 'Self' with a valid type will
+        // result in additional unnecessary diagnostics (does not refer to a
+        // generic parameter or associated type). Simply return an error type.
+        if (options.contains(TypeResolutionFlags::GenericRequirement))
+          return ErrorType::get(tc.Context);
+
+        auto type = resolver->mapTypeIntoContext(
+          dc->getInnermostTypeContext()->getSelfInterfaceType());
+
         comp->overwriteIdentifier(nominal->getName());
         comp->setValue(nominal, nominalDC->getParent());
         return type;
-      } else {
-        // Attempt to refer to 'Self' from a free function.
-        tc.diagnose(comp->getIdLoc(), diag::dynamic_self_non_method,
-                    dc->getParent()->isLocalContext());
-
-        return ErrorType::get(tc.Context);
       }
-    }
+      // Attempt to refer to 'Self' from a free function.
+      tc.diagnose(comp->getIdLoc(), diag::dynamic_self_non_method,
+                  dc->getParent()->isLocalContext());
 
+      return ErrorType::get(tc.Context);
+    }
 
     // Try ignoring access control.
     DeclContext *lookupDC = dc;
diff --git a/lib/Sema/TypeChecker.h b/lib/Sema/TypeChecker.h
index 5cfc029..0e6d5b1 100644
--- a/lib/Sema/TypeChecker.h
+++ b/lib/Sema/TypeChecker.h
@@ -543,6 +543,9 @@
 
   /// Is it okay to resolve an IUO sigil ("!") here with a deprecation warning?
   AllowIUODeprecated = 1 << 25,
+
+  /// Whether we are in a requirement of a generic declaration
+  GenericRequirement = 1 << 26,
 };
 
 /// Option set describing how type resolution should work.
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index d0a1f25..f1362e9 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -43,7 +43,7 @@
       swift swift-ide-test swift-syntax-test sil-opt swift-llvm-opt swift-demangle
       sil-func-extractor sil-llvm-gen sil-nm sil-passpipeline-dumper
       lldb-moduleimport-test swift-reflection-dump swift-remoteast-test
-      swift-api-digester swift-refactor)
+      swift-api-digester swift-refactor swift-demangle-yamldump)
   if(NOT SWIFT_BUILT_STANDALONE)
     list(APPEND deps_binaries FileCheck arcmt-test c-arcmt-test c-index-test
          clang llc llvm-cov llvm-dwarfdump llvm-link llvm-as llvm-dis
diff --git a/test/DebugInfo/DumpTypeFromMangledName.swift b/test/DebugInfo/DumpTypeFromMangledName.swift
index 92615af..1c9e16d 100644
--- a/test/DebugInfo/DumpTypeFromMangledName.swift
+++ b/test/DebugInfo/DumpTypeFromMangledName.swift
@@ -39,3 +39,18 @@
 }
 
 let _ = main()
+
+public struct tinky : Equatable, Hashable {
+  internal let _value: Int
+
+  public var hashValue: Int {
+    return 0
+  }
+}
+
+public func == (lhs: tinky, rhs: tinky) -> Bool {
+  return true
+}
+
+public typealias patatino = UnsafePointer<tinky>
+var local_thread_one: patatino?
diff --git a/test/DebugInfo/Inputs/type-reconstr-names.txt b/test/DebugInfo/Inputs/type-reconstr-names.txt
index 91d7794..856471b 100644
--- a/test/DebugInfo/Inputs/type-reconstr-names.txt
+++ b/test/DebugInfo/Inputs/type-reconstr-names.txt
@@ -10,3 +10,4 @@
 $SSayypXpG ---> Array<Any.Type>
 $S12EyeCandyCore11XPCListenerC14messageHandleryyAA13XPCConnectionV_AA10XPCMessageVxtcvpfiyAF_AHxtcfU_TA.4 ---> Can't resolve type of $S12EyeCandyCore11XPCListenerC14messageHandleryyAA13XPCConnectionV_AA10XPCMessageVxtcvpfiyAF_AHxtcfU_TA.4
 $Ss10CollectionP7ElementQa ---> Can't resolve type of $Ss10CollectionP7ElementQa
+$S12TypeReconstr8patatinoayAA5tinkyVGSgD ---> Optional<patatino>
diff --git a/test/IRGen/abitypes.swift b/test/IRGen/abitypes.swift
index acdf091..2540ce0 100644
--- a/test/IRGen/abitypes.swift
+++ b/test/IRGen/abitypes.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/abi %s -emit-ir -enable-objc-interop -swift-version 3 | %FileCheck -check-prefix=%target-cpu-%target-os %s
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/abi %s -emit-ir -enable-objc-interop | %FileCheck -check-prefix=%target-cpu-%target-os %s
 
 // FIXME: rdar://problem/19648117 Needs splitting objc parts out
 // XFAIL: linux
@@ -38,7 +38,7 @@
   // i386-watchos: define hidden void @"$S8abitypes3FooC3bar{{[_0-9a-zA-Z]*}}FTo"(%TSo6MyRectV* noalias nocapture sret, i8*, i8*) unnamed_addr {{.*}} {
   // armv7k-watchos: define hidden swiftcc { float, float, float, float } @"$S8abitypes3FooC3bar{{[_0-9a-zA-Z]*}}F"(%T8abitypes3FooC* swiftself) {{.*}} {
   // armv7k-watchos: define hidden [[ARMV7K_MYRECT]] @"$S8abitypes3FooC3bar{{[_0-9a-zA-Z]*}}FTo"(i8*, i8*) unnamed_addr {{.*}} {
-  dynamic func bar() -> MyRect {
+  @objc dynamic func bar() -> MyRect {
     return MyRect(x: 1, y: 2, width: 3, height: 4)
   }
 
@@ -51,7 +51,7 @@
   // armv7s-ios: define hidden double @"$S8abitypes3FooC14getXFromNSRect{{[_0-9a-zA-Z]*}}FTo"(i8*, i8*, [4 x i32]) unnamed_addr {{.*}} {
   // armv7k-watchos: define hidden swiftcc double @"$S8abitypes3FooC14getXFromNSRect{{[_0-9a-zA-Z]*}}F"(float, float, float, float, %T8abitypes3FooC* swiftself) {{.*}} {
   // armv7k-watchos: define hidden double @"$S8abitypes3FooC14getXFromNSRect{{[_0-9a-zA-Z]*}}FTo"(i8*, i8*, [4 x float]) unnamed_addr {{.*}} {
-  dynamic func getXFromNSRect(_ r: NSRect) -> Double {
+  @objc dynamic func getXFromNSRect(_ r: NSRect) -> Double {
     return Double(r.origin.x)
   }
 
@@ -63,7 +63,7 @@
   // armv7s-ios: define hidden float @"$S8abitypes3FooC12getXFromRect{{[_0-9a-zA-Z]*}}FTo"(i8*, i8*, [4 x i32]) unnamed_addr {{.*}} {
   // armv7k-watchos: define hidden swiftcc float @"$S8abitypes3FooC12getXFromRect{{[_0-9a-zA-Z]*}}F"(float, float, float, float, %T8abitypes3FooC* swiftself) {{.*}} {
   // armv7k-watchos: define hidden float @"$S8abitypes3FooC12getXFromRect{{[_0-9a-zA-Z]*}}FTo"(i8*, i8*, [4 x float]) unnamed_addr {{.*}} {
-  dynamic func getXFromRect(_ r: MyRect) -> Float {
+  @objc dynamic func getXFromRect(_ r: MyRect) -> Float {
     return r.x
   }
 
@@ -109,7 +109,7 @@
 
   // Ensure that MyRect is passed as an indirect-byval on x86_64 because we run out of registers for direct arguments
   // x86_64-macosx: define hidden float @"$S8abitypes3FooC25getXFromRectIndirectByVal{{[_0-9a-zA-Z]*}}FTo"(i8*, i8*, float, float, float, float, float, float, float, %TSo6MyRectV* byval align 8) unnamed_addr {{.*}} {
-  dynamic func getXFromRectIndirectByVal(_: Float, second _: Float, 
+  @objc dynamic func getXFromRectIndirectByVal(_: Float, second _: Float, 
                                        third _: Float, fourth _: Float,
                                        fifth _: Float, sixth _: Float,
                                        seventh _: Float, withRect r: MyRect)
@@ -173,7 +173,7 @@
 
   // x86_64-macosx: define hidden swiftcc { double, double, double } @"$S8abitypes3FooC3baz{{[_0-9a-zA-Z]*}}F"(%T8abitypes3FooC* swiftself) {{.*}} {
   // x86_64-macosx: define hidden void @"$S8abitypes3FooC3baz{{[_0-9a-zA-Z]*}}FTo"(%TSo4TrioV* noalias nocapture sret, i8*, i8*) unnamed_addr {{.*}} {
-  dynamic func baz() -> Trio {
+  @objc dynamic func baz() -> Trio {
     return Trio(i: 1.0, j: 2.0, k: 3.0)
   }
 
@@ -197,7 +197,7 @@
   }
 
   // x86_64-macosx:      define hidden i64 @"$S8abitypes3FooC8takepair{{[_0-9a-zA-Z]*}}FTo"(i8*, i8*, i64) unnamed_addr {{.*}} {
-  dynamic func takepair(_ p: IntPair) -> IntPair {
+  @objc dynamic func takepair(_ p: IntPair) -> IntPair {
     return p
   }
 
@@ -221,7 +221,7 @@
   // x86_64-macosx:      [[T0:%.*]] = call [[OBJC:%objc_class]]* @swift_getObjCClassFromMetadata([[TYPE]]* [[VALUE]])
   // x86_64-macosx:      [[RESULT:%[0-9]+]] = bitcast [[OBJC]]* [[T0]] to i8*
   // x86_64-macosx:      ret i8* [[RESULT]]
-  dynamic func copyClass(_ a: AnyClass) -> AnyClass {
+  @objc dynamic func copyClass(_ a: AnyClass) -> AnyClass {
     return a
   }
 
@@ -229,7 +229,7 @@
   // x86_64-macosx:      [[VALUE:%[0-9]+]] = call swiftcc [[TYPE:%.*]] @"$S8abitypes3FooC9copyProto{{[_0-9a-zA-Z]*}}F"
   // x86_64-macosx:      [[RESULT:%[0-9]+]] = bitcast [[TYPE]] [[VALUE]] to i8*
   // x86_64-macosx:      ret i8* [[RESULT]]
-  dynamic func copyProto(_ a: AnyObject) -> AnyObject {
+  @objc dynamic func copyProto(_ a: AnyObject) -> AnyObject {
     return a
   }
 
@@ -237,7 +237,7 @@
   // x86_64-macosx:      [[VALUE:%[0-9]+]] = call swiftcc [[TYPE:%.*]] @"$S8abitypes3FooC13copyProtoComp{{[_0-9a-zA-Z]*}}F"
   // x86_64-macosx:      [[RESULT:%[0-9]+]] = bitcast [[TYPE]] [[VALUE]] to i8*
   // x86_64-macosx:      ret i8* [[RESULT]]
-  dynamic func copyProtoComp(_ a: P1 & P2) -> P1 & P2 {
+  @objc dynamic func copyProtoComp(_ a: P1 & P2) -> P1 & P2 {
     return a
   }
 
@@ -300,7 +300,7 @@
   // i386-watchos:  [[R3:%[0-9]+]] = call swiftcc i1 @"$S10ObjectiveC22_convertBoolToObjCBoolyAA0eF0VSbF"(i1 [[R2]])
   // i386-watchos:  ret i1 [[R3]]
 
-  dynamic func negate(_ b: Bool) -> Bool {
+  @objc dynamic func negate(_ b: Bool) -> Bool {
     return !b
   }
 
@@ -416,7 +416,7 @@
   // armv7k-watchos: [[TOOBJCBOOL:%[0-9]+]] = call swiftcc i1 @"$S10ObjectiveC22_convertBoolToObjCBool{{[_0-9a-zA-Z]*}}F"(i1 [[NEG]])
   // armv7k-watchos: ret i1 [[TOOBJCBOOL]]
   //
-  dynamic func negate2(_ b: Bool) -> Bool {
+  @objc dynamic func negate2(_ b: Bool) -> Bool {
     var g = Gadget()
     return g.negate(b)
   }
@@ -439,7 +439,7 @@
   // i386-ios: ret i1 [[NEG]]
   // i386-ios: }
 
-  dynamic func negate3(_ b: Bool) -> Bool {
+  @objc dynamic func negate3(_ b: Bool) -> Bool {
     var g = Gadget()
     return g.invert(b)
   }
@@ -458,23 +458,23 @@
   // i386-ios: [[SEL:%[0-9]+]] = load i8*, i8** @"\01L_selector(negateThrowing:error:)", align 4
   // i386-ios: call signext i8 bitcast (void ()* @objc_msgSend to i8 (%1*, i8*, i8, %2**)*)(%1* {{%[0-9]+}}, i8* [[SEL]], i8 signext {{%[0-9]+}}, %2** {{%[0-9]+}})
   // i386-ios: }
-  dynamic func throwsTest(_ b: Bool) throws {
+  @objc dynamic func throwsTest(_ b: Bool) throws {
     var g = Gadget()
     try g.negateThrowing(b)
   }
 
   // x86_64-macosx: define hidden i32* @"$S8abitypes3FooC24copyUnsafeMutablePointer{{[_0-9a-zA-Z]*}}FTo"(i8*, i8*, i32*) unnamed_addr {{.*}} {
-  dynamic func copyUnsafeMutablePointer(_ p: UnsafeMutablePointer<Int32>) -> UnsafeMutablePointer<Int32> {
+  @objc dynamic func copyUnsafeMutablePointer(_ p: UnsafeMutablePointer<Int32>) -> UnsafeMutablePointer<Int32> {
     return p
   }
 
   // x86_64-macosx: define hidden i64 @"$S8abitypes3FooC17returnNSEnumValue{{[_0-9a-zA-Z]*}}FTo"(i8*, i8*) unnamed_addr {{.*}} {
-  dynamic func returnNSEnumValue() -> ByteCountFormatter.CountStyle {
+  @objc dynamic func returnNSEnumValue() -> ByteCountFormatter.CountStyle {
     return .file
   }
 
   // x86_64-macosx: define hidden zeroext i16 @"$S8abitypes3FooC20returnOtherEnumValue{{[_0-9a-zA-Z]*}}FTo"(i8*, i8*, i16 zeroext) unnamed_addr {{.*}} {
-  dynamic func returnOtherEnumValue(_ choice: ChooseTo) -> ChooseTo {
+  @objc dynamic func returnOtherEnumValue(_ choice: ChooseTo) -> ChooseTo {
     switch choice {
       case .takeIt: return .leaveIt
       case .leaveIt: return .takeIt
@@ -483,7 +483,7 @@
 
   // x86_64-macosx: define hidden swiftcc i32 @"$S8abitypes3FooC10getRawEnum{{[_0-9a-zA-Z]*}}F"(%T8abitypes3FooC* swiftself) {{.*}} {
   // x86_64-macosx: define hidden i32 @"$S8abitypes3FooC10getRawEnum{{[_0-9a-zA-Z]*}}FTo"(i8*, i8*) unnamed_addr {{.*}} {
-  dynamic func getRawEnum() -> RawEnum {
+  @objc dynamic func getRawEnum() -> RawEnum {
     return Intergalactic
   }
 
@@ -493,13 +493,13 @@
   }
 
   // x86_64-macosx: define hidden void @"$S8abitypes3FooC13testArchetype{{[_0-9a-zA-Z]*}}FTo"(i8*, i8*, i8*) unnamed_addr {{.*}} {
-  dynamic func testArchetype(_ work: Work) {
+  @objc dynamic func testArchetype(_ work: Work) {
     work.doStuff(1)
     // x86_64-macosx: [[OBJCPTR:%.*]] = bitcast i8* %2 to %objc_object*
     // x86_64-macosx: call swiftcc void @"$S8abitypes3FooC13testArchetype{{[_0-9a-zA-Z]*}}F"(%objc_object* [[OBJCPTR]], %T8abitypes3FooC* swiftself %{{.*}})
   }
 
-  dynamic func foo(_ x: @convention(block) (Int) -> Int) -> Int {
+  @objc dynamic func foo(_ x: @convention(block) (Int) -> Int) -> Int {
     // FIXME: calling blocks is currently unimplemented
     // return x(5)
     return 1
@@ -517,7 +517,7 @@
   //
   // arm64-tvos: define hidden swiftcc { i64, i64, i64, i64 } @"$S8abitypes3FooC14callJustReturn{{[_0-9a-zA-Z]*}}F"(%TSo13StructReturnsC*, i64, i64, i64, i64, %T8abitypes3FooC* swiftself) {{.*}} {
   // arm64-tvos: define hidden void @"$S8abitypes3FooC14callJustReturn{{[_0-9a-zA-Z]*}}FTo"(%TSo9BigStructV* noalias nocapture sret, i8*, i8*, [[OPAQUE:.*]]*, %TSo9BigStructV*) unnamed_addr {{.*}} {
-  dynamic func callJustReturn(_ r: StructReturns, with v: BigStruct) -> BigStruct {
+  @objc dynamic func callJustReturn(_ r: StructReturns, with v: BigStruct) -> BigStruct {
     return r.justReturn(v)
   }
 
diff --git a/test/IRGen/builtins.swift b/test/IRGen/builtins.swift
index 4d0f95c..0ab5cd4 100644
--- a/test/IRGen/builtins.swift
+++ b/test/IRGen/builtins.swift
@@ -1,5 +1,5 @@
 
-// RUN: %target-swift-frontend -module-name builtins -assume-parsing-unqualified-ownership-sil -parse-stdlib -primary-file %s -emit-ir -o - -disable-objc-attr-requires-foundation-module -swift-version 3 | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-runtime
+// RUN: %target-swift-frontend -module-name builtins -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
 
@@ -14,67 +14,25 @@
 
 // CHECK: call swiftcc void @swift_errorInMain(
 
-infix operator * {
-  associativity left
-  precedence 200
-}
-infix operator / {
-  associativity left
-  precedence 200
-}
-infix operator % {
-  associativity left
-  precedence 200
-}
+infix operator *
+infix operator /
+infix operator %
 
-infix operator + {
-  associativity left
-  precedence 190
-}
-infix operator - {
-  associativity left
-  precedence 190
-}
+infix operator +
+infix operator -
 
-infix operator << {
-  associativity none
-  precedence 180
-}
-infix operator >> {
-  associativity none
-  precedence 180
-}
+infix operator <<
+infix operator >>
 
-infix operator ... {
-  associativity none
-  precedence 175
-}
+infix operator ...
 
-infix operator < {
-  associativity none
-  precedence 170
-}
-infix operator <= {
-  associativity none
-  precedence 170
-}
-infix operator > {
-  associativity none
-  precedence 170
-}
-infix operator >= {
-  associativity none
-  precedence 170
-}
+infix operator <
+infix operator <=
+infix operator >
+infix operator >=
 
-infix operator == {
-  associativity none
-  precedence 160
-}
-infix operator != {
-  associativity none
-  precedence 160
-}
+infix operator ==
+infix operator !=
 
 func * (lhs: Int, rhs: Int) -> Int {
   return Builtin.mul_Int32(lhs, rhs)
@@ -785,7 +743,7 @@
   // CHECK: store i1 true, i1*
   // CHECK: store i1 false, i1*
   var t = Builtin.ispod(Int.self)
-  var f = Builtin.ispod(Builtin.NativeObject)
+  var f = Builtin.ispod(Builtin.NativeObject.self)
 }
 
 // CHECK-LABEL: define {{.*}} @{{.*}}is_same_metatype
diff --git a/test/IRGen/dllimport.swift b/test/IRGen/dllimport.swift
index 3cad1c2..8ff481f 100644
--- a/test/IRGen/dllimport.swift
+++ b/test/IRGen/dllimport.swift
@@ -1,5 +1,5 @@
-// RUN: %swift -target thumbv7--windows-itanium -emit-ir -parse-as-library -parse-stdlib -module-name dllimport %s -o - -enable-source-import -I %S -swift-version 3 | %FileCheck %s -check-prefix CHECK -check-prefix CHECK-NO-OPT
-// RUN: %swift -target thumbv7--windows-itanium -O -emit-ir -parse-as-library -parse-stdlib -module-name dllimport -primary-file %s -o - -enable-source-import -I %S -swift-version 3 | %FileCheck %s -check-prefix CHECK -check-prefix CHECK-OPT
+// RUN: %swift -target thumbv7--windows-itanium -emit-ir -parse-as-library -parse-stdlib -module-name dllimport %s -o - -enable-source-import -I %S | %FileCheck %s -check-prefix CHECK -check-prefix CHECK-NO-OPT
+// RUN: %swift -target thumbv7--windows-itanium -O -emit-ir -parse-as-library -parse-stdlib -module-name dllimport -primary-file %s -o - -enable-source-import -I %S | %FileCheck %s -check-prefix CHECK -check-prefix CHECK-OPT
 
 // REQUIRES: CODEGENERATOR=ARM
 
@@ -10,7 +10,7 @@
 }
 
 public func get_c_type() -> dllexport.c.Type {
-  return dllexport.c
+  return dllexport.c.self
 }
 
 public class d : c {
diff --git a/test/IRGen/generic_metatypes.swift b/test/IRGen/generic_metatypes.swift
index a081595..1017db9 100644
--- a/test/IRGen/generic_metatypes.swift
+++ b/test/IRGen/generic_metatypes.swift
@@ -1,21 +1,30 @@
 
-// RUN: %swift -module-name generic_metatypes -target x86_64-apple-macosx10.9  -emit-ir -parse-stdlib -primary-file %s -swift-version 3 | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s
-// RUN: %swift -module-name generic_metatypes -target i386-apple-ios7.0        -emit-ir -parse-stdlib -primary-file %s -swift-version 3 | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32 %s
-// RUN: %swift -module-name generic_metatypes -target x86_64-apple-ios7.0      -emit-ir -parse-stdlib -primary-file %s -swift-version 3 | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64  %s
-// RUN: %swift -module-name generic_metatypes -target i386-apple-tvos9.0       -emit-ir -parse-stdlib -primary-file %s -swift-version 3 | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32  %s
-// RUN: %swift -module-name generic_metatypes -target x86_64-apple-tvos9.0     -emit-ir -parse-stdlib -primary-file %s -swift-version 3 | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64  %s
-// RUN: %swift -module-name generic_metatypes -target i386-apple-watchos2.0    -emit-ir -parse-stdlib -primary-file %s -swift-version 3 | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32  %s
-// RUN: %swift -module-name generic_metatypes -target x86_64-unknown-linux-gnu -disable-objc-interop -emit-ir -parse-stdlib -primary-file %s -swift-version 3 | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s
+// RUN: %swift -module-name generic_metatypes -target x86_64-apple-macosx10.9  -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s
+// RUN: %swift -module-name generic_metatypes -target i386-apple-ios7.0        -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32 %s
+// RUN: %swift -module-name generic_metatypes -target x86_64-apple-ios7.0      -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64  %s
+// RUN: %swift -module-name generic_metatypes -target i386-apple-tvos9.0       -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32  %s
+// RUN: %swift -module-name generic_metatypes -target x86_64-apple-tvos9.0     -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64  %s
+// RUN: %swift -module-name generic_metatypes -target i386-apple-watchos2.0    -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32  %s
+// RUN: %swift -module-name generic_metatypes -target x86_64-unknown-linux-gnu -disable-objc-interop -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s
 
-// RUN: %swift -module-name generic_metatypes -target armv7-apple-ios7.0       -emit-ir -parse-stdlib -primary-file %s -swift-version 3 | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32 %s
-// RUN: %swift -module-name generic_metatypes -target arm64-apple-ios7.0       -emit-ir -parse-stdlib -primary-file %s -swift-version 3 | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s
-// RUN: %swift -module-name generic_metatypes -target armv7-apple-tvos9.0      -emit-ir -parse-stdlib -primary-file %s -swift-version 3 | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32 %s
-// RUN: %swift -module-name generic_metatypes -target arm64-apple-tvos9.0      -emit-ir -parse-stdlib -primary-file %s -swift-version 3 | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s
-// RUN: %swift -module-name generic_metatypes -target armv7k-apple-watchos2.0  -emit-ir -parse-stdlib -primary-file %s -swift-version 3 | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32 %s
+// RUN: %swift -module-name generic_metatypes -target armv7-apple-ios7.0       -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32 %s
+// RUN: %swift -module-name generic_metatypes -target arm64-apple-ios7.0       -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s
+// RUN: %swift -module-name generic_metatypes -target armv7-apple-tvos9.0      -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32 %s
+// RUN: %swift -module-name generic_metatypes -target arm64-apple-tvos9.0      -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s
+// RUN: %swift -module-name generic_metatypes -target armv7k-apple-watchos2.0  -emit-ir -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32 %s
 
 // REQUIRES: CODEGENERATOR=X86
 // REQUIRES: CODEGENERATOR=ARM
 
+enum Never {}
+
+func never() -> Never { return never() }
+
+@_semantics("typechecker.type(of:)")
+public func type<T, Metatype>(of value: T) -> Metatype {
+  never()
+}
+
 // CHECK: define hidden swiftcc %swift.type* [[GENERIC_TYPEOF:@"\$S17generic_metatypes0A6TypeofyxmxlF"]](%swift.opaque* noalias nocapture, %swift.type* [[TYPE:%.*]])
 func genericTypeof<T>(_ x: T) -> T.Type {
   // CHECK: [[METATYPE:%.*]] = call %swift.type* @swift_getDynamicType(%swift.opaque* {{.*}}, %swift.type* [[TYPE]], i1 false)
diff --git a/test/IRGen/infinite_archetype.swift b/test/IRGen/infinite_archetype.swift
index 450d386..f51e1f2 100644
--- a/test/IRGen/infinite_archetype.swift
+++ b/test/IRGen/infinite_archetype.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -emit-ir -swift-version 3 | %FileCheck %s
+// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -emit-ir | %FileCheck %s
 
 // REQUIRES: CPU=i386 || CPU=x86_64
 
@@ -7,4 +7,4 @@
 }
 
 // CHECK: define hidden swiftcc void @"$S18infinite_archetype3foo{{[_0-9a-zA-Z]*}}F"(%swift.opaque* noalias nocapture sret, %swift.opaque* noalias nocapture, %swift.type* %T, i8** %T.Fooable)
-func foo<T: Fooable where T == T.Foo>(x: T) -> T { return x }
+func foo<T: Fooable>(x: T) -> T where T == T.Foo { return x }
diff --git a/test/IRGen/keypaths_objc.sil b/test/IRGen/keypaths_objc.sil
index cd7a694..65cfe86 100644
--- a/test/IRGen/keypaths_objc.sil
+++ b/test/IRGen/keypaths_objc.sil
@@ -1,14 +1,14 @@
 
 // RUN: %empty-directory(%t)
 // RUN: %{python} %utils/chex.py < %s > %t/keypaths_objc.sil
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-ir %t/keypaths_objc.sil -swift-version 3 | %FileCheck %t/keypaths_objc.sil --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
+// 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
 // REQUIRES: objc_interop
 
 import Swift
 import Foundation
 
 class C: NSObject {
-  dynamic var x: NSString { get }
+  @objc dynamic var x: NSString { get }
   @sil_stored final var stored: Int
   override init()
 }
diff --git a/test/IRGen/local_types.swift b/test/IRGen/local_types.swift
index 81fd2d3..e72b416 100644
--- a/test/IRGen/local_types.swift
+++ b/test/IRGen/local_types.swift
@@ -1,6 +1,6 @@
 // RUN: %empty-directory(%t)
-// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-module %S/Inputs/local_types_helper.swift -o %t -swift-version 3
-// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -enable-objc-interop -emit-ir -parse-as-library %s -I %t -swift-version 3 | %FileCheck -check-prefix CHECK -check-prefix NEGATIVE %s
+// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-module %S/Inputs/local_types_helper.swift -o %t
+// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -enable-objc-interop -emit-ir -parse-as-library %s -I %t | %FileCheck -check-prefix CHECK -check-prefix NEGATIVE %s
 
 import local_types_helper
 
@@ -28,18 +28,6 @@
   })()
 }
 
-public func singleDefaultArgument(i: Int = {
-  // CHECK-DAG: @"$S11local_types21singleDefaultArgument1iySi_tFfA_SiycfU_06SingledE6StructL_VMf" = internal constant
-  struct SingleDefaultArgumentStruct {
-    let i: Int
-  }
-  return 2
-
-  }()){
-    print(i)
-}
-
-
 #if COMPILED_OUT
 public func topLevelIfConfig() {
   class LocalClassDisabled {}
diff --git a/test/IRGen/local_types_swift3.swift b/test/IRGen/local_types_swift3.swift
new file mode 100644
index 0000000..6f4ad4a
--- /dev/null
+++ b/test/IRGen/local_types_swift3.swift
@@ -0,0 +1,15 @@
+// RUN: %empty-directory(%t)
+// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -enable-objc-interop -emit-ir -parse-as-library -swift-version 3 %s | %FileCheck %s
+
+public func singleDefaultArgument(i: Int = {
+  // CHECK-DAG: @"$S18local_types_swift321singleDefaultArgument1iySi_tFfA_SiycfU_06SingleeF6StructL_VMf" = internal constant
+  struct SingleDefaultArgumentStruct {
+    let i: Int
+  }
+  return 2
+
+  }()){
+    print(i)
+}
+
+
diff --git a/test/IRGen/objc.swift b/test/IRGen/objc.swift
index e19145e..ef0d59f 100644
--- a/test/IRGen/objc.swift
+++ b/test/IRGen/objc.swift
@@ -1,7 +1,7 @@
 
 // RUN: %empty-directory(%t)
 // RUN: %build-irgen-test-overlays
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -module-name objc -primary-file %s -emit-ir -disable-objc-attr-requires-foundation-module -swift-version 3 | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -module-name objc -primary-file %s -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck %s
 
 // REQUIRES: CPU=x86_64
 // REQUIRES: objc_interop
@@ -51,12 +51,12 @@
 // CHECK:    call {{.*}} @objc_release
 // CHECK:    ret void
 
-  dynamic func bar() {}
+  @objc dynamic func bar() {}
 }
 
 // Test @nonobjc.
 class Contrarian : Blammo {
-  func acquiesce() {}
+  @objc func acquiesce() {}
   @nonobjc func disharmonize() {}
   @nonobjc func eviscerate() {}
 }
diff --git a/test/IRGen/objc_bridge.swift b/test/IRGen/objc_bridge.swift
index 80c61a7..864806b 100644
--- a/test/IRGen/objc_bridge.swift
+++ b/test/IRGen/objc_bridge.swift
@@ -1,6 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %build-irgen-test-overlays
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -emit-ir -primary-file %s -swift-version 3 | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -emit-ir -primary-file %s | %FileCheck %s
 
 // REQUIRES: CPU=x86_64
 // REQUIRES: objc_interop
@@ -132,7 +132,7 @@
 extension NSString {
   // CHECK: define internal [[OPAQUE:.*]]* @"$SSo8NSStringC11objc_bridgeE13nsstrFakePropABvgTo"([[OPAQUE:.*]]*, i8*) unnamed_addr
   // CHECK: define internal void @"$SSo8NSStringC11objc_bridgeE13nsstrFakePropABvsTo"([[OPAQUE:.*]]*, i8*, [[OPAQUE:.*]]*) unnamed_addr
-  var nsstrFakeProp : NSString {
+  @objc var nsstrFakeProp : NSString {
     get {
       return NSS
     }
@@ -140,20 +140,20 @@
   }
 
   // CHECK: define internal [[OPAQUE:.*]]* @"$SSo8NSStringC11objc_bridgeE11nsstrResultAByFTo"([[OPAQUE:.*]]*, i8*) unnamed_addr
-  func nsstrResult() -> NSString { return NSS }
+  @objc func nsstrResult() -> NSString { return NSS }
 
   // CHECK: define internal void @"$SSo8NSStringC11objc_bridgeE8nsstrArg1syAB_tFTo"([[OPAQUE:.*]]*, i8*, [[OPAQUE:.*]]*) unnamed_addr
-  func nsstrArg(s s: NSString) { }
+  @objc func nsstrArg(s s: NSString) { }
 }
 
 class Bas : NSObject {
   // CHECK: define internal [[OPAQUE:.*]]* @"$S11objc_bridge3BasC11strRealPropSSvgTo"([[OPAQUE:.*]]*, i8*) unnamed_addr {{.*}} {
   // CHECK: define internal void @"$S11objc_bridge3BasC11strRealPropSSvsTo"([[OPAQUE:.*]]*, i8*, [[OPAQUE:.*]]*) unnamed_addr {{.*}} {
-  var strRealProp : String
+  @objc var strRealProp : String
 
   // CHECK: define internal [[OPAQUE:.*]]* @"$S11objc_bridge3BasC11strFakePropSSvgTo"([[OPAQUE:.*]]*, i8*) unnamed_addr {{.*}} {
   // CHECK: define internal void @"$S11objc_bridge3BasC11strFakePropSSvsTo"([[OPAQUE:.*]]*, i8*, [[OPAQUE:.*]]*) unnamed_addr {{.*}} {
-  var strFakeProp : String {
+  @objc var strFakeProp : String {
     get {
       return ""
     }
@@ -162,11 +162,11 @@
 
   // CHECK: define internal [[OPAQUE:.*]]* @"$S11objc_bridge3BasC13nsstrRealPropSo8NSStringCvgTo"([[OPAQUE:.*]]*, i8*) unnamed_addr {{.*}} {
   // CHECK: define internal void @"$S11objc_bridge3BasC13nsstrRealPropSo8NSStringCvsTo"([[OPAQUE:.*]]*, i8*, [[OPAQUE:.*]]*) unnamed_addr {{.*}} {
-  var nsstrRealProp : NSString
+  @objc var nsstrRealProp : NSString
 
   // CHECK: define hidden swiftcc %TSo8NSStringC* @"$S11objc_bridge3BasC13nsstrFakePropSo8NSStringCvg"(%T11objc_bridge3BasC* swiftself) {{.*}} {
   // CHECK: define internal void @"$S11objc_bridge3BasC13nsstrFakePropSo8NSStringCvsTo"([[OPAQUE:.*]]*, i8*, [[OPAQUE:.*]]*) unnamed_addr {{.*}} {
-  var nsstrFakeProp : NSString {
+  @objc var nsstrFakeProp : NSString {
     get {
       return NSS
     }
@@ -174,14 +174,14 @@
   }
 
   // CHECK: define internal [[OPAQUE:.*]]* @"$S11objc_bridge3BasC9strResultSSyFTo"([[OPAQUE:.*]]*, i8*) unnamed_addr {{.*}} {
-  func strResult() -> String { return "" }
+  @objc func strResult() -> String { return "" }
   // CHECK: define internal void @"$S11objc_bridge3BasC6strArg1sySS_tFTo"([[OPAQUE:.*]]*, i8*, [[OPAQUE:.*]]*) unnamed_addr {{.*}} {
-  func strArg(s s: String) { }
+  @objc func strArg(s s: String) { }
 
   // CHECK: define internal [[OPAQUE:.*]]* @"$S11objc_bridge3BasC11nsstrResultSo8NSStringCyFTo"([[OPAQUE:.*]]*, i8*) unnamed_addr {{.*}} {
-  func nsstrResult() -> NSString { return NSS }
+  @objc func nsstrResult() -> NSString { return NSS }
   // CHECK: define internal void @"$S11objc_bridge3BasC8nsstrArg1sySo8NSStringC_tFTo"([[OPAQUE:.*]]*, i8*, [[OPAQUE:.*]]*) unnamed_addr {{.*}} {
-  func nsstrArg(s s: NSString) { }
+  @objc func nsstrArg(s s: NSString) { }
 
   override init() { 
     strRealProp = String()
@@ -193,11 +193,11 @@
 
   override var hashValue: Int { return 0 }
 
-  func acceptSet(_ set: Set<Bas>) { }
+  @objc func acceptSet(_ set: Set<Bas>) { }
 }
 
 func ==(lhs: Bas, rhs: Bas) -> Bool { return true }
 
 class OptionalBlockProperty: NSObject {
-  var x: (([AnyObject]) -> [AnyObject])?
+  @objc var x: (([AnyObject]) -> [AnyObject])?
 }
diff --git a/test/IRGen/objc_bridged_generic_conformance.swift b/test/IRGen/objc_bridged_generic_conformance.swift
index f5f1af1..1380e8f 100644
--- a/test/IRGen/objc_bridged_generic_conformance.swift
+++ b/test/IRGen/objc_bridged_generic_conformance.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-ir -primary-file %s -enable-objc-interop -import-objc-header %S/Inputs/objc_bridged_generic_conformance.h -swift-version 3 | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-ir -primary-file %s -enable-objc-interop -import-objc-header %S/Inputs/objc_bridged_generic_conformance.h | %FileCheck %s
 
 // CHECK-NOT: _TMnCSo
 
@@ -9,5 +9,5 @@
 protocol P { func test() }
 
 extension Thingy: P {
-  func test() {}
+  @objc func test() {}
 }
diff --git a/test/IRGen/objc_class_export.swift b/test/IRGen/objc_class_export.swift
index 3994c61..82383b8 100644
--- a/test/IRGen/objc_class_export.swift
+++ b/test/IRGen/objc_class_export.swift
@@ -1,6 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %build-irgen-test-overlays
-// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -sdk %S/Inputs -I %t -primary-file %s -emit-ir -disable-objc-attr-requires-foundation-module -swift-version 3 | %FileCheck %s
+// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -sdk %S/Inputs -I %t -primary-file %s -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck %s
 
 // REQUIRES: CPU=x86_64
 // REQUIRES: objc_interop
@@ -112,6 +112,6 @@
   // This function is not representable in Objective-C, so don't emit the objc entry point.
   // CHECK-NOT: @_TToFC17objc_class_export3Foo23doStuffToBigSwiftStruct1ffS_FTV17objc_class_export27BigStructWithNativeObjects_T_
 
-  init() { }
+  @objc init() { }
 }
 
diff --git a/test/IRGen/objc_class_property.swift b/test/IRGen/objc_class_property.swift
index ac834c3..21d930b 100644
--- a/test/IRGen/objc_class_property.swift
+++ b/test/IRGen/objc_class_property.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir -enable-objc-interop -disable-objc-attr-requires-foundation-module -swift-version 3 | %FileCheck %s
+// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir -enable-objc-interop -disable-objc-attr-requires-foundation-module | %FileCheck %s
 
 // REQUIRES: CPU=x86_64
 
@@ -14,9 +14,11 @@
 // CHECK-NOT: @_PROPERTIES__TtC19objc_class_property7Smashed
 
 @objc class Smashed {
-  class var sharedSmashed: Smashed {
+  @objc class var sharedSmashed: Smashed {
     return Smashed()
   }
+
+  @objc init() {}
 }
 
 let s = Smashed.sharedSmashed
diff --git a/test/IRGen/objc_extensions.swift b/test/IRGen/objc_extensions.swift
index 0a5156b..59d4fe6 100644
--- a/test/IRGen/objc_extensions.swift
+++ b/test/IRGen/objc_extensions.swift
@@ -1,7 +1,7 @@
 // RUN: %empty-directory(%t)
 // RUN: %build-irgen-test-overlays
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -disable-objc-attr-requires-foundation-module -emit-module %S/Inputs/objc_extension_base.swift -o %t -swift-version 3
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -primary-file %s -emit-ir -swift-version 3 | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -disable-objc-attr-requires-foundation-module -emit-module %S/Inputs/objc_extension_base.swift -o %t
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -primary-file %s -emit-ir | %FileCheck %s
 
 // REQUIRES: CPU=x86_64
 // REQUIRES: objc_interop
@@ -34,14 +34,14 @@
 }
 
 extension NSObject {
-  func someMethod() -> String { return "Hello" }
+  @objc func someMethod() -> String { return "Hello" }
 }
 
 extension Gizmo: NewProtocol {
-  func brandNewInstanceMethod() {
+  @objc func brandNewInstanceMethod() {
   }
 
-  class func brandNewClassMethod() {
+  @objc class func brandNewClassMethod() {
   }
 
   // Overrides an instance method of NSObject
@@ -50,8 +50,7 @@
   }
 
   // Overrides a class method of NSObject
-  open override class func initialize() {
-  }
+  @objc override class func hasOverride() {}
 }
 
 /*
@@ -71,10 +70,10 @@
 // CHECK: }, section "__DATA, __objc_const", align 8
 
 extension Gizmo {
-  func brandSpankingNewInstanceMethod() {
+  @objc func brandSpankingNewInstanceMethod() {
   }
 
-  class func brandSpankingNewClassMethod() {
+  @objc class func brandSpankingNewClassMethod() {
   }
 }
 
@@ -115,8 +114,8 @@
 // CHECK: }, section "__DATA, __objc_const", align 8
 
 extension Hoozit {
-  func blibble() { }
-  class func blobble() { }
+  @objc func blibble() { }
+  @objc class func blobble() { }
 }
 
 class SwiftOnly { }
@@ -146,9 +145,11 @@
 extension NSObject {
   private enum SomeEnum { case X }
 
-  public func needMetadataOfSomeEnum() {
+  @objc public func needMetadataOfSomeEnum() {
     print(NSObject.SomeEnum.X)
   }
+
+  @objc class func hasOverride() {}
 }
 
 
diff --git a/test/IRGen/objc_implicit_with.sil b/test/IRGen/objc_implicit_with.sil
index db5bc7a..d725aac 100644
--- a/test/IRGen/objc_implicit_with.sil
+++ b/test/IRGen/objc_implicit_with.sil
@@ -1,6 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %build-irgen-test-overlays
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir -swift-version 3 | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir | %FileCheck %s
 
 // REQUIRES: CPU=x86_64
 // REQUIRES: objc_interop
@@ -16,9 +16,9 @@
 import gizmo
 
 class SwiftGizmo : Gizmo {
-  init(red: Float, green: Float, blue: Float) { }
-  func color(red: Float, green: Float, blue: Float)
-  func otherColorFor(red: Float, green: Float, blue: Float)
+  @objc init(red: Float, green: Float, blue: Float) { }
+  @objc func color(red: Float, green: Float, blue: Float)
+  @objc func otherColorFor(red: Float, green: Float, blue: Float)
 }
 sil_vtable SwiftGizmo {}
 
diff --git a/test/IRGen/objc_ns_enum.swift b/test/IRGen/objc_ns_enum.swift
index 0deb9ce..786a45f 100644
--- a/test/IRGen/objc_ns_enum.swift
+++ b/test/IRGen/objc_ns_enum.swift
@@ -1,6 +1,6 @@
 // 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 -swift-version 3 | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -primary-file %s -emit-ir | %FileCheck %s
 
 // REQUIRES: CPU=x86_64
 // REQUIRES: objc_interop
@@ -122,13 +122,13 @@
 
 @objc class ObjCEnumMethods : NSObject {
   // CHECK: define internal void @"$S12objc_ns_enum15ObjCEnumMethodsC0C2InyyAA010ExportedToD1COFTo"([[OBJC_ENUM_METHODS:.*]]*, i8*, i64)
-  dynamic func enumIn(_ x: ExportedToObjC) {}
+  @objc dynamic func enumIn(_ x: ExportedToObjC) {}
   // CHECK: define internal i64 @"$S12objc_ns_enum15ObjCEnumMethodsC0C3OutAA010ExportedToD1COyFTo"([[OBJC_ENUM_METHODS]]*, i8*)
-  dynamic func enumOut() -> ExportedToObjC { return .Foo }
+  @objc dynamic func enumOut() -> ExportedToObjC { return .Foo }
 
   // CHECK: define internal i64 @"$S12objc_ns_enum15ObjCEnumMethodsC4propAA010ExportedToD1COvgTo"([[OBJC_ENUM_METHODS]]*, i8*)
   // CHECK: define internal void @"$S12objc_ns_enum15ObjCEnumMethodsC4propAA010ExportedToD1COvsTo"([[OBJC_ENUM_METHODS]]*, i8*, i64)
-  dynamic var prop: ExportedToObjC = .Foo
+  @objc dynamic var prop: ExportedToObjC = .Foo
 }
 
 // CHECK-LABEL: define hidden swiftcc void @"$S12objc_ns_enum0a1_C13_method_callsyyAA15ObjCEnumMethodsCF"(%T12objc_ns_enum15ObjCEnumMethodsC*)
diff --git a/test/IRGen/objc_properties.swift b/test/IRGen/objc_properties.swift
index f69a15b..75e3c60 100644
--- a/test/IRGen/objc_properties.swift
+++ b/test/IRGen/objc_properties.swift
@@ -1,19 +1,19 @@
 // This file is also used by objc_properties_ios.swift.
 
-// RUN: %swift -target x86_64-apple-macosx10.11 %s -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module -swift-version 3 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-NEW %s
-// RUN: %swift -target x86_64-apple-macosx10.10 %s -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module -swift-version 3 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-OLD %s
+// RUN: %swift -target x86_64-apple-macosx10.11 %s -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-NEW %s
+// RUN: %swift -target x86_64-apple-macosx10.10 %s -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-OLD %s
 
 // REQUIRES: OS=macosx
 // REQUIRES: objc_interop
 
 @objc class SomeObject {
-  var readonly : SomeObject {
+  @objc var readonly : SomeObject {
     get {
       return self
     }
   }
 
-  var readwrite : SomeObject {
+  @objc var readwrite : SomeObject {
     get {
       return bareIvar
     }
@@ -22,20 +22,20 @@
     }
   }
 
-  var bareIvar : SomeObject
+  @objc var bareIvar : SomeObject
 
   @objc(wobble) var wibble : SomeObject
 
-  init() { 
+  @objc init() { 
     bareIvar = SomeObject()
     wibble  = SomeObject()
   }
 
-  static var sharedProp: Int64 = 0
+  @objc static var sharedProp: Int64 = 0
 }
 
 extension SomeObject {
-  var extensionProperty : SomeObject {
+  @objc var extensionProperty : SomeObject {
     get {
       return self
     }
@@ -44,7 +44,7 @@
     }
   }
 
-  class var extensionClassProp : SomeObject.Type {
+  @objc class var extensionClassProp : SomeObject.Type {
     return self
   }
 }
@@ -52,12 +52,12 @@
 // <rdar://problem/16952186> Crash with @lazy in @objc class
 @objc
 class LazyPropertyCrash  {
-  lazy var applicationFilesDirectory: LazyPropertyCrash = LazyPropertyCrash()
+  @objc lazy var applicationFilesDirectory: LazyPropertyCrash = LazyPropertyCrash()
 }
 
 // <rdar://16909436>
 @objc class Tree {
-  weak var parent: Tree?
+  @objc weak var parent: Tree?
 }
 
 
@@ -68,7 +68,7 @@
 
 @objc
 class Class17127126 {
-  lazy var x = 1
+  @objc lazy var x = 1
 }
 
 @objc protocol Proto {
diff --git a/test/IRGen/objc_properties_ios.swift b/test/IRGen/objc_properties_ios.swift
index 2c1674a..33fa41e 100644
--- a/test/IRGen/objc_properties_ios.swift
+++ b/test/IRGen/objc_properties_ios.swift
@@ -1,5 +1,5 @@
-// RUN: %swift -target x86_64-apple-ios9 %S/objc_properties.swift -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module -swift-version 3 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-NEW %S/objc_properties.swift
-// RUN: %swift -target x86_64-apple-ios8 %S/objc_properties.swift -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module -swift-version 3 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-OLD %S/objc_properties.swift
+// RUN: %swift -target x86_64-apple-ios9 %S/objc_properties.swift -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-NEW %S/objc_properties.swift
+// RUN: %swift -target x86_64-apple-ios8 %S/objc_properties.swift -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-OLD %S/objc_properties.swift
 
 // REQUIRES: OS=ios
 // REQUIRES: CPU=x86_64
diff --git a/test/IRGen/objc_properties_jit.swift b/test/IRGen/objc_properties_jit.swift
index 209285d..128ae39 100644
--- a/test/IRGen/objc_properties_jit.swift
+++ b/test/IRGen/objc_properties_jit.swift
@@ -1,13 +1,13 @@
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop %s -emit-ir -disable-objc-attr-requires-foundation-module -use-jit -swift-version 3 | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop %s -emit-ir -disable-objc-attr-requires-foundation-module -use-jit | %FileCheck %s
 
 import Foundation
 
 extension NSString {
-  class var classProp: Int {
+  @objc class var classProp: Int {
     get { fatalError() }
     set { fatalError() }
   }
-  var instanceProp: Int {
+  @objc var instanceProp: Int {
     get { fatalError() }
     set { fatalError() }
   }
diff --git a/test/IRGen/objc_property_attrs.swift b/test/IRGen/objc_property_attrs.swift
index bc0f336..c39824b 100644
--- a/test/IRGen/objc_property_attrs.swift
+++ b/test/IRGen/objc_property_attrs.swift
@@ -1,6 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %build-irgen-test-overlays
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir -swift-version 3 | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir | %FileCheck %s
 
 // REQUIRES: CPU=x86_64
 // REQUIRES: objc_interop
@@ -15,16 +15,16 @@
 
   // nonatomic, readonly, ivar b
   // CHECK: private unnamed_addr constant {{.*}} c"Tq,N,R,Va\00"
-  let a: Int = 0
+  @objc let a: Int = 0
   // nonatomic, ivar b
   // CHECK: private unnamed_addr constant {{.*}} c"Tq,N,Vb\00"
-  var b: Int = 0
+  @objc var b: Int = 0
   // nonatomic, readonly
   // CHECK: private unnamed_addr constant {{.*}} c"Tq,N,R\00"
-  var c: Int { return 0 }
+  @objc var c: Int { return 0 }
   // nonatomic, assign
   // CHECK: private unnamed_addr constant {{.*}} c"Tq,N\00"
-  var d: Int { get { return 0 } set {} }
+  @objc var d: Int { get { return 0 } set {} }
   // nonatomic, dynamic
   // CHECK: private unnamed_addr constant {{.*}} c"Tq,N,D\00"
   @NSManaged var e: Int
@@ -34,32 +34,32 @@
 
   // nonatomic, retain, ivar f
   // CHECK: private unnamed_addr constant {{.*}} c"T@\22NSData\22,N,&,Vf\00"
-  var f: NSData = NSData()
+  @objc var f: NSData = NSData()
   // nonatomic, weak, assign, ivar g
   // CHECK: private unnamed_addr constant {{.*}} c"T@\22NSData\22,N,W,Vg\00"
-  weak var g: NSData? = nil
+  @objc weak var g: NSData? = nil
   // nonatomic, copy, ivar h
   // CHECK: private unnamed_addr constant {{.*}} c"T@\22NSData\22,N,C,Vh\00"
-  @NSCopying var h: NSData! = nil
+  @objc @NSCopying var h: NSData! = nil
   // nonatomic, dynamic, assign
   // CHECK: private unnamed_addr constant {{.*}} c"T@\22NSData\22,N,D,&\00"
   @NSManaged var i: NSData
   // nonatomic, readonly
   // CHECK: private unnamed_addr constant {{.*}} c"T@\22NSData\22,N,R\00"
-  var j: NSData { return NSData() }
+  @objc var j: NSData { return NSData() }
 
   // -- Bridged value types
 
   // nonatomic, copy, ivar k
   // CHECK: private unnamed_addr constant {{.*}} c"T@\22NSString\22,N,C,Vk\00"
-  var k: String = ""
+  @objc var k: String = ""
   // nonatomic, readonly, ivar l
   // CHECK: private unnamed_addr constant {{.*}} c"T@\22NSString\22,N,R,Vl\00"
-  let l: String? = nil
+  @objc let l: String? = nil
 
   // -- Protocol types:
   // CHECK: private unnamed_addr constant {{.*}} c"T@\22<_TtP19objc_property_attrs1P_>\22,N,&,Vp\00"
-  var p: P?
+  @objc var p: P?
   // CHECK: private unnamed_addr constant {{.*}} c"T@\22<_TtP19objc_property_attrs1P_><_TtP19objc_property_attrs1Q_>\22,N,&,Vpq\00"
-  var pq: (P & Q)?
+  @objc var pq: (P & Q)?
 }
diff --git a/test/IRGen/objc_subclass.swift b/test/IRGen/objc_subclass.swift
index cce478f..fbc8863 100644
--- a/test/IRGen/objc_subclass.swift
+++ b/test/IRGen/objc_subclass.swift
@@ -1,6 +1,6 @@
 // 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 -swift-version 3 | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize %s
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -primary-file %s -emit-ir | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize %s
 
 // REQUIRES: objc_interop
 
@@ -280,9 +280,9 @@
 
 @requires_stored_property_inits
 class SwiftGizmo : Gizmo {
-  var x = Int()
+  @objc var x = Int()
 
-  func getX() -> Int {
+  @objc func getX() -> Int {
     return x
   }
 
@@ -294,13 +294,13 @@
     super.init(bellsOn:0)
   }
 
-  init(int i: Int, string str : String) {
+  @objc init(int i: Int, string str : String) {
     super.init(bellsOn:i)
   }
 
   deinit { var x = 10 }
 
-  var enabled: Bool {
+  @objc var enabled: Bool {
     @objc(isEnabled) get {
       return true
     }
@@ -311,9 +311,9 @@
 }
 
 class GenericGizmo<T> : Gizmo {
-  func foo() {}
+  @objc func foo() {}
 
-  var x : Int {
+  @objc var x : Int {
     return 0
   }
 
@@ -326,7 +326,7 @@
 
 @_objc_non_lazy_realization
 class SwiftGizmo2 : Gizmo {
-  var sg : SwiftGizmo
+  @objc var sg : SwiftGizmo
 
   override init() {
     sg = SwiftGizmo()
diff --git a/test/IRGen/objc_subscripts.swift b/test/IRGen/objc_subscripts.swift
index e3da02e..6b86901 100644
--- a/test/IRGen/objc_subscripts.swift
+++ b/test/IRGen/objc_subscripts.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -emit-ir -enable-objc-interop -disable-objc-attr-requires-foundation-module -swift-version 3 | %FileCheck %s
+// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -emit-ir -enable-objc-interop -disable-objc-attr-requires-foundation-module | %FileCheck %s
 
 // REQUIRES: CPU=x86_64
 
@@ -36,7 +36,7 @@
 // CHECK:  }
 
 @objc class SomeObject {
-  subscript (i : Int) -> SomeObject {
+  @objc subscript (i : Int) -> SomeObject {
     // CHECK: define internal [[OPAQUE0:%.*]]* @"$S15objc_subscripts10SomeObjectCyACSicigTo"([[OPAQUE1]]*, i8*, i64) unnamed_addr
     get {
       // CHECK: call swiftcc %T15objc_subscripts10SomeObjectC* @"$S15objc_subscripts10SomeObjectCyACSicig"
@@ -49,7 +49,7 @@
     }
   }
 
-  subscript (s : SomeObject) -> Int {
+  @objc subscript (s : SomeObject) -> Int {
   // CHECK-LABEL: define internal i64 @"$S15objc_subscripts10SomeObjectCySiACcigTo"
     get {
       // CHECK: call swiftcc i64 @"$S15objc_subscripts10SomeObjectCySiACcig"
@@ -61,5 +61,7 @@
       // CHECK: call swiftcc void @"$S15objc_subscripts10SomeObjectCySiACcis"
     }
   }
+
+  @objc init() {}
 }
 
diff --git a/test/IRGen/partial_apply_generic.swift b/test/IRGen/partial_apply_generic.swift
index 19bf654..d868cc0 100644
--- a/test/IRGen/partial_apply_generic.swift
+++ b/test/IRGen/partial_apply_generic.swift
@@ -1,11 +1,11 @@
-// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir -swift-version 3 | %FileCheck %s
+// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir | %FileCheck %s
 
 // REQUIRES: CPU=x86_64
 
 //
 // Type parameters
 //
-infix operator ~> { precedence 255 }
+infix operator ~>
 
 func ~> <Target, Args, Result> (
   target: Target,
diff --git a/test/IRGen/partial_apply_objc.sil b/test/IRGen/partial_apply_objc.sil
index 46c314f..b49a12b 100644
--- a/test/IRGen/partial_apply_objc.sil
+++ b/test/IRGen/partial_apply_objc.sil
@@ -1,6 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %build-irgen-test-overlays
-// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir -assume-parsing-unqualified-ownership-sil -disable-objc-attr-requires-foundation-module -swift-version 3 | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
+// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir -assume-parsing-unqualified-ownership-sil -disable-objc-attr-requires-foundation-module | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
 
 // REQUIRES: CPU=x86_64
 // REQUIRES: objc_interop
@@ -11,8 +11,8 @@
 import gizmo
 
 @objc class ObjCClass : BaseClassForMethodFamilies {
-  func method(x: Int) {}
-  func method2(r: NSRect) {}
+  @objc func method(x: Int) {}
+  @objc func method2(r: NSRect) {}
 
   override func fakeInitFamily() -> ObjCClass { return self }
 }
diff --git a/test/IRGen/sil_witness_tables_inherited_conformance.swift b/test/IRGen/sil_witness_tables_inherited_conformance.swift
index 700c4c2..90e2fda 100644
--- a/test/IRGen/sil_witness_tables_inherited_conformance.swift
+++ b/test/IRGen/sil_witness_tables_inherited_conformance.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir -swift-version 3 | %FileCheck %s
+// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir | %FileCheck %s
 
 // rdar://problem/20628295
 
@@ -40,5 +40,5 @@
 }
 
 feed(Cat())
-wangle(Cat)
+wangle(Cat.self)
 Anesthesiologist<Cat>().disentangle(Cat())
diff --git a/test/SILGen/mangling_swift3.swift b/test/SILGen/mangling_swift3.swift
new file mode 100644
index 0000000..9be4470
--- /dev/null
+++ b/test/SILGen/mangling_swift3.swift
@@ -0,0 +1,8 @@
+
+// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-silgen -enable-sil-ownership -swift-version 3 -verify | %FileCheck %s
+
+protocol Foo {}
+
+// Don't crash mangling single-protocol "composition" types.
+// CHECK-LABEL: sil hidden @$S15mangling_swift327single_protocol_composition1xyAA3Foo_p_tF
+func single_protocol_composition(x: protocol<Foo>) {} // expected-warning {{'protocol<...>' composition syntax is deprecated and not needed here}}
diff --git a/test/decl/ext/generic.swift b/test/decl/ext/generic.swift
index 130b65f..71af8d4 100644
--- a/test/decl/ext/generic.swift
+++ b/test/decl/ext/generic.swift
@@ -142,7 +142,6 @@
 
 extension GenericClass where Self : P3 { }
 // expected-error@-1{{'Self' is only available in a protocol or as the result of a method in a class; did you mean 'GenericClass'?}} {{30-34=GenericClass}}
-// expected-error@-2{{type 'GenericClass<T>' in conformance requirement does not refer to a generic parameter or associated type}}
 
 protocol P4 {
   associatedtype T
diff --git a/validation-test/compiler_crashers_2_fixed/0164-sr7989.swift b/validation-test/compiler_crashers_2_fixed/0164-sr7989.swift
index a814e45..a15fd1e 100644
--- a/validation-test/compiler_crashers_2_fixed/0164-sr7989.swift
+++ b/validation-test/compiler_crashers_2_fixed/0164-sr7989.swift
@@ -9,4 +9,3 @@
 
 protocol P3 {}
 extension Var : P3 where Self : P2 {} // expected-error {{'Self' is only available in a protocol or as the result of a method in a class; did you mean 'Var'?}}
-// expected-error@-1 {{type 'Var<N>' in conformance requirement does not refer to a generic parameter or associated type}}