Merge pull request #16578 from milseman/never_forgiv_never_inlin

[String] Drop many @inlinable annotations
diff --git a/stdlib/private/SwiftPrivate/IO.swift b/stdlib/private/SwiftPrivate/IO.swift
index 8f9d2d8..1a77350 100644
--- a/stdlib/private/SwiftPrivate/IO.swift
+++ b/stdlib/private/SwiftPrivate/IO.swift
@@ -26,15 +26,13 @@
   public mutating func getline() -> String? {
     if let newlineIndex =
       _buffer[0..<_bufferUsed].index(of: UInt8(Unicode.Scalar("\n").value)) {
-      let result = String._fromWellFormedUTF8CodeUnitSequence(
-        _buffer[0..<newlineIndex])
+      let result = String(decoding: _buffer[0..<newlineIndex], as: UTF8.self)
       _buffer.removeSubrange(0...newlineIndex)
       _bufferUsed -= newlineIndex + 1
       return result
     }
     if isEOF && _bufferUsed > 0 {
-      let result = String._fromWellFormedUTF8CodeUnitSequence(
-        _buffer[0..<_bufferUsed])
+      let result = String(decoding: _buffer[0..<_bufferUsed], as: UTF8.self)
       _buffer.removeAll()
       _bufferUsed = 0
       return result
diff --git a/stdlib/public/core/CString.swift b/stdlib/public/core/CString.swift
index d410528..dc1fabc 100644
--- a/stdlib/public/core/CString.swift
+++ b/stdlib/public/core/CString.swift
@@ -43,7 +43,6 @@
   ///     // Prints "Caf�"
   ///
   /// - Parameter cString: A pointer to a null-terminated UTF-8 code sequence.
-  @inlinable // FIXME(sil-serialize-all)
   public init(cString: UnsafePointer<CChar>) {
     self = _decodeValidCString(cString, repair: true)
   }
@@ -53,7 +52,6 @@
   ///
   /// This is identical to init(cString: UnsafePointer<CChar> but operates on an
   /// unsigned sequence of bytes.
-  @inlinable // FIXME(sil-serialize-all)
   public init(cString: UnsafePointer<UInt8>) {
     self = _decodeValidCString(cString, repair: true)
   }
@@ -84,7 +82,6 @@
   ///     // Prints "nil"
   ///
   /// - Parameter cString: A pointer to a null-terminated UTF-8 code sequence.
-  @inlinable // FIXME(sil-serialize-all)
   public init?(validatingUTF8 cString: UnsafePointer<CChar>) {
     guard let str = _decodeCString(cString, repair: false) else {
       return nil
@@ -134,7 +131,8 @@
   /// - Returns: A tuple with the new string and a Boolean value that indicates
   ///   whether any repairs were made. If `isRepairing` is `false` and an
   ///   ill-formed sequence is detected, this method returns `nil`.
-  @inlinable // FIXME(sil-serialize-all)
+  @_specialize(where Encoding == Unicode.UTF8)
+  @_specialize(where Encoding == Unicode.UTF16)
   public static func decodeCString<Encoding : _UnicodeEncoding>(
     _ cString: UnsafePointer<Encoding.CodeUnit>?,
     as encoding: Encoding.Type,
@@ -157,7 +155,6 @@
 /// From a non-`nil` `UnsafePointer` to a null-terminated string
 /// with possibly-transient lifetime, create a null-terminated array of 'C' char.
 /// Returns `nil` if passed a null pointer.
-@inlinable // FIXME(sil-serialize-all)
 public func _persistCString(_ p: UnsafePointer<CChar>?) -> [CChar]? {
   guard let s = p else {
     return nil
@@ -170,7 +167,6 @@
   return result
 }
 
-@inlinable
 internal func _decodeValidCString(
   _ cString: UnsafePointer<Int8>, repair: Bool
 ) -> String {
@@ -182,7 +178,6 @@
   }
 }
 
-@inlinable
 internal func _decodeValidCString(
   _ cString: UnsafePointer<UInt8>, repair: Bool
 ) -> String {
@@ -191,7 +186,6 @@
   return String._fromWellFormedUTF8CodeUnitSequence(bufPtr, repair: repair)
 }
 
-@inlinable
 internal func _decodeCString(
   _ cString: UnsafePointer<Int8>, repair: Bool
 ) -> String? {
@@ -203,7 +197,6 @@
   }
 }
 
-@inlinable
 internal func _decodeCString(
   _ cString: UnsafePointer<UInt8>, repair: Bool
 ) -> String? {
@@ -216,7 +209,6 @@
 /// the given pointer using the specified encoding.
 ///
 /// This internal helper takes the string length as an argument.
-@inlinable // FIXME(sil-serialize-all)
 internal func _decodeCString<Encoding : _UnicodeEncoding>(
   _ cString: UnsafePointer<Encoding.CodeUnit>,
   as encoding: Encoding.Type, length: Int,
diff --git a/stdlib/public/core/InputStream.swift b/stdlib/public/core/InputStream.swift
index 445cd39..6c145c8 100644
--- a/stdlib/public/core/InputStream.swift
+++ b/stdlib/public/core/InputStream.swift
@@ -26,7 +26,6 @@
 ///   or character combinations are preserved. The default is `true`.
 /// - Returns: The string of characters read from standard input. If EOF has
 ///   already been reached when `readLine()` is called, the result is `nil`.
-@inlinable // FIXME(sil-serialize-all)
 public func readLine(strippingNewline: Bool = true) -> String? {
   var linePtrVar: UnsafeMutablePointer<UInt8>?
   var readBytes = swift_stdlib_readLine_stdin(&linePtrVar)
@@ -66,7 +65,7 @@
     }
   }
   let result = String._fromUTF8CodeUnitSequence(
-    UnsafeMutableBufferPointer(start: linePtr, count: readBytes),
+    UnsafeBufferPointer(start: linePtr, count: readBytes),
     repair: true)!
   _stdlib_free(linePtr)
   return result
diff --git a/stdlib/public/core/Integers.swift.gyb b/stdlib/public/core/Integers.swift.gyb
index 9e13645..4ba8392 100644
--- a/stdlib/public/core/Integers.swift.gyb
+++ b/stdlib/public/core/Integers.swift.gyb
@@ -1827,6 +1827,10 @@
 
     let isNegative = Self.isSigned && self < (0 as Self)
     var value = magnitude
+
+    // TODO(FIXME JIRA): All current stdlib types fit in small. Use a stack
+    // buffer instead of an array on the heap.
+
     var result: [UInt8] = []
     while value != 0 {
       let (quotient, remainder) = _quotientAndRemainder(value)
@@ -1837,7 +1841,11 @@
     if isNegative {
       result.append(UInt8(("-" as Unicode.Scalar).value))
     }
-    return String._fromASCII(result.reversed())
+
+    result.reverse()
+    return result.withUnsafeBufferPointer {
+      return String._fromASCII($0)
+    }
   }
 
   /// A textual representation of this value.
diff --git a/stdlib/public/core/SmallString.swift b/stdlib/public/core/SmallString.swift
index a949907..a8e200c 100644
--- a/stdlib/public/core/SmallString.swift
+++ b/stdlib/public/core/SmallString.swift
@@ -129,7 +129,7 @@
 
   @inlinable
   public // @testable
-  init?<C: RandomAccessCollection>(_ codeUnits: C) where C.Element == UInt8 {
+  init?(_ codeUnits: UnsafeBufferPointer<UInt8>) {
 #if arch(i386) || arch(arm)
     return nil // Never form small strings on 32-bit
 #else
@@ -137,13 +137,12 @@
     guard count <= _SmallUTF8String.capacity else { return nil }
     self.init()
     self._withAllUnsafeMutableBytes { rawBufPtr in
-      let bufPtr = UnsafeMutableBufferPointer(
-        start: rawBufPtr.baseAddress.unsafelyUnwrapped.assumingMemoryBound(
-          to: UInt8.self),
-        count: rawBufPtr.count)
-      var (itr, written) = codeUnits._copyContents(initializing: bufPtr)
-      _sanityCheck(itr.next() == nil)
-      _sanityCheck(count == written)
+      let rawDst = rawBufPtr.baseAddress._unsafelyUnwrappedUnchecked
+      memcpy_(
+        dst: rawDst.assumingMemoryBound(to: UInt8.self),
+        src: codeUnits.baseAddress._unsafelyUnwrappedUnchecked,
+        count: count
+      )
     }
     _sanityCheck(self.count == 0, "overwrote count early?")
     self.count = count
@@ -154,6 +153,20 @@
     _invariantCheck()
 #endif
   }
+
+  @inlinable
+  public // @testable
+  init?(_ scalar: Unicode.Scalar) {
+#if arch(i386) || arch(arm)
+    return nil // Never form small strings on 32-bit
+#else
+    // FIXME: support transcoding
+    guard scalar.value <= 0x7F else { return nil }
+    self.init()
+    self.count = 1
+    self[0] = UInt8(truncatingIfNeeded: scalar.value)
+#endif
+  }
 }
 
 //
diff --git a/stdlib/public/core/String.swift b/stdlib/public/core/String.swift
index 39fdde4..4401e16 100644
--- a/stdlib/public/core/String.swift
+++ b/stdlib/public/core/String.swift
@@ -625,38 +625,46 @@
   }
 }
 
+internal func _isAllASCII(_ input: UnsafeBufferPointer<UInt8>) -> Bool {
+  for byte in input {
+    guard byte <= 0x7F else { return false }
+  }
+  return true
+}
+
 extension String {
-  @inlinable
-  static func _fromUTF8CodeUnitSequence<C : RandomAccessCollection>(
-    _ input: C, repair: Bool
-  ) -> String? where C.Element == UInt8 {
+  static func _fromUTF8CodeUnitSequence(
+    _ input: UnsafeBufferPointer<UInt8>, repair: Bool
+  ) -> String? {
+    if _isAllASCII(input) {
+      return _fromASCII(input)
+    }
+
     if let smol = _SmallUTF8String(input) {
       return String(_StringGuts(smol))
     }
+
     return String._fromCodeUnits(
       input, encoding: UTF8.self, repairIllFormedSequences: repair)
   }
 
-  @inlinable
-  static func _fromASCII<C : RandomAccessCollection>(
-    _ input: C
-  ) -> String where C.Element == UInt8 {
+  @usableFromInline
+  static func _fromASCII(_ input: UnsafeBufferPointer<UInt8>) -> String {
     if let smol = _SmallUTF8String(input) {
       return String(_StringGuts(smol))
     }
     let storage = _SwiftStringStorage<UInt8>.create(
       capacity: input.count, count: input.count)
-    var (itr, end) = input._copyContents(initializing: storage.usedBuffer)
-    _sanityCheck(itr.next() == nil)
-    _sanityCheck(end == storage.usedBuffer.endIndex)
+    _sanityCheck(storage.count == input.count)
+    storage.start.initialize(
+      from: input.baseAddress._unsafelyUnwrappedUnchecked, count: input.count)
     return String(_StringGuts(_large: storage))
   }
 
-  @inlinable // FIXME(sil-serialize-all)
-  public // FIXME: @usableFromInline, currently public because testing...
-  static func _fromWellFormedUTF8CodeUnitSequence<C : RandomAccessCollection>(
-    _ input: C, repair: Bool = false
-  ) -> String where C.Element == UTF8.CodeUnit {
+  @usableFromInline
+  static func _fromWellFormedUTF8CodeUnitSequence(
+    _ input: UnsafeBufferPointer<UInt8>, repair: Bool = false
+  ) -> String {
     return String._fromUTF8CodeUnitSequence(input, repair: repair)!
   }
 }
@@ -674,9 +682,7 @@
     //
     // TODO: All scalars are small
     if scalar.value <= 0x7f {
-      if let small = _SmallUTF8String(
-        Unicode.UTF8.encode(scalar)._unsafelyUnwrappedUnchecked
-      ) {
+      if let small = _SmallUTF8String(scalar) {
         self = String(_StringGuts(small))
         return
       } else {
@@ -893,7 +899,6 @@
   ///     // Prints "Hello, friend"
   ///
   /// - Parameter other: Another string.
-  @inlinable // FIXME(sil-serialize-all)
   public mutating func append(_ other: String) {
     self._guts.append(other._guts)
   }
@@ -969,12 +974,12 @@
   /// - Parameter separator: A string to insert between each of the elements
   ///   in this sequence. The default separator is an empty string.
   /// - Returns: A single, concatenated string.
-  @inlinable // FIXME(sil-serialize-all)
+  @_specialize(where Self == Array<Substring>)
+  @_specialize(where Self == Array<String>)
   public func joined(separator: String = "") -> String {
     return _joined(separator: separator)
   }
 
-  @inlinable // FIXME(sil-serialize-all)
   internal func _joined(separator: String = "") -> String {
     let separatorSize = separator._guts.count
     var width = separator._guts.byteWidth
@@ -1030,7 +1035,7 @@
   /// - Parameter separator: A string to insert between each of the elements
   ///   in this sequence. The default separator is an empty string.
   /// - Returns: A single, concatenated string.
-  @inlinable // FIXME(sil-serialize-all)
+  @_specialize(where Self == Array<String>)
   public func joined(separator: String = "") -> String {
     return _joined(separator: separator)
   }
@@ -1045,7 +1050,6 @@
 @_silgen_name("swift_stdlib_NSStringUppercaseString")
 internal func _stdlib_NSStringUppercaseString(_ str: AnyObject) -> _CocoaString
 #else
-@inlinable // FIXME(sil-serialize-all)
 internal func _nativeUnicodeLowercaseString(_ str: String) -> String {
 
   // TODO (TODO: JIRA): check for small
@@ -1076,7 +1080,6 @@
   return String(_largeStorage: storage)
 }
 
-@inlinable // FIXME(sil-serialize-all)
 @usableFromInline // FIXME(sil-serialize-all)
 internal func _nativeUnicodeUppercaseString(_ str: String) -> String {
 
@@ -1146,7 +1149,6 @@
   /// - Returns: A lowercase copy of the string.
   ///
   /// - Complexity: O(*n*)
-  @inlinable // FIXME(sil-serialize-all)
   public func lowercased() -> String {
     if _guts.isASCII {
       var guts = _guts
@@ -1194,7 +1196,6 @@
   /// - Returns: An uppercase copy of the string.
   ///
   /// - Complexity: O(*n*)
-  @inlinable // FIXME(sil-serialize-all)
   public func uppercased() -> String {
     if _guts.isASCII {
       var guts = _guts
diff --git a/stdlib/public/core/StringCharacterView.swift b/stdlib/public/core/StringCharacterView.swift
index 6c5e87c..db48e4a 100644
--- a/stdlib/public/core/StringCharacterView.swift
+++ b/stdlib/public/core/StringCharacterView.swift
@@ -330,7 +330,6 @@
   ///   to allocate.
   ///
   /// - Complexity: O(*n*), where *n* is the capacity being reserved.
-  @inlinable // FIXME(sil-serialize-all)
   public mutating func reserveCapacity(_ n: Int) {
     _base.reserveCapacity(n)
   }
@@ -338,7 +337,6 @@
   /// Appends the given character to the character view.
   ///
   /// - Parameter c: The character to append to the character view.
-  @inlinable // FIXME(sil-serialize-all)
   public mutating func append(_ c: Character) {
     _base.append(c)
   }
@@ -368,7 +366,6 @@
   ///
   /// - Complexity: O(*n*) if the underlying string is bridged from
   ///   Objective-C, where *n* is the length of the string; otherwise, O(1).
-  @inlinable // FIXME(sil-serialize-all)
   @available(swift, deprecated: 3.2, message:
     "Please use String or Substring directly")
   public subscript(bounds: Range<Index>) -> String.CharacterView {
diff --git a/stdlib/public/core/StringGuts.swift b/stdlib/public/core/StringGuts.swift
index fc667c5..c12a3f8 100644
--- a/stdlib/public/core/StringGuts.swift
+++ b/stdlib/public/core/StringGuts.swift
@@ -625,6 +625,8 @@
   // Use the existing buffer if possible; otherwise copy the string into a
   // new buffer.
   @usableFromInline
+  @_specialize(where CodeUnit == UInt8)
+  @_specialize(where CodeUnit == UInt16)
   internal
   func _extractNativeStorage<CodeUnit>(
     of codeUnit: CodeUnit.Type = CodeUnit.self
@@ -637,7 +639,6 @@
     return _copyToNativeStorage(of: CodeUnit.self, from: 0..<count)
   }
 
-  @inlinable
   @_specialize(where CodeUnit == UInt8)
   @_specialize(where CodeUnit == UInt16)
   internal
@@ -655,8 +656,7 @@
     return storage
   }
 
-  @inlinable
-  public // @testable
+  @usableFromInline // @testable
   func _extractSlice(_ range: Range<Int>) -> _StringGuts {
     if range.isEmpty { return _StringGuts() }
     if range == 0..<count { return self }
@@ -686,7 +686,6 @@
       _large: _copyToNativeStorage(of: UTF16.CodeUnit.self, from: range))
   }
 
-  @inlinable
   internal mutating func allocationParametersForMutableStorage<CodeUnit>(
     of type: CodeUnit.Type,
     unusedCapacity: Int
@@ -717,7 +716,6 @@
 
   // Convert ourselves (if needed) to a native string with the specified storage
   // parameters and call `body` on the resulting native storage.
-  @inlinable
   internal
   mutating func withMutableStorage<CodeUnit, R>(
     of type: CodeUnit.Type = CodeUnit.self,
@@ -747,7 +745,6 @@
     return result
   }
 
-  @inlinable
   @inline(__always)
   internal
   mutating func withMutableASCIIStorage<R>(
@@ -758,7 +755,6 @@
       of: UInt8.self, unusedCapacity: unusedCapacity, body)
   }
 
-  @inlinable
   @inline(__always)
   internal
   mutating func withMutableUTF16Storage<R>(
@@ -804,16 +800,19 @@
   @usableFromInline
   internal
   var _nonStoredCount: Int {
-    if _object.isSmall {
-      return _object.smallUTF8Count
-    }
+    @effects(readonly)
+    get {
+      if _object.isSmall {
+        return _object.smallUTF8Count
+      }
 #if _runtime(_ObjC)
-    _sanityCheck(_object.isCocoa)
-    return _cocoaCount
+      _sanityCheck(_object.isCocoa)
+      return _cocoaCount
 #else
-    _sanityCheck(_object.isOpaque)
-    return _opaqueCount
+      _sanityCheck(_object.isOpaque)
+      return _opaqueCount
 #endif
+    }
   }
 
   @inlinable
@@ -887,7 +886,6 @@
 
 
   // Copy code units from a slice of this string into a buffer.
-  @inlinable // FIXME(sil-serialize-all)
   internal func _copy<CodeUnit>(
     range: Range<Int>,
     into dest: UnsafeMutableBufferPointer<CodeUnit>)
@@ -907,7 +905,6 @@
     }
   }
 
-  @usableFromInline // @opaque
   internal func _opaqueCopy<CodeUnit>(
     range: Range<Int>,
     into dest: UnsafeMutableBufferPointer<CodeUnit>)
@@ -923,8 +920,7 @@
     _asOpaque()[range]._copy(into: dest)
   }
 
-  @inlinable
-  public // TODO(StringGuts): for testing
+  @usableFromInline
   mutating func reserveUnusedCapacity(
     _ unusedCapacity: Int,
     ascii: Bool = false
@@ -955,8 +951,7 @@
     _invariantCheck()
   }
 
-  @inlinable
-  public // TODO(StringGuts): for testing
+  @usableFromInline // @testable
   mutating func reserveCapacity(_ capacity: Int) {
     if _fastPath(_isUniqueNative()) {
       if _fastPath(_object.nativeRawStorage.capacity >= capacity) {
@@ -982,7 +977,6 @@
     _invariantCheck()
   }
 
-  @inlinable
   internal
   mutating func append(_ other: _UnmanagedASCIIString) {
     guard other.count > 0 else { return  }
@@ -1004,7 +998,6 @@
     }
   }
 
-  @inlinable
   internal
   mutating func append(_ other: _UnmanagedUTF16String) {
     guard other.count > 0 else { return  }
@@ -1013,7 +1006,6 @@
     }
   }
 
-  @inlinable
   internal
   mutating func append(_ other: _UnmanagedOpaqueString) {
     guard other.count > 0 else { return  }
@@ -1022,13 +1014,13 @@
     }
   }
 
-  @inlinable
   internal
   mutating func append<S: StringProtocol>(_ other: S) {
     self.append(other._wholeString._guts, range: other._encodedOffsetRange)
   }
 
-  public // TODO(StringGuts): for testing only
+  @usableFromInline // @testable
+  internal
   mutating func append(_ other: _StringGuts) {
     // FIXME(TODO: JIRA): shouldn't _isEmptySingleton be sufficient?
     if _isEmptySingleton || self.count == 0 && !_object.isNative {
@@ -1053,7 +1045,6 @@
     }
   }
 
-  @usableFromInline // @opaque
   mutating func _opaqueAppend(opaqueOther other: _StringGuts) {
     if other._isSmall {
       // TODO: Fix the visitation pattern for append here. For now, we funnel
@@ -1069,8 +1060,8 @@
     self.append(other._asOpaque())
   }
 
-  @inlinable
-  public // TODO(StringGuts): for testing only
+  @usableFromInline
+  internal
   mutating func append(_ other: _StringGuts, range: Range<Int>) {
     _sanityCheck(range.lowerBound >= 0 && range.upperBound <= other.count)
     guard range.count > 0 else { return }
@@ -1091,7 +1082,6 @@
     }
   }
 
-  @usableFromInline // @opaque
   mutating func _opaqueAppend(opaqueOther other: _StringGuts, range: Range<Int>) {
     if other._isSmall {
       other._smallUTF8String.withUnmanagedASCII {
@@ -1109,8 +1099,8 @@
   // FIXME (TODO JIRA): Appending a character onto the end of a string should
   // really have a less generic implementation, then we can drop @specialize.
   //
+  @usableFromInline
   @_specialize(where C == Character._SmallUTF16)
-  @inlinable
   mutating func append<C : RandomAccessCollection>(contentsOf other: C)
   where C.Element == UInt16 {
     if self._isSmall {
@@ -1212,7 +1202,8 @@
     _invariantCheck()
   }
 
-  public mutating func replaceSubrange<C>(
+  @usableFromInline
+  mutating func replaceSubrange<C>(
     _ bounds: Range<Int>,
     with newElements: C
   ) where C : Collection, C.Element == UTF16.CodeUnit {
@@ -1295,16 +1286,13 @@
 
 extension _StringGuts {
   // TODO: Drop or unify with String._fromCodeUnits
-  //
-  @inlinable // FIXME(sil-serialize-all)
   internal
-  static func fromCodeUnits<Input : Sequence, Encoding : _UnicodeEncoding>(
-    _ input: Input,
+  static func fromCodeUnits<Encoding : _UnicodeEncoding>(
+    _ input: UnsafeBufferPointer<Encoding.CodeUnit>,
     encoding: Encoding.Type,
     repairIllFormedSequences: Bool,
     minimumCapacity: Int = 0
-  ) -> (_StringGuts?, hadError: Bool)
-  where Input.Element == Encoding.CodeUnit {
+  ) -> (_StringGuts?, hadError: Bool) {
     // Determine how many UTF-16 code units we'll need
     guard let (utf16Count, isASCII) = UTF16.transcodedLength(
       of: input.makeIterator(),
@@ -1343,10 +1331,9 @@
 extension _StringGuts {
   // For testing purposes only. Might be both inefficient and too low-level.
   // There should be an eventual API on String to accomplish something similar.
-  public // @_testable
-  static
-  func _createStringFromUTF16<C: RandomAccessCollection>(_ cus: C) -> String
-  where C.Element == UInt16 {
+  @usableFromInline // @_testable
+  static internal
+  func _createStringFromUTF16(_ cus: UnsafeBufferPointer<UInt16>) -> String {
     let storage = _SwiftStringStorage<UTF16.CodeUnit>.create(
       capacity: cus.count, count: cus.count)
     _ = storage._initialize(fromCodeUnits: cus, encoding: UTF16.self)
@@ -1362,13 +1349,11 @@
   /// Returns true iff `input` was found to contain invalid code units in the
   /// specified encoding. If any invalid sequences are found, they are replaced
   /// with REPLACEMENT CHARACTER (U+FFFD).
-  @inlinable // FIXME(sil-serialize-all)
   internal
-  func _initialize<Input : Sequence, Encoding: _UnicodeEncoding>(
-    fromCodeUnits input: Input,
+  func _initialize<Encoding: _UnicodeEncoding>(
+    fromCodeUnits input: UnsafeBufferPointer<Encoding.CodeUnit>,
     encoding: Encoding.Type
-  ) -> Bool
-  where Input.Element == Encoding.CodeUnit {
+  ) -> Bool {
     var p = self.start
     let hadError = transcode(
       input.makeIterator(),
diff --git a/stdlib/public/core/StringRangeReplaceableCollection.swift b/stdlib/public/core/StringRangeReplaceableCollection.swift
index 40f5efb..fe404b2 100644
--- a/stdlib/public/core/StringRangeReplaceableCollection.swift
+++ b/stdlib/public/core/StringRangeReplaceableCollection.swift
@@ -309,7 +309,6 @@
   ///   to allocate.
   ///
   /// - Complexity: O(*n*)
-  @inlinable // FIXME(sil-serialize-all)
   public mutating func reserveCapacity(_ n: Int) {
     _guts.reserveCapacity(n)
   }
@@ -324,7 +323,6 @@
   ///     // Prints "Globe 🌍"
   ///
   /// - Parameter c: The character to append to the string.
-  @inlinable // FIXME(sil-serialize-all)
   public mutating func append(_ c: Character) {
     if let small = c._smallUTF16 {
       _guts.append(contentsOf: small)
@@ -334,12 +332,10 @@
     }
   }
 
-  @inlinable // FIXME(sil-serialize-all)
   public mutating func append(contentsOf newElements: String) {
     append(newElements)
   }
 
-  @inlinable // FIXME(sil-serialize-all)
   public mutating func append(contentsOf newElements: Substring) {
     _guts.append(
       newElements._wholeString._guts,
diff --git a/stdlib/public/core/StringStorage.swift b/stdlib/public/core/StringStorage.swift
index 14ad3ed..5684407 100644
--- a/stdlib/public/core/StringStorage.swift
+++ b/stdlib/public/core/StringStorage.swift
@@ -198,7 +198,6 @@
 extension _SwiftStringStorage {
   // Append operations
 
-  @inlinable // TODO(inlinability): @usableFromInline - P3
   @nonobjc
   internal final func _appendInPlace<OtherCodeUnit>(
     _ other: _UnmanagedString<OtherCodeUnit>
@@ -210,7 +209,6 @@
     self.count += otherCount
   }
 
-  @inlinable // TODO(inlinability): @usableFromInline - P3
   @nonobjc
   internal final func _appendInPlace(_ other: _UnmanagedOpaqueString) {
     let otherCount = Int(other.count)
@@ -219,7 +217,6 @@
     self.count += otherCount
   }
 
-  @inlinable // TODO(inlinability): @usableFromInline - P3
   @nonobjc
   internal final func _appendInPlace<C: Collection>(contentsOf other: C)
   where C.Element == CodeUnit {
@@ -232,7 +229,6 @@
     count += otherCount
   }
 
-  @inlinable // TODO(inlinability): @usableFromInline - P3
   @_specialize(where C == Character._SmallUTF16, CodeUnit == UInt8)
   @nonobjc
   internal final func _appendInPlaceUTF16<C: Collection>(contentsOf other: C)
@@ -250,7 +246,6 @@
 }
 
 extension _SwiftStringStorage {
-  @inlinable
   @nonobjc
   internal final func _appendInPlace(_ other: _StringGuts, range: Range<Int>) {
     if _slowPath(other._isOpaque) {
@@ -281,7 +276,6 @@
     _appendInPlace(other._asOpaque()[range])
   }
 
-  @inlinable
   @nonobjc
   internal final func _appendInPlace(_ other: _StringGuts) {
     if _slowPath(other._isOpaque) {
@@ -310,13 +304,11 @@
     _appendInPlace(other._asOpaque())
   }
 
-  @inlinable
   @nonobjc
   internal final func _appendInPlace(_ other: String) {
     self._appendInPlace(other._guts)
   }
 
-  @inlinable
   @nonobjc
   internal final func _appendInPlace<S : StringProtocol>(_ other: S) {
     self._appendInPlace(
diff --git a/stdlib/public/core/StringUTF16.swift b/stdlib/public/core/StringUTF16.swift
index e99d7b7..5a97108 100644
--- a/stdlib/public/core/StringUTF16.swift
+++ b/stdlib/public/core/StringUTF16.swift
@@ -265,7 +265,6 @@
       self._guts = _guts
     }
 
-    @inlinable // FIXME(sil-serialize-all)
     public var description: String {
       return String(_guts._extractSlice(_encodedOffsetRange))
     }
diff --git a/stdlib/public/core/StringUTF8.swift b/stdlib/public/core/StringUTF8.swift
index 02a0c16..a52e0ed 100644
--- a/stdlib/public/core/StringUTF8.swift
+++ b/stdlib/public/core/StringUTF8.swift
@@ -357,7 +357,6 @@
   ///         print(strlen(ptr.baseAddress!))
   ///     }
   ///     // Prints "6"
-  @inlinable // FIXME(sil-serialize-all)
   public var utf8CString: ContiguousArray<CChar> {
     var result = ContiguousArray<CChar>()
     result.reserveCapacity(utf8.count + 1)
@@ -400,7 +399,6 @@
   /// slice of the `picnicGuest.utf8` view.
   ///
   /// - Parameter utf8: A UTF-8 code sequence.
-  @inlinable // FIXME(sil-serialize-all)
   @available(swift, deprecated: 3.2,
     message: "Failable initializer was removed in Swift 4. When upgrading to Swift 4, please use non-failable String.init(_:UTF8View)")
   @available(swift, obsoleted: 4.0,
@@ -698,7 +696,6 @@
     return String.UTF8View.SubSequence(self, _bounds: r)
   }
 
-  @inlinable // FIXME(sil-serialize-all)
   @available(swift, obsoleted: 4)
   public subscript(r: Range<Index>) -> String.UTF8View {
     let wholeString = String(_guts)
@@ -730,7 +727,6 @@
       legacyPartialCharacters: legacyPartialCharacters)
   }
 
-  @inlinable // FIXME(sil-serialize-all)
   @available(swift, obsoleted: 4)
   public subscript(bounds: ClosedRange<Index>) -> String.UTF8View {
     return self[bounds.relative(to: self)]
diff --git a/stdlib/public/core/StringUnicodeScalarView.swift b/stdlib/public/core/StringUnicodeScalarView.swift
index 18c7e52..d268845 100644
--- a/stdlib/public/core/StringUnicodeScalarView.swift
+++ b/stdlib/public/core/StringUnicodeScalarView.swift
@@ -264,7 +264,6 @@
       return String(_guts)
     }
 
-    @inlinable // FIXME(sil-serialize-all)
     public var debugDescription: String {
       return "StringUnicodeScalarView(\(self.description.debugDescription))"
     }
@@ -369,7 +368,6 @@
   ///   to allocate.
   ///
   /// - Complexity: O(*n*), where *n* is the capacity being reserved.
-  @inlinable // FIXME(sil-serialize-all)
   public mutating func reserveCapacity(_ n: Int) {
     _guts.reserveCapacity(n)
   }
@@ -377,7 +375,6 @@
   /// Appends the given Unicode scalar to the view.
   ///
   /// - Parameter c: The character to append to the string.
-  @inlinable // FIXME(sil-serialize-all)
   public mutating func append(_ c: Unicode.Scalar) {
     if _fastPath(_guts.isASCII && c.value <= 0x7f) {
       _guts.withMutableASCIIStorage(unusedCapacity: 1) { storage in
@@ -407,7 +404,6 @@
   /// - Parameter newElements: A sequence of Unicode scalar values.
   ///
   /// - Complexity: O(*n*), where *n* is the length of the resulting view.
-  @inlinable // FIXME(sil-serialize-all)
   public mutating func append<S : Sequence>(contentsOf newElements: S)
   where S.Element == Unicode.Scalar {
     // FIXME: Keep ASCII storage if possible
@@ -451,7 +447,6 @@
   ///   `newElements`. If the call to `replaceSubrange(_:with:)` simply
   ///   removes elements at the end of the string, the complexity is O(*n*),
   ///   where *n* is equal to `bounds.count`.
-  @inlinable // FIXME(sil-serialize-all)
   public mutating func replaceSubrange<C>(
     _ bounds: Range<Index>,
     with newElements: C
@@ -632,7 +627,6 @@
   ///
   /// - Complexity: O(*n*) if the underlying string is bridged from
   ///   Objective-C, where *n* is the length of the string; otherwise, O(1).
-  @inlinable // FIXME(sil-serialize-all)
   @available(swift, obsoleted: 4)
   public subscript(r: Range<Index>) -> String.UnicodeScalarView {
     let rawSubRange: Range<Int> =
diff --git a/stdlib/public/core/Substring.swift.gyb b/stdlib/public/core/Substring.swift.gyb
index b619c94..875c3e5 100644
--- a/stdlib/public/core/Substring.swift.gyb
+++ b/stdlib/public/core/Substring.swift.gyb
@@ -18,7 +18,6 @@
   ///   instance.
   ///
   /// - Complexity: O(*n*), where *n* is the length of `substring`.
-  @inlinable // FIXME(sil-serialize-all)
   public init(_ substring: Substring) {
     let wholeGuts = substring._wholeString._guts
     self.init(wholeGuts._extractSlice(substring._encodedOffsetRange))
diff --git a/stdlib/public/core/UnicodeParser.swift b/stdlib/public/core/UnicodeParser.swift
index 8fba40f..444a633 100644
--- a/stdlib/public/core/UnicodeParser.swift
+++ b/stdlib/public/core/UnicodeParser.swift
@@ -133,51 +133,3 @@
     }
   }
 }
-
-/*
-extension Unicode {
-  @_fixed_layout
-  @usableFromInline
-  internal struct _TranscodingIterator<
-    SourceCodeUnits : IteratorProtocol,
-    Parser : Unicode.Parser,
-    TargetEncoding : Unicode.Encoding
-  > where Parser.Encoding.CodeUnit == SourceCodeUnits.Element {
-    
-    @inline(__always)
-    @inlinable
-    public init(source: SourceCodeUnits, parser: Parser) {
-      _scalars = _ParsingIterator(codeUnits: source, parser: parser)
-      let firstScalar_ = _scalars.next()
-      if _fastPath(firstScalar_ != nil), let firstScalar = firstScalar_ {
-        _codeUnits = TargetEncoding._transcode(
-          firstScalar, from: Parser.Encoding.self).makeIterator()
-      }
-      else {
-        _codeUnits = TargetEncoding._encode(
-          UnicodeScalar(_unchecked: 0)).makeIterator()
-        while _codeUnits.next() != nil {  }
-        return
-      }
-    }
-
-    internal var _scalars: _ParsingIterator<SourceCodeUnits, Parser>
-    internal var _codeUnits: TargetEncoding.EncodedScalar.Iterator
-  }
-}
-
-
-extension Unicode._TranscodingIterator : IteratorProtocol, Sequence {
-  @inline(__always)
-  @inlinable
-  mutating public func next() -> TargetEncoding.CodeUnit? {
-    if let x = _codeUnits.next() { return x }
-    let nextScalar_ = _scalars.next()
-    if _fastPath(nextScalar_ != nil), let nextScalar = nextScalar_ {
-      _codeUnits = TargetEncoding._transcode(
-        nextScalar, from: Parser.Encoding.self).makeIterator()
-    }
-    return _codeUnits.next()
-  }
-}
-*/
diff --git a/stdlib/public/core/UnmanagedString.swift b/stdlib/public/core/UnmanagedString.swift
index d109c17..df7eaa2 100644
--- a/stdlib/public/core/UnmanagedString.swift
+++ b/stdlib/public/core/UnmanagedString.swift
@@ -55,6 +55,23 @@
   }
 }
 
+@inlinable
+@inline(__always)
+internal
+func memcpy_<
+  Source: FixedWidthInteger & UnsignedInteger
+>(
+  dst: UnsafeMutablePointer<Source>, src: UnsafePointer<Source>, count: Int
+) {
+  // Don't use the for-in-range syntax to avoid precondition checking in Range.
+  // This enables vectorization of the memcpy loop.
+  var i = 0
+  while i < count {
+    dst[i] = src[i]
+    i = i &+ 1
+  }
+}
+
 @_fixed_layout
 @usableFromInline
 internal
diff --git a/test/Sema/fixed_ambiguities/rdar35623181.swift b/test/Sema/fixed_ambiguities/rdar35623181.swift
index 39dbf53..834b8d9 100644
--- a/test/Sema/fixed_ambiguities/rdar35623181.swift
+++ b/test/Sema/fixed_ambiguities/rdar35623181.swift
@@ -1,6 +1,8 @@
-
 // RUN: %target-swift-frontend -emit-sil -verify %s | %FileCheck %s
 
+// XFAIL: *
+// ^ SR-7673
+
 extension Sequence where Element == String {
   func record() -> String {
     // CHECK: function_ref @$Ss20LazySequenceProtocolPsE3mapys0a3MapB0Vy8ElementsQzqd__Gqd__7ElementQzclF : $@convention(method) <τ_0_0 where τ_0_0 : LazySequenceProtocol><τ_1_0> (@guaranteed @callee_guaranteed (@in_guaranteed τ_0_0.Element) -> @out τ_1_0, @in_guaranteed τ_0_0) -> @out LazyMapSequence<τ_0_0.Elements, τ_1_0
diff --git a/test/stdlib/SmallString.swift b/test/stdlib/SmallString.swift
index 664542b..32512e5 100644
--- a/test/stdlib/SmallString.swift
+++ b/test/stdlib/SmallString.swift
@@ -41,6 +41,26 @@
   }
 }
 
+// Testing helper inits
+extension _SmallUTF8String {
+  init?(_ codeUnits: Array<UInt8>) {
+    guard let smol = codeUnits.withUnsafeBufferPointer({
+      return _SmallUTF8String($0)
+    }) else {
+      return nil
+    }
+    self = smol
+  }
+  init?(_ codeUnits: Array<UInt16>) {
+    guard let smol = codeUnits.withUnsafeBufferPointer({
+      return _SmallUTF8String($0)
+    }) else {
+      return nil
+    }
+    self = smol
+  }
+}
+
 SmallStringTests.test("FitsInSmall") {
   func runTest(_ input: String) throws {
     let tiny = Array(input.utf8)
@@ -68,6 +88,15 @@
   //
   expectThrows("Didn't fit", { try runTest("0123456789abcdef") })
   expectThrows("Didn't fit", { try runTest("👩‍👦‍👦") })
+
+  for cu in (0 as UInt32)...(0x10FFFF as UInt32) {
+    // TODO: Iterate over all scalars when we support UTF-8, and possibly move
+    // this to validation suite.
+    guard let scalar = Unicode.Scalar(cu) else { continue }
+    guard cu <= 0x7F else { break }
+    expectDoesNotThrow({ try runTest(String(scalar)) })
+  }
+
 }
 
 SmallStringTests.test("Bridging") {
diff --git a/validation-test/stdlib/String.swift b/validation-test/stdlib/String.swift
index b76dfe0..0b62a95 100644
--- a/validation-test/stdlib/String.swift
+++ b/validation-test/stdlib/String.swift
@@ -1102,7 +1102,7 @@
   ) {
     var chars = Array(String(initialValue).utf8)
     modification(&chars)
-    let str = String._fromWellFormedUTF8CodeUnitSequence(chars)
+    let str = String(decoding: chars, as: UTF8.self)
     expectNil(Int(str))
   }
 
diff --git a/validation-test/stdlib/StringViews.swift b/validation-test/stdlib/StringViews.swift
index 47b3c2b..55fff3f 100644
--- a/validation-test/stdlib/StringViews.swift
+++ b/validation-test/stdlib/StringViews.swift
@@ -9,7 +9,7 @@
 // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
 //
 //===----------------------------------------------------------------------===//
-// RUN: %target-run-simple-swift
+// RUN: %target-run-stdlib-swift
 // REQUIRES: executable_test
 
 import Swift
@@ -37,7 +37,10 @@
 // UTF16, grapheme clusters composed of multiple Unicode scalars, and
 // invalid UTF16 that should be replaced with replacement characters.
 let winterUTF16 = Array("🏂☃❅❆❄︎⛄️❄️".utf16) + [0xD83C, 0x0020, 0xDF67, 0xD83C]
-var winter = _StringGuts._createStringFromUTF16(winterUTF16)
+var winter = winterUTF16.withUnsafeBufferPointer { bufPtr in 
+  _StringGuts._createStringFromUTF16(bufPtr)
+}
+
 let winterInvalidUTF8: [UTF8.CodeUnit] = replacementUTF8 + ([0x20] as [UTF8.CodeUnit]) + replacementUTF8 + replacementUTF8
 let winterUTF8: [UTF8.CodeUnit] = [
   0xf0, 0x9f, 0x8f, 0x82, 0xe2, 0x98, 0x83, 0xe2, 0x9d, 0x85, 0xe2,