Merge pull request #12146 from gottesmm/add_support_for_initFunction

diff --git a/benchmark/scripts/Benchmark_Driver b/benchmark/scripts/Benchmark_Driver
index 648c936..bd817f0f 100755
--- a/benchmark/scripts/Benchmark_Driver
+++ b/benchmark/scripts/Benchmark_Driver
@@ -118,12 +118,20 @@
     return avg_test_output
 
 
+BENCHMARK_OUTPUT_RE = re.compile('([^,]+),')
+
+
 def get_tests(driver_path, args):
     """Return a list of available performance tests"""
     driver = ([driver_path, '--list'])
     if args.benchmarks or args.filters:
         driver.append('--run-all')
-    tests = subprocess.check_output(driver).split()[2:]
+    tests = []
+    for l in subprocess.check_output(driver).split("\n")[1:]:
+        m = BENCHMARK_OUTPUT_RE.match(l)
+        if m is None:
+            continue
+        tests.append(m.group(1))
     if args.filters:
         regexes = [re.compile(pattern) for pattern in args.filters]
         return sorted(list(set([name for pattern in regexes
diff --git a/benchmark/utils/DriverUtils.swift b/benchmark/utils/DriverUtils.swift
index f071e67..f464c6a 100644
--- a/benchmark/utils/DriverUtils.swift
+++ b/benchmark/utils/DriverUtils.swift
@@ -183,10 +183,19 @@
 
     if let x = benchArgs.optionalArgsMap["--tags"] {
       if x.isEmpty { return .fail("--tags requires a value") }
-      guard let cat = BenchmarkCategory(rawValue: x) else {
-        return .fail("Unknown benchmark category: '\(x)'")
+
+      // We support specifying multiple tags by splitting on comma, i.e.:
+      //
+      //  --tags=array,set
+      //
+      // FIXME: If we used Error instead of .fail, then we could have a cleaner
+      // impl here using map on x and tags.formUnion.
+      for t in x.split(separator: ",") {
+        guard let cat = BenchmarkCategory(rawValue: String(t)) else {
+          return .fail("Unknown benchmark category: '\(t)'")
+        }
+        tags.insert(cat)
       }
-      tags.insert(cat)
     }
 
     if let _ = benchArgs.optionalArgsMap["--run-all"] {
diff --git a/benchmark/utils/main.swift b/benchmark/utils/main.swift
index f735558..6bab9bd 100644
--- a/benchmark/utils/main.swift
+++ b/benchmark/utils/main.swift
@@ -246,52 +246,52 @@
 addTo(&precommitTests, "DictionaryRemoveOfObjects", run_DictionaryRemoveOfObjects, [.validation, .api, .Dictionary])
 addTo(&precommitTests, "DictionarySwap", run_DictionarySwap, [.validation, .api, .Dictionary])
 addTo(&precommitTests, "DictionarySwapOfObjects", run_DictionarySwapOfObjects, [.validation, .api, .Dictionary])
-addTo(&precommitTests, "DropFirstAnyCollection", run_DropFirstAnyCollection, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropFirstAnyCollectionLazy", run_DropFirstAnyCollectionLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropFirstAnySeqCRangeIter", run_DropFirstAnySeqCRangeIter, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropFirstAnySeqCRangeIterLazy", run_DropFirstAnySeqCRangeIterLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropFirstAnySeqCntRange", run_DropFirstAnySeqCntRange, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropFirstAnySeqCntRangeLazy", run_DropFirstAnySeqCntRangeLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropFirstAnySequence", run_DropFirstAnySequence, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropFirstAnySequenceLazy", run_DropFirstAnySequenceLazy, [.validation, .api, .abstraction])
+addTo(&precommitTests, "DropFirstAnyCollection", run_DropFirstAnyCollection, [.validation, .api])
+addTo(&precommitTests, "DropFirstAnyCollectionLazy", run_DropFirstAnyCollectionLazy, [.validation, .api])
+addTo(&precommitTests, "DropFirstAnySeqCRangeIter", run_DropFirstAnySeqCRangeIter, [.validation, .api])
+addTo(&precommitTests, "DropFirstAnySeqCRangeIterLazy", run_DropFirstAnySeqCRangeIterLazy, [.validation, .api])
+addTo(&precommitTests, "DropFirstAnySeqCntRange", run_DropFirstAnySeqCntRange, [.validation, .api])
+addTo(&precommitTests, "DropFirstAnySeqCntRangeLazy", run_DropFirstAnySeqCntRangeLazy, [.validation, .api])
+addTo(&precommitTests, "DropFirstAnySequence", run_DropFirstAnySequence, [.validation, .api])
+addTo(&precommitTests, "DropFirstAnySequenceLazy", run_DropFirstAnySequenceLazy, [.validation, .api])
 addTo(&precommitTests, "DropFirstArray", run_DropFirstArray, [.validation, .api, .Array])
 addTo(&precommitTests, "DropFirstArrayLazy", run_DropFirstArrayLazy, [.validation, .api, .Array])
-addTo(&precommitTests, "DropFirstCountableRange", run_DropFirstCountableRange, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropFirstCountableRangeLazy", run_DropFirstCountableRangeLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropFirstSequence", run_DropFirstSequence, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropFirstSequenceLazy", run_DropFirstSequenceLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropLastAnyCollection", run_DropLastAnyCollection, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropLastAnyCollectionLazy", run_DropLastAnyCollectionLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropLastAnySeqCRangeIter", run_DropLastAnySeqCRangeIter, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropLastAnySeqCRangeIterLazy", run_DropLastAnySeqCRangeIterLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropLastAnySeqCntRange", run_DropLastAnySeqCntRange, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropLastAnySeqCntRangeLazy", run_DropLastAnySeqCntRangeLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropLastAnySequence", run_DropLastAnySequence, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropLastAnySequenceLazy", run_DropLastAnySequenceLazy, [.validation, .api, .abstraction])
+addTo(&precommitTests, "DropFirstCountableRange", run_DropFirstCountableRange, [.validation, .api])
+addTo(&precommitTests, "DropFirstCountableRangeLazy", run_DropFirstCountableRangeLazy, [.validation, .api])
+addTo(&precommitTests, "DropFirstSequence", run_DropFirstSequence, [.validation, .api])
+addTo(&precommitTests, "DropFirstSequenceLazy", run_DropFirstSequenceLazy, [.validation, .api])
+addTo(&precommitTests, "DropLastAnyCollection", run_DropLastAnyCollection, [.validation, .api])
+addTo(&precommitTests, "DropLastAnyCollectionLazy", run_DropLastAnyCollectionLazy, [.validation, .api])
+addTo(&precommitTests, "DropLastAnySeqCRangeIter", run_DropLastAnySeqCRangeIter, [.validation, .api])
+addTo(&precommitTests, "DropLastAnySeqCRangeIterLazy", run_DropLastAnySeqCRangeIterLazy, [.validation, .api])
+addTo(&precommitTests, "DropLastAnySeqCntRange", run_DropLastAnySeqCntRange, [.validation, .api])
+addTo(&precommitTests, "DropLastAnySeqCntRangeLazy", run_DropLastAnySeqCntRangeLazy, [.validation, .api])
+addTo(&precommitTests, "DropLastAnySequence", run_DropLastAnySequence, [.validation, .api])
+addTo(&precommitTests, "DropLastAnySequenceLazy", run_DropLastAnySequenceLazy, [.validation, .api])
 addTo(&precommitTests, "DropLastArray", run_DropLastArray, [.validation, .api, .Array])
 addTo(&precommitTests, "DropLastArrayLazy", run_DropLastArrayLazy, [.validation, .api, .Array])
-addTo(&precommitTests, "DropLastCountableRange", run_DropLastCountableRange, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropLastCountableRangeLazy", run_DropLastCountableRangeLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropLastSequence", run_DropLastSequence, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropLastSequenceLazy", run_DropLastSequenceLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropWhileAnyCollection", run_DropWhileAnyCollection, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropWhileAnyCollectionLazy", run_DropWhileAnyCollectionLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropWhileAnySeqCRangeIter", run_DropWhileAnySeqCRangeIter, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropWhileAnySeqCRangeIterLazy", run_DropWhileAnySeqCRangeIterLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropWhileAnySeqCntRange", run_DropWhileAnySeqCntRange, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropWhileAnySeqCntRangeLazy", run_DropWhileAnySeqCntRangeLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropWhileAnySequence", run_DropWhileAnySequence, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropWhileAnySequenceLazy", run_DropWhileAnySequenceLazy, [.validation, .api, .abstraction])
+addTo(&precommitTests, "DropLastCountableRange", run_DropLastCountableRange, [.validation, .api])
+addTo(&precommitTests, "DropLastCountableRangeLazy", run_DropLastCountableRangeLazy, [.validation, .api])
+addTo(&precommitTests, "DropLastSequence", run_DropLastSequence, [.validation, .api])
+addTo(&precommitTests, "DropLastSequenceLazy", run_DropLastSequenceLazy, [.validation, .api])
+addTo(&precommitTests, "DropWhileAnyCollection", run_DropWhileAnyCollection, [.validation, .api])
+addTo(&precommitTests, "DropWhileAnyCollectionLazy", run_DropWhileAnyCollectionLazy, [.validation, .api])
+addTo(&precommitTests, "DropWhileAnySeqCRangeIter", run_DropWhileAnySeqCRangeIter, [.validation, .api])
+addTo(&precommitTests, "DropWhileAnySeqCRangeIterLazy", run_DropWhileAnySeqCRangeIterLazy, [.validation, .api])
+addTo(&precommitTests, "DropWhileAnySeqCntRange", run_DropWhileAnySeqCntRange, [.validation, .api])
+addTo(&precommitTests, "DropWhileAnySeqCntRangeLazy", run_DropWhileAnySeqCntRangeLazy, [.validation, .api])
+addTo(&precommitTests, "DropWhileAnySequence", run_DropWhileAnySequence, [.validation, .api])
+addTo(&precommitTests, "DropWhileAnySequenceLazy", run_DropWhileAnySequenceLazy, [.validation, .api])
 addTo(&precommitTests, "DropWhileArray", run_DropWhileArray, [.validation, .api, .Array])
 addTo(&precommitTests, "DropWhileArrayLazy", run_DropWhileArrayLazy, [.validation, .api, .Array])
-addTo(&precommitTests, "DropWhileCountableRange", run_DropWhileCountableRange, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropWhileCountableRangeLazy", run_DropWhileCountableRangeLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropWhileSequence", run_DropWhileSequence, [.validation, .api, .abstraction])
-addTo(&precommitTests, "DropWhileSequenceLazy", run_DropWhileSequenceLazy, [.validation, .api, .abstraction])
+addTo(&precommitTests, "DropWhileCountableRange", run_DropWhileCountableRange, [.validation, .api])
+addTo(&precommitTests, "DropWhileCountableRangeLazy", run_DropWhileCountableRangeLazy, [.validation, .api])
+addTo(&precommitTests, "DropWhileSequence", run_DropWhileSequence, [.validation, .api])
+addTo(&precommitTests, "DropWhileSequenceLazy", run_DropWhileSequenceLazy, [.validation, .api])
 addTo(&precommitTests, "EqualStringSubstring", run_EqualStringSubstring, [.validation, .api, .String])
 addTo(&precommitTests, "EqualSubstringString", run_EqualSubstringString, [.validation, .api, .String])
 addTo(&precommitTests, "EqualSubstringSubstring", run_EqualSubstringSubstring, [.validation, .api, .String])
-addTo(&precommitTests, "EqualSubstringSubstringGenericEquatable", run_EqualSubstringSubstringGenericEquatable, [.validation, .api, .String, .abstraction])
+addTo(&precommitTests, "EqualSubstringSubstringGenericEquatable", run_EqualSubstringSubstringGenericEquatable, [.validation, .api, .String])
 addTo(&precommitTests, "ErrorHandling", run_ErrorHandling, [.validation, .exceptions])
 addTo(&precommitTests, "FilterEvenUsingReduce", run_FilterEvenUsingReduce, [.validation, .api])
 addTo(&precommitTests, "FilterEvenUsingReduceInto", run_FilterEvenUsingReduceInto, [.validation, .api])
@@ -306,18 +306,18 @@
 addTo(&precommitTests, "LazilyFilteredArrays", run_LazilyFilteredArrays, [.validation, .api, .Array])
 addTo(&precommitTests, "LazilyFilteredRange", run_LazilyFilteredRange, [.validation, .api, .Array])
 addTo(&precommitTests, "LessSubstringSubstring", run_LessSubstringSubstring, [.validation, .api, .String])
-addTo(&precommitTests, "LessSubstringSubstringGenericComparable", run_LessSubstringSubstringGenericComparable, [.validation, .api, .String, .abstraction])
+addTo(&precommitTests, "LessSubstringSubstringGenericComparable", run_LessSubstringSubstringGenericComparable, [.validation, .api, .String])
 addTo(&precommitTests, "LinkedList", run_LinkedList, [.validation])
 addTo(&precommitTests, "MapReduce", run_MapReduce, [.validation, .algorithm])
-addTo(&precommitTests, "MapReduceAnyCollection", run_MapReduceAnyCollection, [.validation, .algorithm, .abstraction])
-addTo(&precommitTests, "MapReduceAnyCollectionShort", run_MapReduceAnyCollectionShort, [.validation, .algorithm, .abstraction])
-addTo(&precommitTests, "MapReduceClass", run_MapReduceClass, [.validation, .algorithm, .abstraction])
-addTo(&precommitTests, "MapReduceClassShort", run_MapReduceClassShort, [.validation, .algorithm, .abstraction])
-addTo(&precommitTests, "MapReduceLazyCollection", run_MapReduceLazyCollection, [.validation, .algorithm, .abstraction])
-addTo(&precommitTests, "MapReduceLazyCollectionShort", run_MapReduceLazyCollectionShort, [.validation, .algorithm, .abstraction])
-addTo(&precommitTests, "MapReduceLazySequence", run_MapReduceLazySequence, [.validation, .algorithm, .abstraction])
-addTo(&precommitTests, "MapReduceSequence", run_MapReduceSequence, [.validation, .algorithm, .abstraction])
-addTo(&precommitTests, "MapReduceShort", run_MapReduceShort, [.validation, .algorithm, .abstraction])
+addTo(&precommitTests, "MapReduceAnyCollection", run_MapReduceAnyCollection, [.validation, .algorithm])
+addTo(&precommitTests, "MapReduceAnyCollectionShort", run_MapReduceAnyCollectionShort, [.validation, .algorithm])
+addTo(&precommitTests, "MapReduceClass", run_MapReduceClass, [.validation, .algorithm])
+addTo(&precommitTests, "MapReduceClassShort", run_MapReduceClassShort, [.validation, .algorithm])
+addTo(&precommitTests, "MapReduceLazyCollection", run_MapReduceLazyCollection, [.validation, .algorithm])
+addTo(&precommitTests, "MapReduceLazyCollectionShort", run_MapReduceLazyCollectionShort, [.validation, .algorithm])
+addTo(&precommitTests, "MapReduceLazySequence", run_MapReduceLazySequence, [.validation, .algorithm])
+addTo(&precommitTests, "MapReduceSequence", run_MapReduceSequence, [.validation, .algorithm])
+addTo(&precommitTests, "MapReduceShort", run_MapReduceShort, [.validation, .algorithm])
 addTo(&precommitTests, "MapReduceShortString", run_MapReduceShortString, [.validation, .algorithm, .String])
 addTo(&precommitTests, "MapReduceString", run_MapReduceString, [.validation, .algorithm, .String])
 addTo(&precommitTests, "Memset", run_Memset, [.validation])
@@ -332,12 +332,12 @@
 addTo(&precommitTests, "ObjectiveCBridgeFromNSArrayAnyObjectForced", run_ObjectiveCBridgeFromNSArrayAnyObjectForced, [.validation, .bridging])
 addTo(&precommitTests, "ObjectiveCBridgeFromNSArrayAnyObjectToString", run_ObjectiveCBridgeFromNSArrayAnyObjectToString, [.validation, .bridging, .String])
 addTo(&precommitTests, "ObjectiveCBridgeFromNSArrayAnyObjectToStringForced", run_ObjectiveCBridgeFromNSArrayAnyObjectToStringForced, [.validation, .bridging, .String])
-addTo(&precommitTests, "ObjectiveCBridgeFromNSDictionaryAnyObject", run_ObjectiveCBridgeFromNSDictionaryAnyObject, [.validation, .bridging, .abstraction])
-addTo(&precommitTests, "ObjectiveCBridgeFromNSDictionaryAnyObjectForced", run_ObjectiveCBridgeFromNSDictionaryAnyObjectForced, [.validation, .bridging, .abstraction])
-addTo(&precommitTests, "ObjectiveCBridgeFromNSDictionaryAnyObjectToString", run_ObjectiveCBridgeFromNSDictionaryAnyObjectToString, [.validation, .bridging, .abstraction, .String])
+addTo(&precommitTests, "ObjectiveCBridgeFromNSDictionaryAnyObject", run_ObjectiveCBridgeFromNSDictionaryAnyObject, [.validation, .bridging])
+addTo(&precommitTests, "ObjectiveCBridgeFromNSDictionaryAnyObjectForced", run_ObjectiveCBridgeFromNSDictionaryAnyObjectForced, [.validation, .bridging])
+addTo(&precommitTests, "ObjectiveCBridgeFromNSDictionaryAnyObjectToString", run_ObjectiveCBridgeFromNSDictionaryAnyObjectToString, [.validation, .bridging, .String])
 addTo(&precommitTests, "ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced", run_ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced, [.validation, .bridging, .String])
-addTo(&precommitTests, "ObjectiveCBridgeFromNSSetAnyObject", run_ObjectiveCBridgeFromNSSetAnyObject, [.validation, .bridging, .abstraction])
-addTo(&precommitTests, "ObjectiveCBridgeFromNSSetAnyObjectForced", run_ObjectiveCBridgeFromNSSetAnyObjectForced, [.validation, .bridging, .abstraction])
+addTo(&precommitTests, "ObjectiveCBridgeFromNSSetAnyObject", run_ObjectiveCBridgeFromNSSetAnyObject, [.validation, .bridging])
+addTo(&precommitTests, "ObjectiveCBridgeFromNSSetAnyObjectForced", run_ObjectiveCBridgeFromNSSetAnyObjectForced, [.validation, .bridging])
 addTo(&precommitTests, "ObjectiveCBridgeFromNSSetAnyObjectToString", run_ObjectiveCBridgeFromNSSetAnyObjectToString, [.validation, .bridging, .String])
 addTo(&precommitTests, "ObjectiveCBridgeFromNSSetAnyObjectToStringForced", run_ObjectiveCBridgeFromNSSetAnyObjectToStringForced, [.validation, .bridging, .String])
 addTo(&precommitTests, "ObjectiveCBridgeFromNSString", run_ObjectiveCBridgeFromNSString, [.validation, .bridging])
@@ -372,36 +372,36 @@
 addTo(&precommitTests, "Phonebook", run_Phonebook, [.validation, .api, .String])
 addTo(&precommitTests, "PolymorphicCalls", run_PolymorphicCalls, [.validation, .runtime, .abstraction])
 addTo(&precommitTests, "PopFrontArray", run_PopFrontArray, [.validation, .api, .Array])
-addTo(&precommitTests, "PopFrontArrayGeneric", run_PopFrontArrayGeneric, [.validation, .api, .Array, .abstraction])
+addTo(&precommitTests, "PopFrontArrayGeneric", run_PopFrontArrayGeneric, [.validation, .api, .Array])
 addTo(&precommitTests, "PopFrontUnsafePointer", run_PopFrontUnsafePointer, [.validation, .api])
-addTo(&precommitTests, "PrefixAnyCollection", run_PrefixAnyCollection, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixAnyCollectionLazy", run_PrefixAnyCollectionLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixAnySeqCRangeIter", run_PrefixAnySeqCRangeIter, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixAnySeqCRangeIterLazy", run_PrefixAnySeqCRangeIterLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixAnySeqCntRange", run_PrefixAnySeqCntRange, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixAnySeqCntRangeLazy", run_PrefixAnySeqCntRangeLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixAnySequence", run_PrefixAnySequence, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixAnySequenceLazy", run_PrefixAnySequenceLazy, [.validation, .api, .abstraction])
+addTo(&precommitTests, "PrefixAnyCollection", run_PrefixAnyCollection, [.validation, .api])
+addTo(&precommitTests, "PrefixAnyCollectionLazy", run_PrefixAnyCollectionLazy, [.validation, .api])
+addTo(&precommitTests, "PrefixAnySeqCRangeIter", run_PrefixAnySeqCRangeIter, [.validation, .api])
+addTo(&precommitTests, "PrefixAnySeqCRangeIterLazy", run_PrefixAnySeqCRangeIterLazy, [.validation, .api])
+addTo(&precommitTests, "PrefixAnySeqCntRange", run_PrefixAnySeqCntRange, [.validation, .api])
+addTo(&precommitTests, "PrefixAnySeqCntRangeLazy", run_PrefixAnySeqCntRangeLazy, [.validation, .api])
+addTo(&precommitTests, "PrefixAnySequence", run_PrefixAnySequence, [.validation, .api])
+addTo(&precommitTests, "PrefixAnySequenceLazy", run_PrefixAnySequenceLazy, [.validation, .api])
 addTo(&precommitTests, "PrefixArray", run_PrefixArray, [.validation, .api, .Array])
 addTo(&precommitTests, "PrefixArrayLazy", run_PrefixArrayLazy, [.validation, .api, .Array])
-addTo(&precommitTests, "PrefixCountableRange", run_PrefixCountableRange, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixCountableRangeLazy", run_PrefixCountableRangeLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixSequence", run_PrefixSequence, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixSequenceLazy", run_PrefixSequenceLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixWhileAnyCollection", run_PrefixWhileAnyCollection, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixWhileAnyCollectionLazy", run_PrefixWhileAnyCollectionLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixWhileAnySeqCRangeIter", run_PrefixWhileAnySeqCRangeIter, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixWhileAnySeqCRangeIterLazy", run_PrefixWhileAnySeqCRangeIterLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixWhileAnySeqCntRange", run_PrefixWhileAnySeqCntRange, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixWhileAnySeqCntRangeLazy", run_PrefixWhileAnySeqCntRangeLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixWhileAnySequence", run_PrefixWhileAnySequence, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixWhileAnySequenceLazy", run_PrefixWhileAnySequenceLazy, [.validation, .api, .abstraction])
+addTo(&precommitTests, "PrefixCountableRange", run_PrefixCountableRange, [.validation, .api])
+addTo(&precommitTests, "PrefixCountableRangeLazy", run_PrefixCountableRangeLazy, [.validation, .api])
+addTo(&precommitTests, "PrefixSequence", run_PrefixSequence, [.validation, .api])
+addTo(&precommitTests, "PrefixSequenceLazy", run_PrefixSequenceLazy, [.validation, .api])
+addTo(&precommitTests, "PrefixWhileAnyCollection", run_PrefixWhileAnyCollection, [.validation, .api])
+addTo(&precommitTests, "PrefixWhileAnyCollectionLazy", run_PrefixWhileAnyCollectionLazy, [.validation, .api])
+addTo(&precommitTests, "PrefixWhileAnySeqCRangeIter", run_PrefixWhileAnySeqCRangeIter, [.validation, .api])
+addTo(&precommitTests, "PrefixWhileAnySeqCRangeIterLazy", run_PrefixWhileAnySeqCRangeIterLazy, [.validation, .api])
+addTo(&precommitTests, "PrefixWhileAnySeqCntRange", run_PrefixWhileAnySeqCntRange, [.validation, .api])
+addTo(&precommitTests, "PrefixWhileAnySeqCntRangeLazy", run_PrefixWhileAnySeqCntRangeLazy, [.validation, .api])
+addTo(&precommitTests, "PrefixWhileAnySequence", run_PrefixWhileAnySequence, [.validation, .api])
+addTo(&precommitTests, "PrefixWhileAnySequenceLazy", run_PrefixWhileAnySequenceLazy, [.validation, .api])
 addTo(&precommitTests, "PrefixWhileArray", run_PrefixWhileArray, [.validation, .api, .Array])
 addTo(&precommitTests, "PrefixWhileArrayLazy", run_PrefixWhileArrayLazy, [.validation, .api, .Array])
-addTo(&precommitTests, "PrefixWhileCountableRange", run_PrefixWhileCountableRange, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixWhileCountableRangeLazy", run_PrefixWhileCountableRangeLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixWhileSequence", run_PrefixWhileSequence, [.validation, .api, .abstraction])
-addTo(&precommitTests, "PrefixWhileSequenceLazy", run_PrefixWhileSequenceLazy, [.validation, .api, .abstraction])
+addTo(&precommitTests, "PrefixWhileCountableRange", run_PrefixWhileCountableRange, [.validation, .api])
+addTo(&precommitTests, "PrefixWhileCountableRangeLazy", run_PrefixWhileCountableRangeLazy, [.validation, .api])
+addTo(&precommitTests, "PrefixWhileSequence", run_PrefixWhileSequence, [.validation, .api])
+addTo(&precommitTests, "PrefixWhileSequenceLazy", run_PrefixWhileSequenceLazy, [.validation, .api])
 addTo(&precommitTests, "Prims", run_Prims, [.validation, .algorithm])
 addTo(&precommitTests, "PrimsSplit", run_PrimsSplit, [.validation, .algorithm])
 addTo(&precommitTests, "ProtocolDispatch", run_ProtocolDispatch, [.validation, .abstraction])
@@ -409,10 +409,10 @@
 addTo(&precommitTests, "RC4", run_RC4, [.validation, .algorithm])
 addTo(&precommitTests, "RGBHistogram", run_RGBHistogram, [.validation, .algorithm])
 addTo(&precommitTests, "RGBHistogramOfObjects", run_RGBHistogramOfObjects, [.validation, .algorithm])
-addTo(&precommitTests, "RangeAssignment", run_RangeAssignment, [.validation, .api, .abstraction])
+addTo(&precommitTests, "RangeAssignment", run_RangeAssignment, [.validation, .api])
 addTo(&precommitTests, "RecursiveOwnedParameter", run_RecursiveOwnedParameter, [.validation, .api, .Array, .refcount])
 addTo(&precommitTests, "ReversedArray", run_ReversedArray, [.validation, .api, .Array])
-addTo(&precommitTests, "ReversedBidirectional", run_ReversedBidirectional, [.validation, .api, .abstraction])
+addTo(&precommitTests, "ReversedBidirectional", run_ReversedBidirectional, [.validation, .api])
 addTo(&precommitTests, "ReversedDictionary", run_ReversedDictionary, [.validation, .api, .Dictionary])
 addTo(&precommitTests, "SetExclusiveOr", run_SetExclusiveOr, [.validation, .api, .Set])
 addTo(&precommitTests, "SetExclusiveOr_OfObjects", run_SetExclusiveOr_OfObjects, [.validation, .api, .Set])
@@ -440,7 +440,7 @@
 addTo(&precommitTests, "StringEnumRawValueInitialization", run_StringEnumRawValueInitialization, [.validation, .api, .String])
 addTo(&precommitTests, "StringEqualPointerComparison", run_StringEqualPointerComparison, [.validation, .api, .String])
 addTo(&precommitTests, "StringFromLongWholeSubstring", run_StringFromLongWholeSubstring, [.validation, .api, .String])
-addTo(&precommitTests, "StringFromLongWholeSubstringGeneric", run_StringFromLongWholeSubstringGeneric, [.validation, .api, .String, .abstraction])
+addTo(&precommitTests, "StringFromLongWholeSubstringGeneric", run_StringFromLongWholeSubstringGeneric, [.validation, .api, .String])
 addTo(&precommitTests, "StringHasPrefix", run_StringHasPrefix, [.validation, .api, .String])
 addTo(&precommitTests, "StringHasPrefixUnicode", run_StringHasPrefixUnicode, [.validation, .api, .String])
 addTo(&precommitTests, "StringHasSuffix", run_StringHasSuffix, [.validation, .api, .String])
@@ -454,21 +454,21 @@
 addTo(&precommitTests, "SubstringEqualString", run_SubstringEqualString, [.validation, .api, .String])
 addTo(&precommitTests, "SubstringEquatable", run_SubstringEquatable, [.validation, .api, .String])
 addTo(&precommitTests, "SubstringFromLongString", run_SubstringFromLongString, [.validation, .api, .String])
-addTo(&precommitTests, "SubstringFromLongStringGeneric", run_SubstringFromLongStringGeneric, [.validation, .api, .String, .abstraction])
-addTo(&precommitTests, "SuffixAnyCollection", run_SuffixAnyCollection, [.validation, .api, .abstraction])
-addTo(&precommitTests, "SuffixAnyCollectionLazy", run_SuffixAnyCollectionLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "SuffixAnySeqCRangeIter", run_SuffixAnySeqCRangeIter, [.validation, .api, .abstraction])
-addTo(&precommitTests, "SuffixAnySeqCRangeIterLazy", run_SuffixAnySeqCRangeIterLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "SuffixAnySeqCntRange", run_SuffixAnySeqCntRange, [.validation, .api, .abstraction])
-addTo(&precommitTests, "SuffixAnySeqCntRangeLazy", run_SuffixAnySeqCntRangeLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "SuffixAnySequence", run_SuffixAnySequence, [.validation, .api, .abstraction])
-addTo(&precommitTests, "SuffixAnySequenceLazy", run_SuffixAnySequenceLazy, [.validation, .api, .abstraction])
+addTo(&precommitTests, "SubstringFromLongStringGeneric", run_SubstringFromLongStringGeneric, [.validation, .api, .String])
+addTo(&precommitTests, "SuffixAnyCollection", run_SuffixAnyCollection, [.validation, .api])
+addTo(&precommitTests, "SuffixAnyCollectionLazy", run_SuffixAnyCollectionLazy, [.validation, .api])
+addTo(&precommitTests, "SuffixAnySeqCRangeIter", run_SuffixAnySeqCRangeIter, [.validation, .api])
+addTo(&precommitTests, "SuffixAnySeqCRangeIterLazy", run_SuffixAnySeqCRangeIterLazy, [.validation, .api])
+addTo(&precommitTests, "SuffixAnySeqCntRange", run_SuffixAnySeqCntRange, [.validation, .api])
+addTo(&precommitTests, "SuffixAnySeqCntRangeLazy", run_SuffixAnySeqCntRangeLazy, [.validation, .api])
+addTo(&precommitTests, "SuffixAnySequence", run_SuffixAnySequence, [.validation, .api])
+addTo(&precommitTests, "SuffixAnySequenceLazy", run_SuffixAnySequenceLazy, [.validation, .api])
 addTo(&precommitTests, "SuffixArray", run_SuffixArray, [.validation, .api, .Array])
 addTo(&precommitTests, "SuffixArrayLazy", run_SuffixArrayLazy, [.validation, .api, .Array])
-addTo(&precommitTests, "SuffixCountableRange", run_SuffixCountableRange, [.validation, .api, .abstraction])
-addTo(&precommitTests, "SuffixCountableRangeLazy", run_SuffixCountableRangeLazy, [.validation, .api, .abstraction])
-addTo(&precommitTests, "SuffixSequence", run_SuffixSequence, [.validation, .api, .abstraction])
-addTo(&precommitTests, "SuffixSequenceLazy", run_SuffixSequenceLazy, [.validation, .api, .abstraction])
+addTo(&precommitTests, "SuffixCountableRange", run_SuffixCountableRange, [.validation, .api])
+addTo(&precommitTests, "SuffixCountableRangeLazy", run_SuffixCountableRangeLazy, [.validation, .api])
+addTo(&precommitTests, "SuffixSequence", run_SuffixSequence, [.validation, .api])
+addTo(&precommitTests, "SuffixSequenceLazy", run_SuffixSequenceLazy, [.validation, .api])
 addTo(&precommitTests, "SumUsingReduce", run_SumUsingReduce, [.validation, .api])
 addTo(&precommitTests, "SumUsingReduceInto", run_SumUsingReduceInto, [.validation, .api])
 addTo(&precommitTests, "SuperChars", run_SuperChars, [.validation, .api, .String])
diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake
index 5145017..53081bd 100644
--- a/cmake/modules/AddSwift.cmake
+++ b/cmake/modules/AddSwift.cmake
@@ -497,7 +497,7 @@
 function(swift_target_link_search_directories target directories)
   set(STLD_FLAGS "")
   foreach(directory ${directories})
-    set(STLD_FLAGS "${STLD_FLAGS} ${CMAKE_LIBRARY_PATH_FLAG}${directory}")
+    set(STLD_FLAGS "${STLD_FLAGS} \"${CMAKE_LIBRARY_PATH_FLAG}${directory}\"")
   endforeach()
   set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS ${STLD_FLAGS})
 endfunction()
diff --git a/docs/StandardLibraryProgrammersManual.md b/docs/StandardLibraryProgrammersManual.md
index e8f6a8a..675a998 100644
--- a/docs/StandardLibraryProgrammersManual.md
+++ b/docs/StandardLibraryProgrammersManual.md
@@ -27,7 +27,8 @@
     1. Resilience, ABI stability, `@_inlineable`, `@_versioned`, etc
     1. Strings and ICU
     1. Lifetimes
-        1. withExtendedLifetime, withUnsafe..., 
+        1. withExtendedLifetime, withUnsafe...,
+    1. Shims and stubs
 1. Coding Standards
     1. High level concerns
     1. Best practices
@@ -35,7 +36,6 @@
 1. Internals
     1. `@inline(__always)` and `@inline(never)`
     1. `@semantics(...)`
-    1. `@_silgen_name`
     1. Builtins
         1. Builtin.addressof, _isUnique, _isUniqueOrPinned, etc
 1. Dirty hacks
@@ -125,6 +125,35 @@
 
 This is currently used in the standard library as an additional annotation applied to @objc protocols signifying that any objects which conform to this protocol are not tagged. This means that (on Darwin platforms) such references, unlike AnyObject, have spare bits available from things like restricted memory spaces or alignment.
 
+#### `@_silgen_name`
+
+This attribute specifies the name that a declaration will have at link time. It is used for two purposes, the second of which is currently considered bad practice and should be replaced with shims:
+
+1. To specify the symbol name of a Swift function so that it can be called from Swift-aware C. Such functions have bodies.
+2. To provide a Swift declaration which really represents a C declaration. Such functions do not have bodies.
+
+##### Using `@_silgen_name` to call Swift from Swift-aware C
+
+Rather than hard-code Swift mangling into C code, `@_silgen_name` is used to provide a stable and known symbol name for linking. Note that C code still must understand and use the Swift calling convention (available in swift-clang) for such Swift functions (if they use Swift's CC). Example:
+
+```swift
+@_silgen_name("_swift_stdlib_destroyTLS")
+internal func _destroyTLS(_ ptr: UnsafeMutableRawPointer?) {
+  // ... implementation ...
+}
+```
+
+```C++
+__attribute__((__swiftcall__)) extern "C" void _swift_stdlib_destroyTLS(void *);
+
+// ... C code can now call _swift_stdlib_destroyTLS on a void * ...
+```
+
+##### Using `@_silgen_name` to call C from Swift
+
+The standard library cannot import the Darwin module (much less an ICU module), yet it needs access to these C functions that it otherwise wouldn't have a decl for. For that, we use shims. But, `@_silgen_name` can also be used on a body-less Swift function declaration to denote that it's an external C function whose symbol will be available at link time, even if not available at compile time. This usage is discouraged.
+
+
 ### Internal structures
 
 #### `_FixedArray`
diff --git a/include/swift/AST/ASTContext.h b/include/swift/AST/ASTContext.h
index 5a75c21..08d8326 100644
--- a/include/swift/AST/ASTContext.h
+++ b/include/swift/AST/ASTContext.h
@@ -176,6 +176,17 @@
   TypeOrExtensionDecl;
 
 /// ASTContext - This object creates and owns the AST objects.
+/// However, this class does more than just maintain context within an AST.
+/// It is the closest thing to thread-local or compile-local storage in this
+/// code base. Why? SourceKit uses this code with multiple threads per Unix
+/// process. Each thread processes a different source file. Each thread has its
+/// own instance of ASTContext, and that instance persists for the duration of
+/// the thread, throughout all phases of the compilation. (The name "ASTContext"
+/// is a bit of a misnomer here.) Why not use thread-local storage? This code
+/// may use DispatchQueues and pthread-style TLS won't work with code that uses
+/// DispatchQueues. Summary: if you think you need a global or static variable,
+/// you probably need to put it here instead.
+
 class ASTContext {
   ASTContext(const ASTContext&) = delete;
   void operator=(const ASTContext&) = delete;
diff --git a/include/swift/AST/ASTWalker.h b/include/swift/AST/ASTWalker.h
index efa35de..b112e72 100644
--- a/include/swift/AST/ASTWalker.h
+++ b/include/swift/AST/ASTWalker.h
@@ -63,7 +63,7 @@
     ParentTy(Expr *E) : Kind(ParentKind::Expr), Ptr(E) {}
     ParentTy(Pattern *P) : Kind(ParentKind::Pattern), Ptr(P) {}
     ParentTy(TypeRepr *T) : Kind(ParentKind::TypeRepr), Ptr(T) {}
-    ParentTy() = default;
+    ParentTy() : Kind(ParentKind::Module), Ptr(nullptr) { }
 
     bool isNull() const { return Ptr == nullptr; }
     ParentKind getKind() const {
diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def
index 64e96e0..c8af8d0 100644
--- a/include/swift/AST/DiagnosticsSema.def
+++ b/include/swift/AST/DiagnosticsSema.def
@@ -3721,6 +3721,11 @@
         "value %0 was defined but never used; consider replacing "
         "with boolean test",
         (Identifier))
+WARNING(unused_setter_parameter, none,
+        "setter argument %0 was never used, but the property was accessed",
+        (Identifier))
+NOTE(fixit_for_unused_setter_parameter, none,
+     "did you mean to use %0 instead of accessing the property's current value?", (Identifier))
 
 WARNING(pbd_never_used, none,
         "initialization of %select{variable|immutable value}1 %0 was never used"
diff --git a/include/swift/AST/GenericSignatureBuilder.h b/include/swift/AST/GenericSignatureBuilder.h
index 94dafa3..ba06a2b 100644
--- a/include/swift/AST/GenericSignatureBuilder.h
+++ b/include/swift/AST/GenericSignatureBuilder.h
@@ -1314,6 +1314,7 @@
                                      bool inferred) {
     FloatingRequirementSource result{ AbstractProtocol, base };
     result.protocolReq.protocol = inProtocol;
+    result.protocolReq.written = WrittenRequirementLoc();
     result.protocolReq.inferred = inferred;
     return result;
   }
diff --git a/include/swift/Basic/Statistic.h b/include/swift/Basic/Statistic.h
index 3ee26e2..1dd95e0 100644
--- a/include/swift/Basic/Statistic.h
+++ b/include/swift/Basic/Statistic.h
@@ -66,6 +66,15 @@
 #undef FRONTEND_STATISTIC
   };
 
+  struct AlwaysOnFrontendRecursiveSharedTimers {
+    AlwaysOnFrontendRecursiveSharedTimers();
+#define FRONTEND_RECURSIVE_SHARED_TIMER(ID) RecursiveSharedTimer ID;
+#include "Statistics.def"
+#undef FRONTEND_RECURSIVE_SHARED_TIMER
+
+    int dummyInstanceVariableToGetConstructorToParse;
+  };
+
   struct FrontendStatsTracer
   {
     UnifiedStatsReporter *Reporter;
@@ -105,6 +114,8 @@
   std::unique_ptr<AlwaysOnFrontendCounters> FrontendCounters;
   std::unique_ptr<AlwaysOnFrontendCounters> LastTracedFrontendCounters;
   std::vector<FrontendStatsEvent> FrontendStatsEvents;
+  std::unique_ptr<AlwaysOnFrontendRecursiveSharedTimers>
+      FrontendRecursiveSharedTimers;
 
   void publishAlwaysOnStatsToLLVM();
   void printAlwaysOnStatsAndTimers(llvm::raw_ostream &OS);
@@ -128,6 +139,7 @@
 
   AlwaysOnDriverCounters &getDriverCounters();
   AlwaysOnFrontendCounters &getFrontendCounters();
+  AlwaysOnFrontendRecursiveSharedTimers &getFrontendRecursiveSharedTimers();
   FrontendStatsTracer getStatsTracer(StringRef N,
                                      SourceRange const &R);
   void saveAnyFrontendStatsEvents(FrontendStatsTracer const& T,
diff --git a/include/swift/Basic/Statistics.def b/include/swift/Basic/Statistics.def
index 343d761..ed034a8 100644
--- a/include/swift/Basic/Statistics.def
+++ b/include/swift/Basic/Statistics.def
@@ -101,3 +101,9 @@
 
 FRONTEND_STATISTIC(LLVM, NumLLVMBytesOutput)
 #endif
+
+/// Frontend timers for recursive routines
+#ifdef FRONTEND_RECURSIVE_SHARED_TIMER
+FRONTEND_RECURSIVE_SHARED_TIMER(NominalTypeDecl__lookupDirect)
+FRONTEND_RECURSIVE_SHARED_TIMER(ClangImporter__Implementation__loadAllMembers)
+#endif
diff --git a/include/swift/Basic/Timer.h b/include/swift/Basic/Timer.h
index 75bf96a..dab7abc 100644
--- a/include/swift/Basic/Timer.h
+++ b/include/swift/Basic/Timer.h
@@ -47,11 +47,12 @@
   };
 
   /// A SharedTimer for recursive routines.
-  /// Declare as a static, and use as below:
   /// void example() {
-  ///     static RecursiveSharedTimer timer("lookupDirect");
-  ///     auto guard = RecursiveSharedTimer::Guard(timer);
-  ///     (void)guard;
+  ///  RecursiveSharedTimer::Guard guard; // MUST BE AT TOP SCOPE of function to
+  ///  work right! if (auto s = getASTContext().Stats) {
+  ///    guard =
+  ///    ctx.Stats->getFrontendRecursiveSharedTimers().NominalTypeDecl__lookupDirect.getGuard();
+  //  }
   ///   ...
   /// }
 
@@ -76,13 +77,33 @@
     RecursiveSharedTimer(StringRef name) : name(name) {}
 
     struct Guard {
-      RecursiveSharedTimer &recursiveTimer;
-      Guard &operator=(Guard &) = delete;
-      Guard(RecursiveSharedTimer &rst) : recursiveTimer(rst) {
-        recursiveTimer.enterRecursiveFunction();
+      RecursiveSharedTimer *recursiveTimerOrNull;
+
+      Guard(RecursiveSharedTimer *rst) : recursiveTimerOrNull(rst) {
+        if (recursiveTimerOrNull)
+          recursiveTimerOrNull->enterRecursiveFunction();
       }
-      ~Guard() { recursiveTimer.exitRecursiveFunction(); }
+      ~Guard() {
+        if (recursiveTimerOrNull)
+          recursiveTimerOrNull->exitRecursiveFunction();
+      }
+
+      // All this stuff is to do an RAII object that be moved.
+      Guard() : recursiveTimerOrNull(nullptr) {}
+      Guard(Guard &&other) {
+        recursiveTimerOrNull = other.recursiveTimerOrNull;
+        other.recursiveTimerOrNull = nullptr;
+      }
+      Guard &operator=(Guard &&other) {
+        recursiveTimerOrNull = other.recursiveTimerOrNull;
+        other.recursiveTimerOrNull = nullptr;
+        return *this;
+      }
+      Guard(const Guard &) = delete;
+      Guard &operator=(const Guard &) = delete;
     };
+
+    Guard getGuard() { return Guard(this); }
   };
 } // end namespace swift
 
diff --git a/include/swift/IDE/SyntaxModel.h b/include/swift/IDE/SyntaxModel.h
index 138ce92..6e223c4 100644
--- a/include/swift/IDE/SyntaxModel.h
+++ b/include/swift/IDE/SyntaxModel.h
@@ -111,6 +111,7 @@
   ArrayExpression,
   DictionaryExpression,
   ObjectLiteralExpression,
+  TupleExpression
 };
 
 enum class SyntaxStructureElementKind : uint8_t {
diff --git a/lib/AST/DeclContext.cpp b/lib/AST/DeclContext.cpp
index 27f3d50..dc1c407 100644
--- a/lib/AST/DeclContext.cpp
+++ b/lib/AST/DeclContext.cpp
@@ -942,9 +942,9 @@
   ++NumLazyIterableDeclContexts;
   ++NumUnloadedLazyIterableDeclContexts;
   // FIXME: (transitional) increment the redundant "always-on" counter.
-  if (ctx.Stats) {
-    ++ctx.Stats->getFrontendCounters().NumLazyIterableDeclContexts;
-    ++ctx.Stats->getFrontendCounters().NumUnloadedLazyIterableDeclContexts;
+  if (auto s = ctx.Stats) {
+    ++s->getFrontendCounters().NumLazyIterableDeclContexts;
+    ++s->getFrontendCounters().NumUnloadedLazyIterableDeclContexts;
   }
 }
 
@@ -974,8 +974,8 @@
 
   --NumUnloadedLazyIterableDeclContexts;
   // FIXME: (transitional) decrement the redundant "always-on" counter.
-  if (ctx.Stats)
-    ctx.Stats->getFrontendCounters().NumUnloadedLazyIterableDeclContexts--;
+  if (auto s = ctx.Stats)
+    s->getFrontendCounters().NumUnloadedLazyIterableDeclContexts--;
 }
 
 bool IterableDeclContext::classof(const Decl *D) {
diff --git a/lib/AST/NameLookup.cpp b/lib/AST/NameLookup.cpp
index 288662d..5f3960c 100644
--- a/lib/AST/NameLookup.cpp
+++ b/lib/AST/NameLookup.cpp
@@ -1194,14 +1194,13 @@
 TinyPtrVector<ValueDecl *> NominalTypeDecl::lookupDirect(
                                                   DeclName name,
                                                   bool ignoreNewExtensions) {
-  static RecursiveSharedTimer timer("lookupDirect");
-  auto guard = RecursiveSharedTimer::Guard(timer);
-  (void)guard;
+  RecursiveSharedTimer::Guard guard;
+  if (auto s = getASTContext().Stats) {
+    ++s->getFrontendCounters().NominalTypeLookupDirectCount;
+    guard = s->getFrontendRecursiveSharedTimers()
+                .NominalTypeDecl__lookupDirect.getGuard();
+  }
 
-  ASTContext &ctx = getASTContext();
-  if (ctx.Stats)
-    ++ctx.Stats->getFrontendCounters().NominalTypeLookupDirectCount;
-  
   (void)getMembers();
 
   // Make sure we have the complete list of members (in this nominal and in all
diff --git a/lib/Basic/Statistic.cpp b/lib/Basic/Statistic.cpp
index 6165702..8d04a8d 100644
--- a/lib/Basic/Statistic.cpp
+++ b/lib/Basic/Statistic.cpp
@@ -173,6 +173,14 @@
   return *FrontendCounters;
 }
 
+UnifiedStatsReporter::AlwaysOnFrontendRecursiveSharedTimers &
+UnifiedStatsReporter::getFrontendRecursiveSharedTimers() {
+  if (!FrontendRecursiveSharedTimers)
+    FrontendRecursiveSharedTimers =
+        make_unique<AlwaysOnFrontendRecursiveSharedTimers>();
+  return *FrontendRecursiveSharedTimers;
+}
+
 void
 UnifiedStatsReporter::publishAlwaysOnStatsToLLVM() {
   if (FrontendCounters) {
@@ -313,6 +321,15 @@
 #undef FRONTEND_STATISTIC
 }
 
+UnifiedStatsReporter::AlwaysOnFrontendRecursiveSharedTimers::
+    AlwaysOnFrontendRecursiveSharedTimers()
+    :
+#define FRONTEND_RECURSIVE_SHARED_TIMER(ID) ID(#ID),
+#include "swift/Basic/Statistics.def"
+#undef FRONTEND_RECURSIVE_SHARED_TIMER
+      dummyInstanceVariableToGetConstructorToParse(0) {
+}
+
 UnifiedStatsReporter::~UnifiedStatsReporter()
 {
   // NB: Timer needs to be Optional<> because it needs to be destructed early;
diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp
index 16f22e8..d3dcd8e 100644
--- a/lib/ClangImporter/ImportDecl.cpp
+++ b/lib/ClangImporter/ImportDecl.cpp
@@ -7978,9 +7978,11 @@
 
 void
 ClangImporter::Implementation::loadAllMembers(Decl *D, uint64_t extra) {
-  static RecursiveSharedTimer timer("ClangImporterLoadAllMembers");
-  auto guard = RecursiveSharedTimer::Guard(timer);
-  (void)guard;
+  RecursiveSharedTimer::Guard guard;
+  if (auto s = D->getASTContext().Stats) {
+    guard = s->getFrontendRecursiveSharedTimers()
+                .ClangImporter__Implementation__loadAllMembers.getGuard();
+  }
 
   assert(D);
 
diff --git a/lib/IDE/SyntaxModel.cpp b/lib/IDE/SyntaxModel.cpp
index d6465b0..d43c0bc 100644
--- a/lib/IDE/SyntaxModel.cpp
+++ b/lib/IDE/SyntaxModel.cpp
@@ -507,10 +507,24 @@
     SN.BodyRange = innerCharSourceRangeFromSourceRange(SM, E->getSourceRange());
     pushStructureNode(SN, E);
   } else if (auto *Tup = dyn_cast<TupleExpr>(E)) {
-    for (unsigned I = 0; I < Tup->getNumElements(); ++ I) {
-      SourceLoc NameLoc = Tup->getElementNameLoc(I);
-      if (NameLoc.isValid())
-        passTokenNodesUntil(NameLoc, PassNodesBehavior::ExcludeNodeAtLocation);
+    if (isCurrentCallArgExpr(Tup)) {
+      for (unsigned I = 0; I < Tup->getNumElements(); ++ I) {
+        SourceLoc NameLoc = Tup->getElementNameLoc(I);
+        if (NameLoc.isValid())
+          passTokenNodesUntil(NameLoc, PassNodesBehavior::ExcludeNodeAtLocation);
+      }
+    } else {
+      SyntaxStructureNode SN;
+      SN.Kind = SyntaxStructureKind::TupleExpression;
+      SN.Range = charSourceRangeFromSourceRange(SM, Tup->getSourceRange());
+      SN.BodyRange = innerCharSourceRangeFromSourceRange(SM,
+                                                         Tup->getSourceRange());
+
+      for (auto *Elem : Tup->getElements()) {
+        addExprElem(Elem, SN);
+      }
+
+      pushStructureNode(SN, Tup);
     }
   }
 
diff --git a/lib/SIL/SILFunctionType.cpp b/lib/SIL/SILFunctionType.cpp
index dbb400d..1286792 100644
--- a/lib/SIL/SILFunctionType.cpp
+++ b/lib/SIL/SILFunctionType.cpp
@@ -867,9 +867,14 @@
     for (auto capture : loweredCaptures.getCaptures()) {
       if (capture.isDynamicSelfMetadata()) {
         ParameterConvention convention = ParameterConvention::Direct_Unowned;
+        auto dynamicSelfInterfaceType = GenericEnvironment::mapTypeOutOfContext(
+          function->getGenericEnvironment(),
+          loweredCaptures.getDynamicSelfType());
+        
         auto selfMetatype = MetatypeType::get(
-            loweredCaptures.getDynamicSelfType(),
+            dynamicSelfInterfaceType,
             MetatypeRepresentation::Thick);
+        
         auto canSelfMetatype = getCanonicalType(selfMetatype);
         SILParameterInfo param(canSelfMetatype, convention);
         inputs.push_back(param);
diff --git a/lib/Sema/CSDiag.cpp b/lib/Sema/CSDiag.cpp
index d2b84a8..f1e0cd5 100644
--- a/lib/Sema/CSDiag.cpp
+++ b/lib/Sema/CSDiag.cpp
@@ -6214,11 +6214,15 @@
 
   auto result = TC.checkGenericArguments(
       dc, callExpr->getLoc(), fnExpr->getLoc(), AFD->getInterfaceType(),
-      env->getGenericSignature(), QueryTypeSubstitutionMap{substitutions},
+      env->getGenericSignature(), substitutionFn,
       LookUpConformanceInModule{dc->getParentModule()}, nullptr,
       ConformanceCheckFlags::SuppressDependencyTracking, &genericReqListener);
 
-  return result != RequirementCheckResult::Success;
+  assert(result != RequirementCheckResult::UnsatisfiedDependency);
+
+  // Note: If result is RequirementCheckResult::SubstitutionFailure, we did
+  // not emit a diagnostic, so we must return false in that case.
+  return result == RequirementCheckResult::Failure;
 }
 
 /// When initializing Unsafe[Mutable]Pointer<T> from Unsafe[Mutable]RawPointer,
diff --git a/lib/Sema/ConstraintSystem.h b/lib/Sema/ConstraintSystem.h
index 296a099..55c7496 100644
--- a/lib/Sema/ConstraintSystem.h
+++ b/lib/Sema/ConstraintSystem.h
@@ -2641,35 +2641,32 @@
       if (NumDefaultableBindings > 0)
         out << "#defaultable_bindings=" << NumDefaultableBindings << " ";
 
-      out << "bindings=";
-      if (!Bindings.empty()) {
-        interleave(Bindings,
-                   [&](const PotentialBinding &binding) {
-                     auto type = binding.BindingType;
-                     auto &ctx = type->getASTContext();
-                     llvm::SaveAndRestore<bool> debugConstraints(
-                         ctx.LangOpts.DebugConstraintSolver, true);
-                     switch (binding.Kind) {
-                     case AllowedBindingKind::Exact:
-                       break;
+      out << "bindings={";
+      interleave(Bindings,
+                 [&](const PotentialBinding &binding) {
+                   auto type = binding.BindingType;
+                   auto &ctx = type->getASTContext();
+                   llvm::SaveAndRestore<bool> debugConstraints(
+                       ctx.LangOpts.DebugConstraintSolver, true);
+                   switch (binding.Kind) {
+                   case AllowedBindingKind::Exact:
+                     break;
 
-                     case AllowedBindingKind::Subtypes:
-                       out << "(subtypes of) ";
-                       break;
+                   case AllowedBindingKind::Subtypes:
+                     out << "(subtypes of) ";
+                     break;
 
-                     case AllowedBindingKind::Supertypes:
-                       out << "(supertypes of) ";
-                       break;
-                     }
-                     if (binding.DefaultedProtocol)
-                       out << "(default from "
-                           << (*binding.DefaultedProtocol)->getName() << ") ";
-                     out << type.getString();
-                   },
-                   [&]() { out << " "; });
-      } else {
-        out << "{}";
-      }
+                   case AllowedBindingKind::Supertypes:
+                     out << "(supertypes of) ";
+                     break;
+                   }
+                   if (binding.DefaultedProtocol)
+                     out << "(default from "
+                         << (*binding.DefaultedProtocol)->getName() << ") ";
+                   out << type.getString();
+                 },
+                 [&]() { out << "; "; });
+      out << "}";
     }
 
     void dump(ConstraintSystem *cs,
diff --git a/lib/Sema/MiscDiagnostics.cpp b/lib/Sema/MiscDiagnostics.cpp
index 54fd144..d47a255 100644
--- a/lib/Sema/MiscDiagnostics.cpp
+++ b/lib/Sema/MiscDiagnostics.cpp
@@ -2093,7 +2093,13 @@
   /// This is a mapping from an OpaqueValue to the expression that initialized
   /// it.
   llvm::SmallDenseMap<OpaqueValueExpr*, Expr*> OpaqueValueMap;
-  
+
+  /// The getter associated with a setter function declaration.
+  const VarDecl *AssociatedGetter = nullptr;
+
+  /// The first reference to the associated getter.
+  const DeclRefExpr *AssociatedGetterDeclRef = nullptr;
+
   /// This is a mapping from VarDecls to the if/while/guard statement that they
   /// occur in, when they are in a pattern in a StmtCondition.
   llvm::SmallDenseMap<VarDecl*, LabeledConditionalStmt*> StmtConditionForVD;
@@ -2105,12 +2111,18 @@
 
 public:
   VarDeclUsageChecker(TypeChecker &TC, AbstractFunctionDecl *AFD) : Diags(TC.Diags) {
-    // Track the parameters of the function.
-    for (auto PL : AFD->getParameterLists())
-      for (auto param : *PL)
-        if (shouldTrackVarDecl(param))
-          VarDecls[param] = 0;
-    
+    // If this AFD is a setter, track the parameter and the getter for
+    // the containing property so if newValue isn't used but the getter is used
+    // an error can be reported.
+    if (auto FD = dyn_cast<FuncDecl>(AFD)) {
+      if (FD->getAccessorKind() == AccessorKind::IsSetter) {
+        if (auto getter = dyn_cast<VarDecl>(FD->getAccessorStorageDecl())) {
+          auto arguments = FD->getParameterLists().back();
+          VarDecls[arguments->get(0)] = 0;
+          AssociatedGetter = getter;
+        }
+      }
+    }
   }
 
   VarDeclUsageChecker(DiagnosticEngine &Diags) : Diags(Diags) {}
@@ -2119,7 +2131,7 @@
     // Track a specific VarDecl
     VarDecls[VD] = 0;
   }
-    
+
   void suppressDiagnostics() {
     sawError = true; // set this flag so that no diagnostics will be emitted on delete.
   }
@@ -2257,7 +2269,6 @@
       }
     }
 
-    
     // Note that we ignore the initialization behavior of PatternBindingDecls,
     // but we do want to walk into them, because we want to see any uses or
     // other things going on in the initializer expressions.
@@ -2321,12 +2332,27 @@
     if (var->isInOut())
       continue;    
     
-    // Consider parameters to always have been read.  It is common to name a
-    // parameter and not use it (e.g. because you are an override or want the
-    // named keyword, etc).  Warning to rewrite it to _ is more annoying than
-    // it is useful.
-    if (isa<ParamDecl>(var))
-      access |= RK_Read;
+    // If the setter parameter is not used, but the property is read, report
+    // a warning. Otherwise, parameters should not generate usage warnings. It
+    // is common to name a parameter and not use it (e.g. because you are an
+    // override or want the named keyword, etc).  Warning to rewrite it to _ is
+    // more annoying than it is useful.
+    if (auto param = dyn_cast<ParamDecl>(var)) {
+      auto FD = dyn_cast<FuncDecl>(param->getDeclContext());
+      if (FD && FD->getAccessorKind() == AccessorKind::IsSetter) {
+        auto getter = dyn_cast<VarDecl>(FD->getAccessorStorageDecl());
+        if ((access & RK_Read) == 0 && AssociatedGetter == getter) {
+          if (auto DRE = AssociatedGetterDeclRef) {
+            Diags.diagnose(DRE->getLoc(), diag::unused_setter_parameter,
+                           var->getName());
+            Diags.diagnose(DRE->getLoc(), diag::fixit_for_unused_setter_parameter,
+                           var->getName())
+              .fixItReplace(DRE->getSourceRange(), var->getName().str());
+          }
+        }
+      }
+      continue;
+    }
     
     // Diagnose variables that were never used (other than their
     // initialization).
@@ -2608,9 +2634,15 @@
 
   // If this is a DeclRefExpr found in a random place, it is a load of the
   // vardecl.
-  if (auto *DRE = dyn_cast<DeclRefExpr>(E))
+  if (auto *DRE = dyn_cast<DeclRefExpr>(E)) {
     addMark(DRE->getDecl(), RK_Read);
 
+    // If the Decl is a read of a getter, track the first DRE for diagnostics
+    if (auto VD = dyn_cast<VarDecl>(DRE->getDecl())) {
+      if (AssociatedGetter == VD && AssociatedGetterDeclRef == nullptr)
+        AssociatedGetterDeclRef = DRE;
+    }
+  }
   // If this is an AssignExpr, see if we're mutating something that we know
   // about.
   if (auto *assign = dyn_cast<AssignExpr>(E)) {
diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp
index 9df52e5..467e35c 100644
--- a/lib/Serialization/Deserialization.cpp
+++ b/lib/Serialization/Deserialization.cpp
@@ -2128,8 +2128,8 @@
   SmallVector<uint64_t, 64> scratch;
   StringRef blobData;
 
-  if (ctx.Stats)
-    ctx.Stats->getFrontendCounters().NumDeclsDeserialized++;
+  if (auto s = ctx.Stats)
+    s->getFrontendCounters().NumDeclsDeserialized++;
 
   // Read the attributes (if any).
   // This isn't just using DeclAttributes because that would result in the
@@ -3816,8 +3816,8 @@
   StringRef blobData;
   unsigned recordID = DeclTypeCursor.readRecord(entry.ID, scratch, &blobData);
 
-  if (ctx.Stats)
-    ctx.Stats->getFrontendCounters().NumTypesDeserialized++;
+  if (auto s = ctx.Stats)
+    s->getFrontendCounters().NumTypesDeserialized++;
 
   switch (recordID) {
   case decls_block::NAME_ALIAS_TYPE: {
diff --git a/stdlib/public/SDK/Foundation/NSStringAPI.swift b/stdlib/public/SDK/Foundation/NSStringAPI.swift
index 03ebc30..1b57164 100644
--- a/stdlib/public/SDK/Foundation/NSStringAPI.swift
+++ b/stdlib/public/SDK/Foundation/NSStringAPI.swift
@@ -42,12 +42,6 @@
   return result
 }
 
-func _toNSRange(_ r: Range<String.Index>) -> NSRange {
-  return NSRange(
-    location: r.lowerBound.encodedOffset,
-    length: r.upperBound.encodedOffset - r.lowerBound.encodedOffset)
-}
-
 #if !DEPLOYMENT_RUNTIME_SWIFT
 // We only need this for UnsafeMutablePointer, but there's not currently a way
 // to write that constraint.
@@ -439,10 +433,26 @@
     return self._ephemeralString._bridgeToObjectiveC()
   }
 
+  // self can be a Substring so we need to subtract/add this offset when
+  // passing _ns to the Foundation APIs. Will be 0 if self is String.
+  @_inlineable
+  @_versioned
+  internal var _substringOffset: Int {
+    return self.startIndex.encodedOffset
+  }
+
   /// Return an `Index` corresponding to the given offset in our UTF-16
   /// representation.
   func _index(_ utf16Index: Int) -> Index {
-    return Index(encodedOffset: utf16Index)
+    return Index(encodedOffset: utf16Index + _substringOffset)
+  }
+
+  @_inlineable
+  @_versioned
+  internal func _toRelativeNSRange(_ r: Range<String.Index>) -> NSRange {
+    return NSRange(
+      location: r.lowerBound.encodedOffset - _substringOffset,
+      length: r.upperBound.encodedOffset - r.lowerBound.encodedOffset)
   }
 
   /// Return a `Range<Index>` corresponding to the given `NSRange` of
@@ -603,7 +613,7 @@
     return locale != nil ? _ns.compare(
       aString,
       options: mask,
-      range: _toNSRange(
+      range: _toRelativeNSRange(
         range ?? startIndex..<endIndex
       ),
       locale: locale?._bridgeToObjectiveC()
@@ -612,7 +622,7 @@
     : range != nil ? _ns.compare(
       aString,
       options: mask,
-      range: _toNSRange(range!)
+      range: _toRelativeNSRange(range!)
     )
 
     : !mask.isEmpty ? _ns.compare(aString, options: mask)
@@ -1050,7 +1060,7 @@
     T : StringProtocol, R : RangeExpression
   >(in range: R, with replacement: T) -> String where R.Bound == Index {
     return _ns.replacingCharacters(
-      in: _toNSRange(range.relative(to: self)),
+      in: _toRelativeNSRange(range.relative(to: self)),
       with: replacement._ephemeralString)
   }
 
@@ -1083,7 +1093,7 @@
       of: target,
       with: replacement,
       options: options,
-      range: _toNSRange(
+      range: _toRelativeNSRange(
         searchRange ?? startIndex..<endIndex
       )
     )
@@ -1208,7 +1218,7 @@
   ) where R.Bound == Index {
     let range = range.relative(to: self)
     _ns.enumerateLinguisticTags(
-      in: _toNSRange(range),
+      in: _toRelativeNSRange(range),
       scheme: tagScheme._ephemeralString,
       options: opts,
       orthography: orthography != nil ? orthography! : nil
@@ -1273,7 +1283,7 @@
     ) -> Void
   ) where R.Bound == Index {
     _ns.enumerateSubstrings(
-      in: _toNSRange(range.relative(to: self)), options: opts) {
+      in: _toRelativeNSRange(range.relative(to: self)), options: opts) {
       var stop_ = false
 
       body($0,
@@ -1346,7 +1356,7 @@
         usedLength: usedBufferCount,
         encoding: encoding.rawValue,
         options: options,
-        range: _toNSRange(range.relative(to: self)),
+        range: _toRelativeNSRange(range.relative(to: self)),
         remaining: $0)
     }
   }
@@ -1373,7 +1383,7 @@
           contentsEnd in self._ns.getLineStart(
             start, end: end,
             contentsEnd: contentsEnd,
-            for: _toNSRange(range.relative(to: self)))
+            for: _toRelativeNSRange(range.relative(to: self)))
         }
       }
     }
@@ -1401,7 +1411,7 @@
           contentsEnd in self._ns.getParagraphStart(
             start, end: end,
             contentsEnd: contentsEnd,
-            for: _toNSRange(range.relative(to: self)))
+            for: _toRelativeNSRange(range.relative(to: self)))
         }
       }
     }
@@ -1428,7 +1438,8 @@
   public func lineRange<
     R : RangeExpression
   >(for aRange: R) -> Range<Index> where R.Bound == Index {
-    return _range(_ns.lineRange(for: _toNSRange(aRange.relative(to: self))))
+    return _range(_ns.lineRange(
+      for: _toRelativeNSRange(aRange.relative(to: self))))
   }
 
 #if !DEPLOYMENT_RUNTIME_SWIFT
@@ -1453,7 +1464,7 @@
     var nsTokenRanges: NSArray?
     let result = tokenRanges._withNilOrAddress(of: &nsTokenRanges) {
       self._ns.linguisticTags(
-        in: _toNSRange(range.relative(to: self)),
+        in: _toRelativeNSRange(range.relative(to: self)),
         scheme: tagScheme._ephemeralString,
         options: opts,
         orthography: orthography,
@@ -1477,7 +1488,7 @@
     R : RangeExpression
   >(for aRange: R) -> Range<Index> where R.Bound == Index {
     return _range(
-      _ns.paragraphRange(for: _toNSRange(aRange.relative(to: self))))
+      _ns.paragraphRange(for: _toRelativeNSRange(aRange.relative(to: self))))
   }
 #endif
 
@@ -1504,7 +1515,7 @@
       _ns.rangeOfCharacter(
         from: aSet,
         options: mask,
-        range: _toNSRange(
+        range: _toRelativeNSRange(
           aRange ?? startIndex..<endIndex
         )
       )
@@ -1535,7 +1546,7 @@
     // and output ranges due (if nothing else) to locale changes
     return _range(
       _ns.rangeOfComposedCharacterSequences(
-        for: _toNSRange(range.relative(to: self))))
+        for: _toRelativeNSRange(range.relative(to: self))))
   }
 
   // - (NSRange)rangeOfString:(NSString *)aString
@@ -1570,13 +1581,13 @@
       locale != nil ? _ns.range(
         of: aString,
         options: mask,
-        range: _toNSRange(
+        range: _toRelativeNSRange(
           searchRange ?? startIndex..<endIndex
         ),
         locale: locale
       )
       : searchRange != nil ? _ns.range(
-        of: aString, options: mask, range: _toNSRange(searchRange!)
+        of: aString, options: mask, range: _toRelativeNSRange(searchRange!)
       )
       : !mask.isEmpty ? _ns.range(of: aString, options: mask)
       : _ns.range(of: aString)
@@ -1687,7 +1698,7 @@
   @available(swift, deprecated: 4.0,
     message: "Please use String slicing subscript.")
   public func substring(with aRange: Range<Index>) -> String {
-    return _ns.substring(with: _toNSRange(aRange))
+    return _ns.substring(with: _toRelativeNSRange(aRange))
   }
 }
 
diff --git a/stdlib/public/stubs/UnicodeNormalization.cpp b/stdlib/public/stubs/UnicodeNormalization.cpp
index fe3a29d..703a3db 100644
--- a/stdlib/public/stubs/UnicodeNormalization.cpp
+++ b/stdlib/public/stubs/UnicodeNormalization.cpp
@@ -330,7 +330,5 @@
 // Force an autolink with ICU
 #if defined(__MACH__)
 asm(".linker_option \"-licucore\"\n");
-#elif defined(_WIN32)
-#pragma comment(lib, "icucore.lib")
 #endif // defined(__MACH__)
 
diff --git a/test/Constraints/diagnostics.swift b/test/Constraints/diagnostics.swift
index e609b84..8c9bba8 100644
--- a/test/Constraints/diagnostics.swift
+++ b/test/Constraints/diagnostics.swift
@@ -1102,3 +1102,12 @@
     // expected-error@-1 {{type of expression is ambiguous without more context}}
   }
 }
+
+// https://bugs.swift.org/browse/SR-5934 - failure to emit diagnostic for bad
+// generic constraints
+func elephant<T, U>(_: T) where T : Collection, T.Element == U, T.Element : Hashable {}
+// expected-note@-1 {{in call to function 'elephant'}}
+
+func platypus<T>(a: [T]) {
+    _ = elephant(a) // expected-error {{generic parameter 'U' could not be inferred}}
+}
diff --git a/test/Constraints/interpolation_segments.swift b/test/Constraints/interpolation_segments.swift
index 8811e88..dc2ffbe 100644
--- a/test/Constraints/interpolation_segments.swift
+++ b/test/Constraints/interpolation_segments.swift
@@ -16,30 +16,30 @@
 // CHECK-NEXT:  9:
 
 // CHECK: (solving component #
-// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByStringLiteral) String)
+// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByStringLiteral) String})
 
 // CHECK: (solving component #
-// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByIntegerLiteral) Int)
+// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int})
 
 // CHECK: (solving component #
-// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByStringLiteral) String)
+// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByStringLiteral) String})
 
 // CHECK: (solving component #
-// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByIntegerLiteral) Int)
+// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int})
 
 // CHECK: (solving component #
-// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByStringLiteral) String)
+// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByStringLiteral) String})
 
 // CHECK: (solving component #
-// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByIntegerLiteral) Int)
+// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int})
 
 // CHECK: (solving component #
-// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByStringLiteral) String)
+// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByStringLiteral) String})
 
 // CHECK: (solving component #
-// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByIntegerLiteral) Int)
+// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int})
 
 // CHECK: (solving component #
-// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByStringLiteral) String)
+// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByStringLiteral) String})
 
 _ = "\(1), \(2), \(3), \(4)"
diff --git a/test/IDE/structure.swift b/test/IDE/structure.swift
index 336610d..4274fd2 100644
--- a/test/IDE/structure.swift
+++ b/test/IDE/structure.swift
@@ -232,3 +232,21 @@
 
 a.b(c: d?.e?.f, g: h)
 // CHECK: <call><name>a.b</name>(<arg><name>c</name>: d?.e?.f</arg>, <arg><name>g</name>: h</arg>)</call>
+
+struct Tuples {
+  var foo: (Int, String) {
+    return (1, "test")
+    // CHECK: <tuple>(<elem-expr>1</elem-expr>, <elem-expr>"test"</elem-expr>)</tuple>
+  }
+  
+  func foo2() {
+    foo3(x: (1, 20))
+    // CHECK: <call><name>foo3</name>(<arg><name>x</name>: <tuple>(<elem-expr>1</elem-expr>, <elem-expr>20</elem-expr>)</tuple></arg>)</call>
+    let y = (x, foo4(a: 0))
+    // CHECK: <lvar>let <name>y</name> = <tuple>(<elem-expr>x</elem-expr>, <elem-expr><call><name>foo4</name>(<arg><name>a</name>: 0</arg>)</call></elem-expr>)</tuple></lvar>
+    
+    let z = (name1: 1, name2: 2)
+    // CHECK: <lvar>let <name>z</name> = <tuple>(name1: <elem-expr>1</elem-expr>, name2: <elem-expr>2</elem-expr>)</tuple></lvar>
+  }
+}
+
diff --git a/test/NameBinding/scope_map_lookup.swift b/test/NameBinding/scope_map_lookup.swift
index 102ff1f..902aebd 100644
--- a/test/NameBinding/scope_map_lookup.swift
+++ b/test/NameBinding/scope_map_lookup.swift
@@ -93,6 +93,7 @@
       return localProperty // expected-warning{{attempting to access 'localProperty' within its own getter}}
     }
     set {
+      _ = newValue
       print(localProperty)
     }
   }
diff --git a/test/SILGen/dynamic_self.swift b/test/SILGen/dynamic_self.swift
index 1b94302..5231557 100644
--- a/test/SILGen/dynamic_self.swift
+++ b/test/SILGen/dynamic_self.swift
@@ -355,6 +355,28 @@
   }
 }
 
