Skip to content

Commit 61a5668

Browse files
committed
Merge branch 'master' of github.com:swiftwasm/swift into maxd/master-merge
# Conflicts: # test/stdlib/simd.swift.gyb
2 parents 4ffe726 + 1725ece commit 61a5668

File tree

347 files changed

+476
-47505
lines changed

Some content is hidden

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

347 files changed

+476
-47505
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Please make sure you use Python 2.x. Python 3.x is not supported currently.
108108

109109
#### macOS
110110

111-
To build for macOS, you need [Xcode 11.4](https://developer.apple.com/xcode/resources/).
111+
To build for macOS, you need [Xcode 12 beta](https://developer.apple.com/xcode/resources/).
112112
The required version of Xcode changes frequently, and is often a beta release.
113113
Check this document or the host information on <https://ci.swift.org> for the
114114
current required version.

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,11 @@ function (swift_benchmark_compile_archopts)
660660
"-m${triple_platform}-version-min=${ver}"
661661
"-lobjc"
662662
"-L${SWIFT_LIBRARY_PATH}/${BENCH_COMPILE_ARCHOPTS_PLATFORM}"
663+
"-L${sdk}/usr/lib/swift"
663664
"-Xlinker" "-rpath"
664665
"-Xlinker" "${SWIFT_LINK_RPATH}"
666+
"-Xlinker" "-rpath"
667+
"-Xlinker" "/usr/lib/swift"
665668
${bench_library_objects}
666669
${bench_driver_objects}
667670
${ld64_add_ast_path_opts}
@@ -694,7 +697,7 @@ function(swift_benchmark_compile)
694697
cmake_parse_arguments(SWIFT_BENCHMARK_COMPILE "" "PLATFORM" "" ${ARGN})
695698

696699
if(NOT SWIFT_BENCHMARK_BUILT_STANDALONE)
697-
set(stdlib_dependencies "swift")
700+
set(stdlib_dependencies "swift-frontend")
698701
foreach(stdlib_dependency ${UNIVERSAL_LIBRARY_NAMES_${SWIFT_BENCHMARK_COMPILE_PLATFORM}})
699702
string(FIND "${stdlib_dependency}" "Unittest" find_output)
700703
if("${find_output}" STREQUAL "-1")

include/swift/AST/Types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2885,6 +2885,10 @@ class AnyFunctionType : public TypeBase {
28852885

28862886
Param getWithoutLabel() const { return Param(Ty, Identifier(), Flags); }
28872887

2888+
Param withLabel(Identifier newLabel) const {
2889+
return Param(Ty, newLabel, Flags);
2890+
}
2891+
28882892
Param withType(Type newType) const { return Param(newType, Label, Flags); }
28892893

28902894
Param withFlags(ParameterTypeFlags flags) const {

include/swift/Basic/OptionSet.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <type_traits>
2323
#include <cstdint>
24+
#include <initializer_list>
2425

2526
namespace swift {
2627

@@ -58,6 +59,10 @@ class OptionSet {
5859
/// Create an option set with only the given option set.
5960
constexpr OptionSet(Flags flag) : Storage(static_cast<StorageType>(flag)) {}
6061

62+
/// Create an option set containing the given options.
63+
constexpr OptionSet(std::initializer_list<Flags> flags)
64+
: Storage(combineFlags(flags)) {}
65+
6166
/// Create an option set from raw storage.
6267
explicit constexpr OptionSet(StorageType storage) : Storage(storage) {}
6368

@@ -136,6 +141,14 @@ class OptionSet {
136141

137142
static void _checkResultTypeOperatorOr(...) {}
138143

144+
static constexpr StorageType
145+
combineFlags(const std::initializer_list<Flags> &flags) {
146+
OptionSet result;
147+
for (Flags flag : flags)
148+
result |= flag;
149+
return result.Storage;
150+
}
151+
139152
static_assert(!std::is_same<decltype(_checkResultTypeOperatorOr(Flags())),
140153
Flags>::value,
141154
"operator| should produce an OptionSet");

lib/AST/ImportCache.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,10 @@ ImportSet &ImportCache::getImportSet(const DeclContext *dc) {
179179
ModuleDecl::ImportedModule{ModuleDecl::AccessPathTy(), mod});
180180

181181
if (file) {
182-
ModuleDecl::ImportFilter importFilter;
183-
importFilter |= ModuleDecl::ImportFilterKind::Private;
184-
importFilter |= ModuleDecl::ImportFilterKind::ImplementationOnly;
185-
importFilter |= ModuleDecl::ImportFilterKind::SPIAccessControl;
186-
file->getImportedModules(imports, importFilter);
182+
file->getImportedModules(imports,
183+
{ModuleDecl::ImportFilterKind::Private,
184+
ModuleDecl::ImportFilterKind::ImplementationOnly,
185+
ModuleDecl::ImportFilterKind::SPIAccessControl});
187186
}
188187

189188
auto &result = getImportSet(ctx, imports);
@@ -265,11 +264,10 @@ ImportCache::getAllAccessPathsNotShadowedBy(const ModuleDecl *mod,
265264
ModuleDecl::ImportedModule{ModuleDecl::AccessPathTy(), currentMod});
266265

267266
if (auto *file = dyn_cast<FileUnit>(dc)) {
268-
ModuleDecl::ImportFilter importFilter;
269-
importFilter |= ModuleDecl::ImportFilterKind::Private;
270-
importFilter |= ModuleDecl::ImportFilterKind::ImplementationOnly;
271-
importFilter |= ModuleDecl::ImportFilterKind::SPIAccessControl;
272-
file->getImportedModules(stack, importFilter);
267+
file->getImportedModules(stack,
268+
{ModuleDecl::ImportFilterKind::Private,
269+
ModuleDecl::ImportFilterKind::ImplementationOnly,
270+
ModuleDecl::ImportFilterKind::SPIAccessControl});
273271
}
274272

275273
SmallVector<ModuleDecl::AccessPathTy, 4> accessPaths;

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,13 +1460,13 @@ struct ExplicitSwiftModuleLoader::Implementation {
14601460
for (auto &entry: *mapNode) {
14611461
auto key = getScalaNodeText(entry.getKey());
14621462
auto val = getScalaNodeText(entry.getValue());
1463-
if (key == "SwiftModule") {
1463+
if (key == "moduleName") {
14641464
moduleName = val;
1465-
} else if (key == "SwiftModulePath") {
1465+
} else if (key == "modulePath") {
14661466
result.modulePath = val;
1467-
} else if (key == "SwiftDocPath") {
1467+
} else if (key == "docPath") {
14681468
result.moduleDocPath = val;
1469-
} else if (key == "SwiftSourceInfoPath") {
1469+
} else if (key == "sourceInfoPath") {
14701470
result.moduleSourceInfoPath = val;
14711471
} else {
14721472
// Being forgiving for future fields.
@@ -1480,16 +1480,16 @@ struct ExplicitSwiftModuleLoader::Implementation {
14801480
}
14811481
// [
14821482
// {
1483-
// "SwiftModule": "A",
1484-
// "SwiftModulePath": "A.swiftmodule",
1485-
// "SwiftDocPath": "A.swiftdoc",
1486-
// "SwiftSourceInfoPath": "A.swiftsourceinfo"
1483+
// "moduleName": "A",
1484+
// "modulePath": "A.swiftmodule",
1485+
// "docPath": "A.swiftdoc",
1486+
// "sourceInfoPath": "A.swiftsourceinfo"
14871487
// },
14881488
// {
1489-
// "SwiftModule": "B",
1490-
// "SwiftModulePath": "B.swiftmodule",
1491-
// "SwiftDocPath": "B.swiftdoc",
1492-
// "SwiftSourceInfoPath": "B.swiftsourceinfo"
1489+
// "moduleName": "B",
1490+
// "modulePath": "B.swiftmodule",
1491+
// "docPath": "B.swiftdoc",
1492+
// "sourceInfoPath": "B.swiftsourceinfo"
14931493
// }
14941494
// ]
14951495
void parseSwiftExplicitModuleMap(StringRef fileName) {

lib/Frontend/ModuleInterfaceSupport.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,11 @@ static void printImports(raw_ostream &out,
100100
ModuleDecl *M) {
101101
// FIXME: This is very similar to what's in Serializer::writeInputBlock, but
102102
// it's not obvious what higher-level optimization would be factored out here.
103-
ModuleDecl::ImportFilter allImportFilter;
104-
allImportFilter |= ModuleDecl::ImportFilterKind::Public;
105-
allImportFilter |= ModuleDecl::ImportFilterKind::Private;
106-
allImportFilter |= ModuleDecl::ImportFilterKind::SPIAccessControl;
107-
108103
SmallVector<ModuleDecl::ImportedModule, 8> allImports;
109-
M->getImportedModules(allImports, allImportFilter);
104+
M->getImportedModules(allImports,
105+
{ModuleDecl::ImportFilterKind::Public,
106+
ModuleDecl::ImportFilterKind::Private,
107+
ModuleDecl::ImportFilterKind::SPIAccessControl});
110108
ModuleDecl::removeDuplicateImports(allImports);
111109
diagnoseScopedImports(M->getASTContext().Diags, allImports);
112110

lib/FrontendTool/ImportedModules.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,12 @@ bool swift::emitImportedModules(ASTContext &Context, ModuleDecl *mainModule,
7878
StringRef implicitHeaderPath = opts.ImplicitObjCHeaderPath;
7979
if (!implicitHeaderPath.empty()) {
8080
if (!clangImporter->importBridgingHeader(implicitHeaderPath, mainModule)) {
81-
ModuleDecl::ImportFilter importFilter;
82-
importFilter |= ModuleDecl::ImportFilterKind::Public;
83-
importFilter |= ModuleDecl::ImportFilterKind::Private;
84-
importFilter |= ModuleDecl::ImportFilterKind::ImplementationOnly;
85-
importFilter |= ModuleDecl::ImportFilterKind::SPIAccessControl;
86-
8781
SmallVector<ModuleDecl::ImportedModule, 16> imported;
8882
clangImporter->getImportedHeaderModule()->getImportedModules(
89-
imported, importFilter);
83+
imported, {ModuleDecl::ImportFilterKind::Public,
84+
ModuleDecl::ImportFilterKind::Private,
85+
ModuleDecl::ImportFilterKind::ImplementationOnly,
86+
ModuleDecl::ImportFilterKind::SPIAccessControl});
9087

9188
for (auto IM : imported) {
9289
if (auto clangModule = IM.importedModule->findUnderlyingClangModule())

lib/IDE/CodeCompletion.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,15 +2085,13 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
20852085
}
20862086

20872087
void collectImportedModules(llvm::StringSet<> &ImportedModules) {
2088-
ModuleDecl::ImportFilter ImportFilter;
2089-
ImportFilter |= ModuleDecl::ImportFilterKind::Public;
2090-
ImportFilter |= ModuleDecl::ImportFilterKind::Private;
2091-
ImportFilter |= ModuleDecl::ImportFilterKind::ImplementationOnly;
2092-
20932088
SmallVector<ModuleDecl::ImportedModule, 16> Imported;
20942089
SmallVector<ModuleDecl::ImportedModule, 16> FurtherImported;
2095-
CurrDeclContext->getParentSourceFile()->getImportedModules(Imported,
2096-
ImportFilter);
2090+
CurrDeclContext->getParentSourceFile()->getImportedModules(
2091+
Imported,
2092+
{ModuleDecl::ImportFilterKind::Public,
2093+
ModuleDecl::ImportFilterKind::Private,
2094+
ModuleDecl::ImportFilterKind::ImplementationOnly});
20972095
while (!Imported.empty()) {
20982096
ModuleDecl *MD = Imported.back().importedModule;
20992097
Imported.pop_back();
@@ -6365,13 +6363,12 @@ void CodeCompletionCallbacksImpl::doneParsing() {
63656363
Lookup.addModuleName(curModule);
63666364

63676365
// Add results for all imported modules.
6368-
ModuleDecl::ImportFilter ImportFilter;
6369-
ImportFilter |= ModuleDecl::ImportFilterKind::Public;
6370-
ImportFilter |= ModuleDecl::ImportFilterKind::Private;
6371-
ImportFilter |= ModuleDecl::ImportFilterKind::ImplementationOnly;
63726366
SmallVector<ModuleDecl::ImportedModule, 4> Imports;
63736367
auto *SF = CurDeclContext->getParentSourceFile();
6374-
SF->getImportedModules(Imports, ImportFilter);
6368+
SF->getImportedModules(
6369+
Imports, {ModuleDecl::ImportFilterKind::Public,
6370+
ModuleDecl::ImportFilterKind::Private,
6371+
ModuleDecl::ImportFilterKind::ImplementationOnly});
63756372

63766373
for (auto Imported : Imports) {
63776374
for (auto Import : namelookup::getAllImports(Imported.importedModule))

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,12 +1832,11 @@ void IRGenDebugInfoImpl::finalize() {
18321832

18331833
// Get the list of imported modules (which may actually be different
18341834
// from all ImportDecls).
1835-
ModuleDecl::ImportFilter ImportFilter;
1836-
ImportFilter |= ModuleDecl::ImportFilterKind::Public;
1837-
ImportFilter |= ModuleDecl::ImportFilterKind::Private;
1838-
ImportFilter |= ModuleDecl::ImportFilterKind::ImplementationOnly;
18391835
SmallVector<ModuleDecl::ImportedModule, 8> ModuleWideImports;
1840-
IGM.getSwiftModule()->getImportedModules(ModuleWideImports, ImportFilter);
1836+
IGM.getSwiftModule()->getImportedModules(
1837+
ModuleWideImports, {ModuleDecl::ImportFilterKind::Public,
1838+
ModuleDecl::ImportFilterKind::Private,
1839+
ModuleDecl::ImportFilterKind::ImplementationOnly});
18411840
for (auto M : ModuleWideImports)
18421841
if (!ImportedModules.count(M.importedModule))
18431842
DBuilder.createImportedModule(MainFile, getOrCreateModule(M), MainFile,

lib/Index/Index.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ class SourceFileOrModule {
125125

126126
void
127127
getImportedModules(SmallVectorImpl<ModuleDecl::ImportedModule> &Modules) const {
128-
ModuleDecl::ImportFilter ImportFilter;
129-
ImportFilter |= ModuleDecl::ImportFilterKind::Public;
130-
ImportFilter |= ModuleDecl::ImportFilterKind::Private;
131-
ImportFilter |= ModuleDecl::ImportFilterKind::ImplementationOnly;
128+
constexpr ModuleDecl::ImportFilter ImportFilter = {
129+
ModuleDecl::ImportFilterKind::Public,
130+
ModuleDecl::ImportFilterKind::Private,
131+
ModuleDecl::ImportFilterKind::ImplementationOnly};
132132

133133
if (auto *SF = SFOrMod.dyn_cast<SourceFile *>()) {
134134
SF->getImportedModules(Modules, ImportFilter);

lib/Index/IndexRecord.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,9 @@ emitDataForSwiftSerializedModule(ModuleDecl *module,
580580
unitWriter.addRecordFile(recordFile, *FE, isSystemModule, mod);
581581
}
582582

583-
ModuleDecl::ImportFilter importFilter;
584-
importFilter |= ModuleDecl::ImportFilterKind::Public;
585-
importFilter |= ModuleDecl::ImportFilterKind::Private;
586583
SmallVector<ModuleDecl::ImportedModule, 8> imports;
587-
module->getImportedModules(imports, importFilter);
584+
module->getImportedModules(imports, {ModuleDecl::ImportFilterKind::Public,
585+
ModuleDecl::ImportFilterKind::Private});
588586
StringScratchSpace moduleNameScratch;
589587
addModuleDependencies(imports, indexStorePath, indexSystemModules, skipStdlib,
590588
targetTriple, clangCI, diags, unitWriter,
@@ -621,13 +619,11 @@ recordSourceFileUnit(SourceFile *primarySourceFile, StringRef indexUnitToken,
621619
getModuleInfoFromOpaqueModule);
622620

623621
// Module dependencies.
624-
ModuleDecl::ImportFilter importFilter;
625-
importFilter |= ModuleDecl::ImportFilterKind::Public;
626-
importFilter |= ModuleDecl::ImportFilterKind::Private;
627-
importFilter |= ModuleDecl::ImportFilterKind::ImplementationOnly;
628-
629622
SmallVector<ModuleDecl::ImportedModule, 8> imports;
630-
primarySourceFile->getImportedModules(imports, importFilter);
623+
primarySourceFile->getImportedModules(
624+
imports, {ModuleDecl::ImportFilterKind::Public,
625+
ModuleDecl::ImportFilterKind::Private,
626+
ModuleDecl::ImportFilterKind::ImplementationOnly});
631627
StringScratchSpace moduleNameScratch;
632628
addModuleDependencies(imports, indexStorePath, indexSystemModules, skipStdlib,
633629
targetTriple, clangCI, diags, unitWriter,

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,17 @@ static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
436436
// not blocked by any other passes' optimizations, so do it early.
437437
P.addDifferentiabilityWitnessDevirtualizer();
438438

439-
// Strip ownership from non-transparent functions.
439+
// Strip ownership from non-transparent functions when we are not compiling
440+
// the stdlib module. When compiling the stdlib, we eliminate ownership on
441+
// these functions later with a nromal call to
442+
// P.addNonTransparentFunctionOwnershipModelEliminator().
443+
//
444+
// This is done so we can push ownership through the pass pipeline first for
445+
// the stdlib and then everything else.
446+
P.addNonStdlibNonTransparentFunctionOwnershipModelEliminator();
447+
448+
// We earlier eliminated ownership if we are not compiling the stdlib. Now
449+
// handle the stdlib functions.
440450
P.addNonTransparentFunctionOwnershipModelEliminator();
441451

442452
// Start by linking in referenced functions from other modules.

lib/Sema/CSApply.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2533,14 +2533,15 @@ namespace {
25332533
if (cs.getType(expr) && !cs.getType(expr)->hasTypeVariable())
25342534
return expr;
25352535

2536-
auto &ctx = cs.getASTContext();
2537-
25382536
// Figure out the type we're converting to.
25392537
auto openedType = cs.getType(expr);
25402538
auto type = simplifyType(openedType);
25412539
cs.setType(expr, type);
25422540

2543-
if (type->is<UnresolvedType>()) return expr;
2541+
if (type->is<UnresolvedType>())
2542+
return expr;
2543+
2544+
auto &ctx = cs.getASTContext();
25442545

25452546
Type conformingType = type;
25462547
if (auto baseType = conformingType->getOptionalObjectType()) {
@@ -2550,7 +2551,7 @@ namespace {
25502551
}
25512552

25522553
// Find the appropriate object literal protocol.
2553-
auto proto = TypeChecker::getLiteralProtocol(cs.getASTContext(), expr);
2554+
auto proto = TypeChecker::getLiteralProtocol(ctx, expr);
25542555
assert(proto && "Missing object literal protocol?");
25552556
auto conformance =
25562557
TypeChecker::conformsToProtocol(conformingType, proto, cs.DC);
@@ -2560,10 +2561,24 @@ namespace {
25602561

25612562
ConcreteDeclRef witness = conformance.getWitnessByName(
25622563
conformingType->getRValueType(), constrName);
2563-
if (!witness || !isa<AbstractFunctionDecl>(witness.getDecl()))
2564+
2565+
auto selectedOverload = solution.getOverloadChoiceIfAvailable(
2566+
cs.getConstraintLocator(expr, ConstraintLocator::ConstructorMember));
2567+
2568+
if (!selectedOverload)
25642569
return nullptr;
2570+
2571+
auto fnType =
2572+
simplifyType(selectedOverload->openedType)->castTo<FunctionType>();
2573+
2574+
auto newArg = coerceCallArguments(
2575+
expr->getArg(), fnType, witness,
2576+
/*applyExpr=*/nullptr, expr->getArgumentLabels(),
2577+
expr->hasTrailingClosure(),
2578+
cs.getConstraintLocator(expr, ConstraintLocator::ApplyArgument));
2579+
25652580
expr->setInitializer(witness);
2566-
expr->setArg(cs.coerceToRValue(expr->getArg()));
2581+
expr->setArg(newArg);
25672582
return expr;
25682583
}
25692584

lib/Sema/CSBindings.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,8 +1110,7 @@ bool TypeVariableBinding::attempt(ConstraintSystem &cs) const {
11101110
fix = SpecifyClosureParameterType::create(cs, dstLocator);
11111111
} else if (TypeVar->getImpl().isClosureResultType()) {
11121112
fix = SpecifyClosureReturnType::create(cs, dstLocator);
1113-
} else if (srcLocator->getAnchor() &&
1114-
isExpr<ObjectLiteralExpr>(srcLocator->getAnchor())) {
1113+
} else if (srcLocator->directlyAt<ObjectLiteralExpr>()) {
11151114
fix = SpecifyObjectLiteralTypeImport::create(cs, dstLocator);
11161115
} else if (srcLocator->isKeyPathRoot()) {
11171116
fix = SpecifyKeyPathRootType::create(cs, dstLocator);

0 commit comments

Comments
 (0)