Skip to content

Commit 44b7e58

Browse files
authored
---
yaml --- r: 278015 b: refs/heads/swift-5.1-old-llvm-branch c: 69ff99f h: refs/heads/master i: 278013: 5dd2b62 278011: d11bb64 278007: f058b5d 277999: a62e822 277983: 81ea717 277951: 8126195 277887: 6b022bc 277759: e00d65b 277503: c468e33
1 parent 70bf6e9 commit 44b7e58

File tree

143 files changed

+3399
-841
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+3399
-841
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-01-24-a: b6f62823aa5010b2ae53f15f72a57
12411241
refs/heads/marcrasi-astverifier-disable: 3fac766a23a77ebd0640296bfd7fc116ea60a4e0
12421242
refs/heads/revert-22227-a-tall-white-fountain-played: adfce60b2eaa54903ea189bed8a783bca609fa53
12431243
refs/heads/revert-22300-revert-22227-a-tall-white-fountain-played: 5f92040224df7dd4e618fdfb367349df64d8acad
1244-
refs/heads/swift-5.1-old-llvm-branch: fd9b6a12de02de4fe4ffb7191f174ccaaba83da6
1244+
refs/heads/swift-5.1-old-llvm-branch: 69ff99fbd57eeadbb42399e967669ddf126b621d
12451245
refs/heads/swift-5.1-branch: 8060872acb4105d9655e020fe047e1ebcd77d0fb
12461246
refs/tags/swift-4.2.2-RELEASE: e429d1f1aaf59e69d38207a96e56265c7f6fccec
12471247
refs/tags/swift-5.0-DEVELOPMENT-SNAPSHOT-2019-02-02-a: 3e5a03d32ff3b1e9af90d6c1198c14f938379a6e

branches/swift-5.1-old-llvm-branch/cmake/modules/AddSwift.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ endfunction()
3030
# Compute the library subdirectory to use for the given sdk and
3131
# architecture, placing the result in 'result_var_name'.
3232
function(compute_library_subdir result_var_name sdk arch)
33-
set("${result_var_name}" "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}" PARENT_SCOPE)
33+
if(sdk IN_LIST SWIFT_APPLE_PLATFORMS)
34+
set("${result_var_name}" "${SWIFT_SDK_${sdk}_LIB_SUBDIR}" PARENT_SCOPE)
35+
else()
36+
set("${result_var_name}" "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}" PARENT_SCOPE)
37+
endif()
3438
endfunction()
3539

3640
function(_compute_lto_flag option out_var)
@@ -1156,6 +1160,8 @@ function(_add_swift_library_single target name)
11561160
# Don't set PROPERTY COMPILE_FLAGS or LINK_FLAGS directly.
11571161
set(c_compile_flags ${SWIFTLIB_SINGLE_C_COMPILE_FLAGS})
11581162
set(link_flags ${SWIFTLIB_SINGLE_LINK_FLAGS})
1163+
1164+
set(library_search_subdir "${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_LIB_SUBDIR}")
11591165
set(library_search_directories
11601166
"${SWIFTLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}"
11611167
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFTLIB_SINGLE_SUBDIR}"
@@ -1300,6 +1306,7 @@ function(_add_swift_library_single target name)
13001306
if(target_static)
13011307
set_property(TARGET "${target_static}" APPEND_STRING PROPERTY
13021308
COMPILE_FLAGS " ${c_compile_flags}")
1309+
# FIXME: The fallback paths here are going to be dynamic libraries.
13031310
set(library_search_directories
13041311
"${SWIFTSTATICLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}"
13051312
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFTLIB_SINGLE_SUBDIR}"

branches/swift-5.1-old-llvm-branch/cmake/modules/SwiftSource.cmake

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ function(handle_swift_sources
6161
endif()
6262

6363
if(swift_sources)
64-
compute_library_subdir(SWIFTSOURCES_LIBRARY_SUBDIR
65-
"${SWIFTSOURCES_SDK}" "${SWIFTSOURCES_ARCHITECTURE}")
66-
set(objsubdir "/${SWIFTSOURCES_LIBRARY_SUBDIR}")
64+
set(objsubdir "/${SWIFTSOURCES_SDK}/${SWIFTSOURCES_ARCHITECTURE}")
6765

6866
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}${objsubdir}")
6967