+class Generic<T> {
+  // Examples where we have to add a special argument to capture Self's metadata
+  func t1() -> Self {
+    // CHECK-LABEL: sil private @_T012dynamic_self7GenericC2t1ACyxGXDyFAEXDSgycfU_ : $@convention(thin) <T> (@owned <τ_0_0> { var @sil_weak Optional<Generic<τ_0_0>> } <T>, @thick @dynamic_self Generic<T>.Type) -> @owned Optional<Generic<T>>
+    _ = {[weak self] in self }
+    return self
+  }
+
+  func t2() -> Self {
+    // CHECK-LABEL: sil private @_T012dynamic_self7GenericC2t2ACyxGXDyFAEXD_AEXDtycfU_ : $@convention(thin) <T> (@owned (Generic<T>, Generic<T>), @thick @dynamic_self Generic<T>.Type) -> (@owned Generic<T>, @owned Generic<T>)
+    let selves = (self, self)
+    _ = { selves }
+    return self
+  }
+
+  func t3() -> Self {
+    // CHECK-LABEL: sil private @_T012dynamic_self7GenericC2t3ACyxGXDyFAEXDycfU_ : $@convention(thin) <T> (@owned @sil_unowned Generic<T>, @thick @dynamic_self Generic<T>.Type) -> @owned Generic<T> 
+    _ = {[unowned self] in self }
+    return self
+  }
+}
+
 // CHECK-LABEL: sil_witness_table hidden X: P module dynamic_self {
 // CHECK: method #P.f!1: {{.*}} : @_T012dynamic_self1XCAA1PA2aDP1f{{[_0-9a-zA-Z]*}}FTW
 
