Skip to content

Commit 11fb5dc

Browse files
authored
---
yaml --- r: 343515 b: refs/heads/master-rebranch c: 3ddfcae h: refs/heads/master i: 343513: 6000b5a 343511: 49fbcf9
1 parent 99bb642 commit 11fb5dc

File tree

56 files changed

+882
-362
lines changed

Some content is hidden

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

56 files changed

+882
-362
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14551455
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14561456
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14571457
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1458-
refs/heads/master-rebranch: a09382ce2bae5051d0cded4a987ed2c05d1287bf
1458+
refs/heads/master-rebranch: 3ddfcae24b928d981e6bcd9b037bacf6a505ca0a
14591459
refs/heads/rdar-53901732: 9bd06af3284e18a109cdbf9aa59d833b24eeca7b
14601460
refs/heads/revert-26776-subst-always-returns-a-type: 1b8e18fdd391903a348970a4c848995d4cdd789c
14611461
refs/heads/tensorflow-merge: 8b854f62f80d4476cb383d43c4aac2001dde3cec

branches/master-rebranch/docs/ABI/Mangling.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,11 @@ Types
551551
type ::= assoc-type-name 'Qz' // shortcut for 'Qyz'
552552
type ::= assoc-type-list 'QY' GENERIC-PARAM-INDEX // associated type at depth
553553
type ::= assoc-type-list 'QZ' // shortcut for 'QYz'
554+
555+
#if SWIFT_RUNTIME_VERSION >= 5.2
556+
type ::= type assoc-type-name 'Qx' // associated type relative to base `type`
557+
type ::= type assoc-type-list 'QX' // associated type relative to base `type`
558+
#endif
554559

555560
protocol-list ::= protocol '_' protocol*
556561
protocol-list ::= empty-list