@@ -255,6 +253,8 @@ function(_compile_swift_files
255253
"-nostdimport" "-parse-stdlib" "-module-name" "Swift")
256254
list(APPEND swift_flags "-Xfrontend" "-group-info-path"
257255
"-Xfrontend" "${GROUP_INFO_JSON_FILE}")
256+
else()
257+
list(APPEND swift_flags "-module-name" "${SWIFTFILE_MODULE_NAME}")
258258
endif()
259259

260260
# Force swift 5 mode for Standard Library.
@@ -313,19 +313,32 @@ function(_compile_swift_files
313313
list(APPEND swift_flags "-parse-as-library")
314314

315315
set(module_base "${module_dir}/${SWIFTFILE_MODULE_NAME}")
316+
if(SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
317+
set(specific_module_dir "${module_base}.swiftmodule")
318+
set(module_base "${module_base}.swiftmodule/${SWIFTFILE_ARCHITECTURE}")
319+
endif()
316320
set(module_file "${module_base}.swiftmodule")
321+
set(module_doc_file "${module_base}.swiftdoc")
322+
323+
# FIXME: These don't really belong inside the swiftmodule, but there's not
324+
# an obvious alternate place to put them.
317325
set(sib_file "${module_base}.Onone.sib")
318326
set(sibopt_file "${module_base}.O.sib")
319327
set(sibgen_file "${module_base}.sibgen")
320-
set(module_doc_file "${module_base}.swiftdoc")
321328

322329
if(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES)
323330
set(interface_file "${module_base}.swiftinterface")
324-
list(APPEND swift_flags "-emit-parseable-module-interface")
331+
list(APPEND swift_flags
332+
"-emit-parseable-module-interface-path" "${interface_file}")
325333
endif()
326334

327-
list(APPEND command_create_dirs
328-
COMMAND "${CMAKE_COMMAND}" -E make_directory "${module_dir}")
335+
if(SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
336+
list(APPEND command_create_dirs
337+
COMMAND "${CMAKE_COMMAND}" -E make_directory "${specific_module_dir}")
338+
else()
339+
list(APPEND command_create_dirs
340+
COMMAND "${CMAKE_COMMAND}" -E make_directory "${module_dir}")
341+
endif()
329342

330343
# If we have extra regexp flags, check if we match any of the regexps. If so
331344
# add the relevant flags to our swift_flags.
@@ -349,10 +362,15 @@ function(_compile_swift_files
349362
set(optional_arg "OPTIONAL")
350363
endif()
351364

352-
swift_install_in_component("${SWIFTFILE_INSTALL_IN_COMPONENT}"
353-
FILES ${module_outputs}
354-
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${library_subdir}"
355-
"${optional_arg}")
365+
if(SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
366+
swift_install_in_component("${SWIFTFILE_INSTALL_IN_COMPONENT}"
367+
DIRECTORY "${specific_module_dir}"
368+
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${library_subdir}")
369+
else()
370+
swift_install_in_component("${SWIFTFILE_INSTALL_IN_COMPONENT}"
371+
FILES ${module_outputs}
372+
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${library_subdir}")
373+
endif()
356374

357375
set(line_directive_tool "${SWIFT_SOURCE_DIR}/utils/line-directive")
358376
set(swift_compiler_tool "${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/swiftc")

branches/swift-5.1-old-llvm-branch/docs/SIL.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,6 +2937,7 @@ is_escaping_closure
29372937
```````````````````
29382938

29392939
::
2940+
29402941
sil-instruction ::= 'is_escaping_closure' sil-operand
29412942

29422943
%1 = is_escaping_closure %0 : $@callee_guaranteed () -> ()
@@ -2948,6 +2949,7 @@ true if it is.
29482949

29492950
copy_block
29502951
``````````
2952+
29512953
::
29522954

29532955
sil-instruction :: 'copy_block' sil-operand
@@ -2960,6 +2962,7 @@ if the block is copied from the stack to the heap.
29602962

29612963
copy_block_without_escaping
29622964
```````````````````````````
2965+
29632966
::
29642967

29652968
sil-instruction :: 'copy_block_without_escaping' sil-operand 'withoutEscaping' sil-operand

branches/swift-5.1-old-llvm-branch/docs/StandardLibraryProgrammersManual.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,65 @@ The standard library utilizes thread local storage (TLS) to cache expensive comp
171171
172172
See [ThreadLocalStorage.swift](https://github.com/apple/swift/blob/master/stdlib/public/core/ThreadLocalStorage.swift) for more details.
173173
174+
175+
## Working with Resilience
176+
177+
Maintaining ABI compatibility with previously released versions of the standard library makes things more complicated. This section details some of the extra rules to remember and patterns to use.
178+
179+
### The Curiously Recursive Inlinable Switch Pattern (CRISP)
180+
181+
When inlinable code switches over a non-frozen enum, it has to handle possible future cases (since it will be inlined into a module outside the standard library). You can see this in action with the implementation of `round(_:)` in FloatingPointTypes.swift.gyb, which takes a FloatingPointRoundingRule. It looks something like this:
182+
183+
```swift
184+
@_transparent
185+
public mutating func round(_ rule: FloatingPointRoundingRule) {
186+
switch rule {
187+
case .toNearestOrAwayFromZero:
188+
_value = Builtin.int_round_FPIEEE${bits}(_value)
189+
case .toNearestOrEven:
190+
_value = Builtin.int_rint_FPIEEE${bits}(_value)
191+
// ...
192+
@unknown default:
193+
self._roundSlowPath(rule)
194+
}
195+
}
196+
```
197+
198+
Making `round(_:)` inlinable but still have a default case is an attempt to get the best of both worlds: if the rounding rule is known at compile time, the call will compile down to a single instruction in optimized builds; and if it dynamically turns out to be a new kind of rounding rule added in Swift 25 (e.g. `.towardFortyTwo`), there's a fallback function, `_roundSlowPath(_:)`, that can handle it.
199+
200+
So what does `_roundSlowPath(_:)` look like? Well, it can't be inlinable, because that would defeat the purpose. It *could* just look like this:
201+
202+
```swift
203+
@usableFromInline
204+
internal mutating func _roundSlowPath(_ rule: FloatingPointRoundingRule) {
205+
switch rule {
206+
case .toNearestOrAwayFromZero:
207+
_value = Builtin.int_round_FPIEEE${bits}(_value)
208+
case .toNearestOrEven:
209+
_value = Builtin.int_rint_FPIEEE${bits}(_value)
210+
// ...
211+
}
212+
}
213+
```
214+
215+
...i.e. exactly the same as `round(_:)` but with no `default` case. That's guaranteed to be up to date if any new cases are added in the future. But it seems a little silly, since it's duplicating code that's in `round(_:)`. We *could* omit cases that have always existed, but there's a better answer:
216+
217+
```swift
218+
// Slow path for new cases that might have been inlined into an old
219+
// ABI-stable version of round(_:) called from a newer version. If this is
220+
// the case, this non-inlinable function will call into the _newer_ version
221+
// which _will_ support this rounding rule.
222+
@usableFromInline
223+
internal mutating func _roundSlowPath(_ rule: FloatingPointRoundingRule) {
224+
self.round(rule)
225+
}
226+
```
227+
228+
Because `_roundSlowPath(_:)` isn't inlinable, the version of `round(_:)` that gets called at run time will always be the version implemented in the standard library dylib. And since FloatingPointRoundingRule is *also* defined in the standard library, we know it'll never be out of sync with this version of `round(_:)`.
229+
230+
Maybe some day we'll have special syntax in the language to say "call this method without allowing inlining" to get the same effect, but for now, this Curiously Recursive Inlinable Switch Pattern allows for safe inlining of switches over non-frozen enums with less boilerplate than you might otherwise have. Not none, but less.
231+
232+
174233
## Productivity Hacks
175234

176235
### Be a Ninja

branches/swift-5.1-old-llvm-branch/include/swift/AST/Attr.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ DECL_ATTR(_private, PrivateImport,
387387
OnImport |
388388
UserInaccessible |
389389
NotSerialized, 82)
390+
SIMPLE_DECL_ATTR(_alwaysEmitIntoClient, AlwaysEmitIntoClient,
391+
OnVar | OnSubscript | OnAbstractFunction | UserInaccessible,
392+
83)
390393

391394
#undef TYPE_ATTR
392395
#undef DECL_ATTR_ALIAS

branches/swift-5.1-old-llvm-branch/include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4079,6 +4079,7 @@ ERROR(usable_from_inline_attr_in_protocol,none,
40794079
#define FRAGILE_FUNC_KIND \
40804080
"%select{a '@_transparent' function|" \
40814081
"an '@inlinable' function|" \
4082+
"an '@_alwaysEmitIntoClient' function|" \
40824083
"a default argument value|" \
40834084
"a property initializer in a '@_fixed_layout' type}"
40844085

@@ -4112,7 +4113,7 @@ NOTE(resilience_decl_declared_here,
41124113

41134114
ERROR(class_designated_init_inlinable_resilient,none,
41144115
"initializer for class %0 is "
4115-
"'%select{@_transparent|@inlinable|%error}1' and must "
4116+
"'%select{@_transparent|@inlinable|@_alwaysEmitIntoClient|%error}1' and must "
41164117
"delegate to another initializer", (Type, unsigned))
41174118

41184119
ERROR(attribute_invalid_on_stored_property,

branches/swift-5.1-old-llvm-branch/include/swift/Basic/NullablePtr.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ class NullablePtr {
6060
const T *getPtrOrNull() const { return Ptr; }
6161

6262
explicit operator bool() const { return Ptr; }
63+
64+
bool operator==(NullablePtr<T> &&other) const { return other.Ptr == Ptr; }
65+
66+
bool operator!=(NullablePtr<T> &&other) const { return !(*this == other); }
67+
68+
bool operator==(const T *other) const { return other == Ptr; }
69+
70+
bool operator!=(const T *other) const { return !(*this == other); }
6371
};
6472

6573
} // end namespace swift

branches/swift-5.1-old-llvm-branch/include/swift/FrontendTool/FrontendTool.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ class FrontendObserver {
4444
virtual void configuredCompiler(CompilerInstance &instance);
4545
};
4646

47+
namespace frontend {
48+
namespace utils {
49+
StringRef escapeForMake(StringRef raw, llvm::SmallVectorImpl<char> &buffer);
50+
}
51+
}
52+
4753
/// Perform all the operations of the frontend, exactly as if invoked
4854
/// with -frontend.
4955
///

branches/swift-5.1-old-llvm-branch/include/swift/IRGen/Linking.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ class LinkEntity {
158158
SwiftMetaclassStub,
159159

160160
/// A callback used by newer Objective-C runtimes to initialize class
161-
/// metadata for classes where doesClassMetadataRequireUpdate() is true
162-
/// but doesClassMetadataRequireInitialization() is false.
161+
/// metadata for classes where getClassMetadataStrategy() is equal to
162+
/// ClassMetadataStrategy::Update or ::FixedOrUpdate.
163163
ObjCMetadataUpdateFunction,
164164

165165
/// A class metadata base offset global variable. This stores the offset

branches/swift-5.1-old-llvm-branch/include/swift/Remote/MetadataReader.h

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -361,24 +361,21 @@ class MetadataReader {
361361
bool isObjC = false;
362362
bool isBridged = false;
363363

364-
// If we can determine the Objective-C class name, this is probably an
365-
// error existential with NSError-compatible layout.
366-
std::string ObjCClassName;
367-
if (readObjCClassName(*MetadataAddress, ObjCClassName)) {
368-
if (ObjCClassName == "__SwiftNativeNSError")
369-
isObjC = true;
370-
else
364+
auto Meta = readMetadata(*MetadataAddress);
365+
if (auto ClassMeta = dyn_cast<TargetClassMetadata<Runtime>>(Meta)) {
366+
if (ClassMeta->isPureObjC()) {
367+
// If we can determine the Objective-C class name, this is probably an
368+
// error existential with NSError-compatible layout.
369+
std::string ObjCClassName;
370+
if (readObjCClassName(*MetadataAddress, ObjCClassName)) {
371+
if (ObjCClassName == "__SwiftNativeNSError")
372+
isObjC = true;
373+
else
374+
isBridged = true;
375+
}
376+
} else {
371377
isBridged = true;
372-
} else {
373-
// Otherwise, we can check to see if this is a class metadata with the
374-
// kind value's least significant bit set, which indicates a pure
375-
// Swift class.
376-
auto Meta = readMetadata(*MetadataAddress);
377-
auto ClassMeta = dyn_cast<TargetClassMetadata<Runtime>>(Meta);
378-
if (!ClassMeta)
379-
return None;
380-
381-
isObjC = ClassMeta->isPureObjC();
378+
}
382379
}
383380

384381
if (isBridged) {

branches/swift-5.1-old-llvm-branch/include/swift/SIL/SILBuilder.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,27 @@ class SILBuilder {
716716
BeginBorrowInst(getSILDebugLocation(Loc), LV));
717717
}
718718

719+
SILValue emitLoadBorrowOperation(SILLocation loc, SILValue v) {
720+
if (!hasOwnership()) {
721+
return emitLoadValueOperation(loc, v,
722+
LoadOwnershipQualifier::Unqualified);
723+
}
724+
return createLoadBorrow(loc, v);
725+
}
726+
727+
SILValue emitBeginBorrowOperation(SILLocation loc, SILValue v) {
728+
if (!hasOwnership() ||
729+
v.getOwnershipKind().isCompatibleWith(ValueOwnershipKind::Guaranteed))
730+
return v;
731+
return createBeginBorrow(loc, v);
732+
}
733+
734+
void emitEndBorrowOperation(SILLocation loc, SILValue v) {
735+
if (!hasOwnership())
736+
return;
737+
createEndBorrow(loc, v);
738+
}
739+
719740
// Pass in an address or value, perform a begin_borrow/load_borrow and pass
720741
// the value to the passed in closure. After the closure has finished
721742
// executing, automatically insert the end_borrow. The closure can assume that

branches/swift-5.1-old-llvm-branch/include/swift/Sema/IDETypeChecking.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,28 @@ namespace swift {
161161
bool shouldPrintRequirement(ExtensionDecl *ED, StringRef Req);
162162
bool hasMergeGroup(MergeGroupKind Kind);
163163
};
164+
165+
/// Reported type for an expression. This expression is represented by offset
166+
/// length in the source buffer;
167+
struct ExpressionTypeInfo {
168+
169+
/// The start of the expression;
170+
uint32_t offset;
171+
172+
/// The length of the expression;
173+
uint32_t length;
174+
175+
/// The start of the printed type in a separately given string buffer.
176+
uint32_t typeOffset;
177+
178+
/// The length of the printed type
179+
uint32_t typeLength;
180+
};
181+
182+
/// Collect type information for every expression in \c SF; all types will
183+
/// be printed to \c OS.
184+
ArrayRef<ExpressionTypeInfo> collectExpressionType(SourceFile &SF,
185+
std::vector<ExpressionTypeInfo> &scratch, llvm::raw_ostream &OS);
164186
}
165187

166188
#endif

branches/swift-5.1-old-llvm-branch/include/swift/Serialization/ModuleFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5252
/// describe what change you made. The content of this comment isn't important;
5353
/// it just ensures a conflict if two people change the module format.
5454
/// Don't worry about adhering to the 80-column limit for this line.
55-
const uint16_t SWIFTMODULE_VERSION_MINOR = 473; // Last change: assign ownership qualifier
55+
const uint16_t SWIFTMODULE_VERSION_MINOR = 474; // Last change: @_alwaysEmitIntoClient
5656

5757
using DeclIDField = BCFixed<31>;
5858

0 commit comments

Comments
 (0)