diff --git a/test/decl/var/usage.swift b/test/decl/var/usage.swift
index b6236f8..73273f3 100644
--- a/test/decl/var/usage.swift
+++ b/test/decl/var/usage.swift
@@ -274,3 +274,34 @@
   let x: Int // expected-warning {{immutable value 'x' was never used; consider removing it}}
   x = 42
 }
+
+// Tests fix to SR-964
+func sr964() {
+  var noOpSetter: String {
+    get { return "" }
+    set { } // No warning
+  }
+  var suspiciousSetter: String {
+    get { return "" }
+    set {
+      print(suspiciousSetter) // expected-warning {{setter argument 'newValue' was never used, but the property was accessed}} expected-note {{did you mean to use 'newValue' instead of accessing the property's current value?}} {{13-29=newValue}}
+    }
+  }
+  var namedSuspiciousSetter: String {
+    get { return "" }
+    set(parameter) {
+      print(namedSuspiciousSetter) // expected-warning {{setter argument 'parameter' was never used, but the property was accessed}} expected-note {{did you mean to use 'parameter' instead of accessing the property's current value?}} {{13-34=parameter}}
+    }
+  }
+  var okSetter: String {
+    get { return "" }
+    set { print(newValue) } // No warning
+  }
+  var multiTriggerSetter: String {
+    get { return "" }
+    set {
+      print(multiTriggerSetter) // expected-warning {{setter argument 'newValue' was never used, but the property was accessed}} expected-note {{did you mean to use 'newValue' instead of accessing the property's current value?}} {{13-31=newValue}}
+      print(multiTriggerSetter)
+    }
+  }
+}
diff --git a/test/lit.cfg b/test/lit.cfg
index 12a5315..590db94 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -115,7 +115,7 @@
         else:
             return "simctl spawn 'iPhone 6'"
     elif run_os == 'tvos':