branches/master-rebranch/include/swift/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4338,7 +4338,7 @@ class ProtocolDecl final : public NominalTypeDecl {
43384338
/// with the Objective-C runtime.
43394339
StringRef getObjCRuntimeName(llvm::SmallVectorImpl<char> &buffer) const;
43404340

4341-
/// Create the generic parameters of this protocol if the haven't been
4341+
/// Create the generic parameters of this protocol if they haven't been
43424342
/// created yet.
43434343
void createGenericParamsIfMissing();
43444344

branches/master-rebranch/include/swift/Frontend/ParseableInterfaceModuleLoader.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,16 @@ class ParseableInterfaceModuleLoader : public SerializedModuleLoaderBase {
134134
DependencyTracker *tracker, ModuleLoadingMode loadMode,
135135
ArrayRef<std::string> PreferInterfaceForModules,
136136
bool RemarkOnRebuildFromInterface)
137-
: SerializedModuleLoaderBase(ctx, tracker, loadMode, PreferInterfaceForModules),
137+
: SerializedModuleLoaderBase(ctx, tracker, loadMode),
138138
CacheDir(cacheDir), PrebuiltCacheDir(prebuiltCacheDir),
139-
RemarkOnRebuildFromInterface(RemarkOnRebuildFromInterface)
139+
RemarkOnRebuildFromInterface(RemarkOnRebuildFromInterface),
140+
PreferInterfaceForModules(PreferInterfaceForModules)
140141
{}
141142

142143
std::string CacheDir;
143144
std::string PrebuiltCacheDir;
144145
bool RemarkOnRebuildFromInterface;
146+
ArrayRef<std::string> PreferInterfaceForModules;
145147

146148
std::error_code findModuleFilesInDirectory(
147149
AccessPathElem ModuleID, StringRef DirPath, StringRef ModuleFilename,
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
//===--- SILInstructionWorklist.h -------------------------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
///
13+
/// \file
14+
///
15+
/// When visiting the instructions in a function/basic block, one often modifies
16+
/// the list of instructions to be visited. That fact introduces complexity in
17+
/// the form of ensuring that no effort is wasted moving items down in the list
18+
/// when an item is removed from it and also in the form of ensuring that no
19+
/// instructions which have been modified/deleted are visited.
20+
///
21+
/// The SILInstructionWorklist manages that complexity. It is responsible for
22+
/// ensuring that removing an instruction is not unnecessarily expensive and
23+
/// that only valid instructions are removed from the list.
24+
///
25+
//===----------------------------------------------------------------------===//
26+
27+
#include "swift/SIL/SILInstruction.h"
28+
#include "swift/SIL/SILValue.h"
29+
#include "llvm/ADT/DenseMap.h"
30+
#include "llvm/ADT/SmallVector.h"
31+
32+
namespace swift {
33+
34+
/// Manages a list of instructions awaiting visitation.
35+
class SILInstructionWorklist final {
36+
llvm::SmallVector<SILInstruction *, 256> worklist;
37+
llvm::DenseMap<SILInstruction *, unsigned> worklistMap;
38+
StringRef loggingName;
39+
40+
void operator=(const SILInstructionWorklist &rhs) = delete;
41+
SILInstructionWorklist(const SILInstructionWorklist &worklist) = delete;
42+
43+
public:
44+
SILInstructionWorklist(const char *loggingName = "InstructionWorklist")
45+
: loggingName(loggingName) {}
46+
47+
/// Returns true if the worklist is empty.
48+
bool isEmpty() const { return worklist.empty(); }
49+
50+
/// Add the specified instruction to the worklist if it isn't already in it.
51+
void add(SILInstruction *instruction);
52+
53+
/// If the given ValueBase is a SILInstruction add it to the worklist.
54+
void addValue(ValueBase *value) {
55+
if (auto *instruction = value->getDefiningInstruction())
56+
add(instruction);
57+
}
58+
59+
/// Add the given list of instructions in reverse order to the worklist. This
60+
/// routine assumes that the worklist is empty and the given list has no
61+
/// duplicates.
62+
void addInitialGroup(ArrayRef<SILInstruction *> list);
63+
64+
// If instruction is in the worklist, remove it.
65+
void remove(SILInstruction *instruction) {
66+
auto iterator = worklistMap.find(instruction);
67+
if (iterator == worklistMap.end())
68+
return; // Not in worklist.
69+
70+
// Don't bother moving everything down, just null out the slot. We will
71+
// check before we process any instruction if it is null.
72+
worklist[iterator->second] = nullptr;
73+
worklistMap.erase(iterator);
74+
}
75+
76+
/// Remove the top element from the worklist.
77+
SILInstruction *removeOne() {
78+
SILInstruction *instruction = worklist.pop_back_val();
79+
worklistMap.erase(instruction);
80+
return instruction;
81+
}
82+
83+
/// When an instruction has been simplified, add all of its users to the
84+
/// worklist, since additional simplifications of its users may have been
85+
/// exposed.
86+
void addUsersToWorklist(ValueBase *instruction) {
87+
for (auto *use : instruction->getUses())
88+
add(use->getUser());
89+
}
90+
91+
void addUsersToWorklist(SILValue value) {
92+
for (auto *use : value->getUses())
93+
add(use->getUser());
94+
}
95+
96+
/// When an instruction has been simplified, add all of its users to the
97+
/// worklist, since additional simplifications of its users may have been
98+
/// exposed.
99+
void addUsersOfAllResultsToWorklist(SILInstruction *instruction) {
100+
for (auto result : instruction->getResults()) {
101+
addUsersToWorklist(result);
102+
}
103+
}
104+
105+
/// Check that the worklist is empty and nuke the backing store for the map if
106+
/// it is large.
107+
void zap() {
108+
assert(worklistMap.empty() && "Worklist empty, but the map is not?");
109+
110+
// Do an explicit clear, this shrinks the map if needed.
111+
worklistMap.clear();
112+
}
113+
};
114+
115+
} // end namespace swift

branches/master-rebranch/include/swift/Serialization/SerializedModuleLoader.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ class SerializedModuleLoaderBase : public ModuleLoader {
4242
protected:
4343
ASTContext &Ctx;
4444
ModuleLoadingMode LoadMode;
45-
ArrayRef<std::string> PreferInterfaceForModules;
4645
SerializedModuleLoaderBase(ASTContext &ctx, DependencyTracker *tracker,
47-
ModuleLoadingMode LoadMode,
48-
ArrayRef<std::string> PreferInterfaceForModules = {});
46+
ModuleLoadingMode LoadMode);
4947

5048
void collectVisibleTopLevelModuleNamesImpl(SmallVectorImpl<Identifier> &names,
5149
StringRef extension) const;

branches/master-rebranch/lib/AST/ASTMangler.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,9 @@ void ASTMangler::appendOpaqueDeclName(const OpaqueTypeDecl *opaqueDecl) {
736736
if (canSymbolicReference(opaqueDecl)) {
737737
appendSymbolicReference(opaqueDecl);
738738
} else if (auto namingDecl = opaqueDecl->getNamingDecl()) {
739+
CanGenericSignature savedSignature = CurGenericSignature;
739740
appendEntity(namingDecl);
741+
CurGenericSignature = savedSignature;
740742
appendOperator("QO");
741743
} else {
742744
llvm_unreachable("todo: independent opaque type decls");
@@ -1003,6 +1005,22 @@ void ASTMangler::appendType(Type type, const ValueDecl *forDecl) {
10031005

10041006
case TypeKind::NestedArchetype: {
10051007
auto nestedType = cast<NestedArchetypeType>(tybase);
1008+
1009+
// Mangle associated types of opaque archetypes like dependent member
1010+
// types, so that they can be accurately demangled at runtime.
1011+
if (auto opaque =
1012+
dyn_cast<OpaqueTypeArchetypeType>(nestedType->getRoot())) {
1013+
if (tryMangleTypeSubstitution(nestedType))
1014+
return;
1015+
1016+
appendType(opaque);
1017+
bool isAssocTypeAtDepth = false;
1018+
appendAssocType(nestedType->getInterfaceType(), isAssocTypeAtDepth);
1019+
appendOperator(isAssocTypeAtDepth ? "QX" : "Qx");
1020+
addTypeSubstitution(nestedType);
1021+
return;
1022+
}
1023+
10061024
appendType(nestedType->getParent());
10071025
appendIdentifier(nestedType->getName().str());
10081026
appendOperator("Qa");

branches/master-rebranch/lib/AST/ModuleNameLookup.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,8 @@ void ModuleNameLookup<LookupStrategy>::lookupInModule(
154154
resolutionKind == ResolutionKind::Overloadable) {
155155
// If we only found top-level functions, keep looking, since we may
156156
// find additional overloads.
157-
if (std::find_if(decls.begin() + initialCount, decls.end(),
158-
[](ValueDecl *VD) { return !isa<FuncDecl>(VD); })
159-
== decls.end())
157+
if (std::all_of(decls.begin() + initialCount, decls.end(),
158+
[](ValueDecl *VD) { return isa<FuncDecl>(VD); }))
160159
canReturnEarly = false;
161160
}
162161

branches/master-rebranch/lib/Basic/Platform.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget(const llvm::Triple &Triple){
351351
if (Major == 10) {
352352
if (Minor <= 14) {
353353
return llvm::VersionTuple(5, 0);
354+
} else if (Minor <= 15) {
355+
return llvm::VersionTuple(5, 1);
354356
} else {
355357
return None;
356358
}
@@ -361,13 +363,17 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget(const llvm::Triple &Triple){
361363
Triple.getiOSVersion(Major, Minor, Micro);
362364
if (Major <= 12) {
363365
return llvm::VersionTuple(5, 0);
366+
} else if (Major <= 13) {
367+
return llvm::VersionTuple(5, 1);
364368
} else {
365369
return None;
366370
}
367371
} else if (Triple.isWatchOS()) {
368372
Triple.getWatchOSVersion(Major, Minor, Micro);
369373
if (Major <= 5) {
370374
return llvm::VersionTuple(5, 0);
375+
} else if (Major <= 6) {
376+
return llvm::VersionTuple(5, 1);
371377
} else {
372378
return None;
373379
}

0 commit comments

Comments
 (0)