-        return "simctl spawn 'Apple TV 1080p'"
+        return "simctl spawn 'Apple TV 4K'"
     elif run_os == 'watchos':
         return "simctl spawn 'Apple Watch - 42mm'"
     else:
diff --git a/test/stdlib/NSStringAPI+Substring.swift b/test/stdlib/NSStringAPI+Substring.swift
new file mode 100644
index 0000000..92c9444
--- /dev/null
+++ b/test/stdlib/NSStringAPI+Substring.swift
@@ -0,0 +1,146 @@
+// RUN: rm -rf %t ; mkdir -p %t
+// RUN: %target-build-swift %s -o %t/a.out4 -swift-version 4 && %target-run %t/a.out4
+// REQUIRES: executable_test
+
+// REQUIRES: objc_interop
+
+//
+// Tests for the NSString APIs on Substring
+//
+
+import StdlibUnittest
+
+import Foundation
+
+
+extension String {
+  func range(fromStart: Int, fromEnd: Int) -> Range<String.Index> {
+    return index(startIndex, offsetBy: fromStart) ..<
+           index(endIndex, offsetBy: fromEnd)
+  }
+  subscript(fromStart: Int, fromEnd: Int) -> SubSequence {
+    return self[range(fromStart: fromStart, fromEnd: fromEnd)]
+  }
+}
+
+var tests = TestSuite("NSStringAPIs/Substring")
+
+tests.test("range(of:)/NilRange") {
+  let ss = "aabcdd"[1, -1]
+  let range = ss.range(of: "bc")
+  expectOptionalEqual("bc", range.map { ss[$0] })
+}
+
+tests.test("range(of:)/NonNilRange") {
+  let s = "aabcdd"
+  let ss = s[1, -1]
+  let searchRange = s.range(fromStart: 2, fromEnd: -2)
+  let range = ss.range(of: "bc", range: searchRange)
+  expectOptionalEqual("bc", range.map { ss[$0] })
+}
+
+tests.test("rangeOfCharacter") {
+  let ss = "__hello__"[2, -2]
+  let range = ss.rangeOfCharacter(from: CharacterSet.alphanumerics)
+  expectOptionalEqual("h", range.map { ss[$0] })
+}
+
+tests.test("compare(_:options:range:locale:)/NilRange") {
+  let needle = "hello"
+  let haystack = "__hello__"[2, -2]
+  expectEqual(.orderedSame, haystack.compare(needle))
+}
+
+tests.test("compare(_:options:range:locale:)/NonNilRange") {
+  let needle = "hello"
+  let haystack = "__hello__"
+  let range = haystack.range(fromStart: 2, fromEnd: -2)
+  expectEqual(.orderedSame, haystack[range].compare(needle, range: range))
+}
+
+tests.test("replacingCharacters(in:with:)") {
+  let s = "__hello, world"
+  let range = s.range(fromStart: 2, fromEnd: -7)
+  let expected = "__goodbye, world"
+  let replacement = "goodbye"
+  expectEqual(expected,
+    s.replacingCharacters(in: range, with: replacement))
+  expectEqual(expected[2, 0],
+    s[2, 0].replacingCharacters(in: range, with: replacement))
+
+  expectEqual(replacement,
+    s.replacingCharacters(in: s.startIndex..., with: replacement))
+  expectEqual(replacement,
+    s.replacingCharacters(in: ..<s.endIndex, with: replacement))
+  expectEqual(expected[2, 0],
+    s[2, 0].replacingCharacters(in: range, with: replacement[...]))
+}
+
+tests.test("replacingOccurrences(of:with:options:range:)/NilRange") {
+  let s = "hello"
+
+  expectEqual("he11o", s.replacingOccurrences(of: "l", with: "1"))
+  expectEqual("he11o", s.replacingOccurrences(of: "l"[...], with: "1"))
+  expectEqual("he11o", s.replacingOccurrences(of: "l", with: "1"[...]))
+  expectEqual("he11o", s.replacingOccurrences(of: "l"[...], with: "1"[...]))
+
+  expectEqual("he11o",
+    s[...].replacingOccurrences(of: "l", with: "1"))
+  expectEqual("he11o",
+    s[...].replacingOccurrences(of: "l"[...], with: "1"))
+  expectEqual("he11o",
+    s[...].replacingOccurrences(of: "l", with: "1"[...]))
+  expectEqual("he11o",
+    s[...].replacingOccurrences(of: "l"[...], with: "1"[...]))
+}
+
+tests.test("replacingOccurrences(of:with:options:range:)/NonNilRange") {
+  let s = "hello"
+  let r = s.range(fromStart: 1, fromEnd: -2)
+
+  expectEqual("he1lo",
+    s.replacingOccurrences(of: "l", with: "1", range: r))
+  expectEqual("he1lo",
+    s.replacingOccurrences(of: "l"[...], with: "1", range: r))
+  expectEqual("he1lo",
+    s.replacingOccurrences(of: "l", with: "1"[...], range: r))
+  expectEqual("he1lo",
+    s.replacingOccurrences(of: "l"[...], with: "1"[...], range: r))
+
+  expectEqual("he1lo",
+    s[...].replacingOccurrences(of: "l", with: "1", range: r))
+  expectEqual("he1lo",
+    s[...].replacingOccurrences(of: "l"[...], with: "1", range: r))
+  expectEqual("he1lo",
+    s[...].replacingOccurrences(of: "l", with: "1"[...], range: r))
+  expectEqual("he1lo",
+    s[...].replacingOccurrences(of: "l"[...], with: "1"[...], range: r))
+
+  let ss = s[1, -1]
+  expectEqual("e1l",
+    ss.replacingOccurrences(of: "l", with: "1", range: r))
+  expectEqual("e1l",
+    ss.replacingOccurrences(of: "l"[...], with: "1", range: r))
+  expectEqual("e1l",
+    ss.replacingOccurrences(of: "l", with: "1"[...], range: r))
+  expectEqual("e1l",
+    ss.replacingOccurrences(of: "l"[...], with: "1"[...], range: r))
+}
+
+tests.test("substring(with:)") {
+  let s = "hello, world"
+  let r = s.range(fromStart: 7, fromEnd: 0)
+  expectEqual("world", s.substring(with: r))
+  expectEqual("world", s[...].substring(with: r))
+  expectEqual("world", s[1, 0].substring(with: r))
+}
+
+tests.test("substring(with:)/SubscriptEquivalence") {
+  let s = "hello, world"
+  let r = s.range(fromStart: 7, fromEnd: 0)
+  expectEqual(s[r], s.substring(with: r))
+  expectEqual(s[...][r], s[...].substring(with: r))
+  expectEqual(s[1, 0][r], s[1, 0].substring(with: r))
+}
+
+runAllTests()
diff --git a/test/stdlib/NSStringAPI.swift b/test/stdlib/NSStringAPI.swift
index 72e4376..4d7d2a7 100644
--- a/test/stdlib/NSStringAPI.swift
+++ b/test/stdlib/NSStringAPI.swift
@@ -1,4 +1,4 @@
-// RUN: %target-run-simple-swift -swift-version 3
+// RUN: %target-run-simple-swift
 // REQUIRES: executable_test
 
 // REQUIRES: objc_interop
@@ -1144,9 +1144,11 @@
       for: s.index(s.startIndex, offsetBy: 8)..<s.index(s.startIndex, offsetBy: 10))])
 }
 
-func toIntRange(
-  _ string: String, _ maybeRange: Range<String.Index>?
-) -> Range<Int>? {
+func toIntRange<
+  S : StringProtocol
+>(
+  _ string: S, _ maybeRange: Range<String.Index>?
+) -> Range<Int>? where S.Index == String.Index, S.IndexDistance == Int {
   guard let range = maybeRange else { return nil }
 
   return
diff --git a/tools/SourceKit/include/SourceKit/Core/ProtocolUIDs.def b/tools/SourceKit/include/SourceKit/Core/ProtocolUIDs.def
index 8f019c7..b332d41 100644
--- a/tools/SourceKit/include/SourceKit/Core/ProtocolUIDs.def
+++ b/tools/SourceKit/include/SourceKit/Core/ProtocolUIDs.def
@@ -270,6 +270,7 @@
 KIND(ExprArray, "source.lang.swift.expr.array")
 KIND(ExprDictionary, "source.lang.swift.expr.dictionary")
 KIND(ExprObjectLiteral, "source.lang.swift.expr.object_literal")
+KIND(ExprTuple, "source.lang.swift.expr.tuple")
 KIND(StructureElemId, "source.lang.swift.structure.elem.id")
 KIND(StructureElemExpr, "source.lang.swift.structure.elem.expr")
 KIND(StructureElemInitExpr, "source.lang.swift.structure.elem.init_expr")
diff --git a/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp b/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp
index 3e7ad81..dfb75c6 100644
--- a/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp
+++ b/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp
@@ -421,6 +421,8 @@
       return KindExprDictionary;
     case SyntaxStructureKind::ObjectLiteralExpression:
       return KindExprObjectLiteral;
+    case SyntaxStructureKind::TupleExpression:
+      return KindExprTuple;
     case SyntaxStructureKind::Argument:
       return KindExprArg;
   }
diff --git a/tools/swift-ide-test/swift-ide-test.cpp b/tools/swift-ide-test/swift-ide-test.cpp
index e6f4d81..e2566ce 100644
--- a/tools/swift-ide-test/swift-ide-test.cpp
+++ b/tools/swift-ide-test/swift-ide-test.cpp
@@ -1090,6 +1090,7 @@
       case SyntaxStructureKind::DictionaryExpression: return "dictionary";
       case SyntaxStructureKind::ObjectLiteralExpression:
         return "object-literal-expression";
+      case SyntaxStructureKind::TupleExpression: return "tuple";
     }
     llvm_unreachable("unhandled tag?");
   }
diff --git a/utils/update-checkout-config.json b/utils/update-checkout-config.json
index 3371871..dfe8acf 100644
--- a/utils/update-checkout-config.json
+++ b/utils/update-checkout-config.json
@@ -116,8 +116,8 @@
             "repos": {
                 "llvm": "swift-4.1-branch",
                 "clang": "swift-4.1-branch",
-                "swift": "swift-4.1-branch",
-                "lldb": "upstream-with-swift",
+                "swift": "master",
+                "lldb": "swift-4.1-branch",
                 "cmark": "master",
                 "llbuild": "master",
                 "swiftpm": "master",
diff --git a/validation-test/compiler_crashers_2/sr-5836.swift b/validation-test/compiler_crashers_2_fixed/sr-5836.swift
similarity index 68%
rename from validation-test/compiler_crashers_2/sr-5836.swift
rename to validation-test/compiler_crashers_2_fixed/sr-5836.swift
index ffce9dd..740bd57 100644
--- a/validation-test/compiler_crashers_2/sr-5836.swift
+++ b/validation-test/compiler_crashers_2_fixed/sr-5836.swift
@@ -1,5 +1,4 @@
-// RUN: not --crash %target-typecheck-verify-swift
-// REQUIRES: asserts
+// RUN: not %target-typecheck-verify-swift
 
 extension Dictionary {
   func doSomething<T>() -> [T : Value] {
diff --git a/validation-test/stdlib/ArrayNew.swift.gyb b/validation-test/stdlib/ArrayNew.swift.gyb
index 6457a9a..bd7278a 100644
--- a/validation-test/stdlib/ArrayNew.swift.gyb
+++ b/validation-test/stdlib/ArrayNew.swift.gyb
@@ -447,8 +447,8 @@
 }
 
 ArrayTestSuite.test("BridgedFromObjC.Nonverbatim.ImmutableArrayIsCopied")
-  .xfail(.iOSAny("<rdar://problem/33926468>"))
-  .xfail(.tvOSAny("<rdar://problem/33926468>"))
+  .skip(.iOSAny("<rdar://problem/33926468>"))
+  .skip(.tvOSAny("<rdar://problem/33926468>"))
   .code {
   let nsa: NSArray = CustomImmutableNSArray(_privateInit: ())