Skip to content

Commit 46a447a

Browse files
Merge pull request #2191 from swiftwasm/katei/merge-main-2020-11-11
Merge main 2020-11-11
2 parents f217db1 + b1ea7d8 commit 46a447a

File tree

86 files changed

+1674
-269
lines changed

Some content is hidden

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

86 files changed

+1674
-269
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ jobs:
129129
sudo xcode-select --switch /Applications/Xcode_12.2.app/Contents/Developer/
130130
xcodebuild -version
131131
./utils/webassembly/ci.sh
132+
env:
133+
SKIP_XCODE_VERSION_CHECK: 1 # Skip upstream update the compatible Xcode version
132134
- name: Upload macOS installable archive
133135
uses: actions/upload-artifact@v1
134136
with:

benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ set(SWIFT_BENCH_MODULES
9898
single-source/Hash
9999
single-source/Histogram
100100
single-source/HTTP2StateMachine
101+
single-source/IndexPathTest
101102
single-source/InsertCharacter
102103
single-source/IntegerParsing
103104
single-source/Integrate
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
//===--- IndexPathTest.swift ----------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 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+
import Foundation
14+
import TestsUtils
15+
16+
let size = 200
17+
let increasingIndexPath = indexPath(size)
18+
let decreasingIndexPath = indexPath(size, reversed: true)
19+
let increasingMaxMiddleIndexPath = indexPath(size, middle: size + 1)
20+
let increasingMinMiddleIndexPath = indexPath(size, middle: -1)
21+
let tags: [BenchmarkCategory] = [.validation, .api, .IndexPath]
22+
23+
public let IndexPathTest = [
24+
BenchmarkInfo(
25+
name: "IndexPath.Subscript.Mutation",
26+
runFunction: run_IndexPathSubscriptMutation,
27+
tags: tags,
28+
setUpFunction: { blackHole(increasingIndexPath) }),
29+
BenchmarkInfo(
30+
name: "IndexPath.Subscript.Range.Mutation",
31+
runFunction: run_IndexPathSubscriptRangeMutation,
32+
tags: tags,
33+
setUpFunction: { blackHole(increasingIndexPath) }),
34+
BenchmarkInfo(
35+
name: "IndexPath.Max",
36+
runFunction: run_IndexPathMax,
37+
tags: tags,
38+
setUpFunction: {
39+
blackHole(decreasingIndexPath)
40+
blackHole(increasingMaxMiddleIndexPath)
41+
blackHole(increasingIndexPath)
42+
}),
43+
BenchmarkInfo(
44+
name: "IndexPath.Min",
45+
runFunction: run_IndexPathMin,
46+
tags: tags,
47+
setUpFunction: {
48+
blackHole(increasingIndexPath)
49+
blackHole(increasingMinMiddleIndexPath)
50+
blackHole(decreasingIndexPath)
51+
}),
52+
]
53+
54+
func indexPath(_ size: Int, reversed: Bool = false) -> IndexPath {
55+
let indexes = Array(0..<size)
56+
return IndexPath(indexes: reversed ? indexes.reversed() : indexes)
57+
}
58+
59+
func indexPath(_ size: Int, middle: Int) -> IndexPath {
60+
var indexes = Array(0..<size)
61+
indexes.insert(middle, at: (indexes.count - 1) / 2)
62+
return IndexPath(indexes: indexes)
63+
}
64+
65+
// Subscript Mutations
66+
67+
@inline(__always)
68+
func subscriptMutation(
69+
n: Int,
70+
mutations: Int,
71+
indexPath: IndexPath,
72+
mutate: (inout IndexPath, Int) -> Void
73+
) {
74+
for _ in 0..<n {
75+
for i in 0..<mutations {
76+
var ip = indexPath
77+
mutate(&ip, i)
78+
}
79+
}
80+
}
81+
82+
@inline(never)
83+
public func run_IndexPathSubscriptMutation(_ n: Int) {
84+
subscriptMutation(
85+
n: n * 10, mutations: size, indexPath: increasingIndexPath,
86+
mutate: { ip, i in
87+
ip[i % 4] += 1
88+
})
89+
}
90+
91+
@inline(never)
92+
public func run_IndexPathSubscriptRangeMutation(_ n: Int) {
93+
subscriptMutation(
94+
n: n, mutations: size, indexPath: increasingIndexPath,
95+
mutate: { ip, i in
96+
ip[0..<i] += [i]
97+
})
98+
}
99+
100+
// Max
101+
102+
@inline(never)
103+
public func run_IndexPathMax(_ n: Int) {
104+
for _ in 0..<n * 10 {
105+
var val: Int?
106+
// Beginning max
107+
val = decreasingIndexPath.max()
108+
blackHole(val)
109+
// Middle max
110+
val = increasingMaxMiddleIndexPath.max()
111+
blackHole(val)
112+
// End max
113+
val = increasingIndexPath.max()
114+
blackHole(val)
115+
}
116+
}
117+
118+
// Min
119+
120+
@inline(never)
121+
public func run_IndexPathMin(_ n: Int) {
122+
for _ in 0..<n * 10 {
123+
var val: Int?
124+
// Beginning min
125+
val = increasingIndexPath.min()
126+
blackHole(val)
127+
// Middle min
128+
val = increasingMinMiddleIndexPath.min()
129+
blackHole(val)
130+
// End min
131+
val = decreasingIndexPath.min()
132+
blackHole(val)
133+
}
134+
}

benchmark/utils/TestsUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public enum BenchmarkCategory : String {
2323
// we know is important to measure.
2424
case validation
2525
// subsystems to validate and their subcategories.
26-
case api, Array, String, Dictionary, Codable, Set, Data
26+
case api, Array, String, Dictionary, Codable, Set, Data, IndexPath
2727
case sdk
2828
case runtime, refcount, metadata
2929
// Other general areas of compiled code validation.

benchmark/utils/main.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ import Hanoi
8686
import Hash
8787
import Histogram
8888
import HTTP2StateMachine
89+
import IndexPathTest
8990
import InsertCharacter
9091
import IntegerParsing
9192
import Integrate
@@ -274,6 +275,7 @@ registerBenchmark(Hanoi)
274275
registerBenchmark(HashTest)
275276
registerBenchmark(Histogram)
276277
registerBenchmark(HTTP2StateMachine)
278+
registerBenchmark(IndexPathTest)
277279
registerBenchmark(InsertCharacter)
278280
registerBenchmark(IntegerParsing)
279281
registerBenchmark(IntegrateTest)

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2758,12 +2758,8 @@ ERROR(conformance_from_implementation_only_module,none,
27582758
"the conformance is declared as SPI in %3|"
27592759
"the conformance is declared as SPI}4",
27602760
(Type, Identifier, unsigned, Identifier, unsigned))
2761-
ERROR(assoc_conformance_from_implementation_only_module,none,
2762-
"cannot use conformance of %0 to %1 in associated type %3 (inferred as "
2763-
"%4); %select{%2 has been imported as implementation-only|"
2764-
"the conformance is declared as SPI in %2|"
2765-
"the conformance is declared as SPI}5",
2766-
(Type, Identifier, Identifier, Type, Type, unsigned))
2761+
NOTE(assoc_conformance_from_implementation_only_module,none,
2762+
"in associated type %0 (inferred as %1)", (Type, Type))
27672763
ERROR(unexportable_clang_function_type,none,
27682764
"cannot export the underlying C type of the function type %0; "
27692765
"it may use anonymous types or types defined outside of a module",

include/swift/AST/PlatformKinds.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ AVAILABILITY_PLATFORM(macOSApplicationExtension, "application extensions for mac
3333
AVAILABILITY_PLATFORM(macCatalyst, "Mac Catalyst")
3434
AVAILABILITY_PLATFORM(macCatalystApplicationExtension, "application extensions for Mac Catalyst")
3535
AVAILABILITY_PLATFORM(OpenBSD, "OpenBSD")
36+
AVAILABILITY_PLATFORM(Windows, "Windows")
3637

3738
#undef AVAILABILITY_PLATFORM

include/swift/Basic/LangOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ namespace swift {
367367
/// TODO: remove this when @_implementationOnly modules are robust enough.
368368
bool AllowDeserializingImplementationOnly = false;
369369

370+
// Allow errors during module generation. See corresponding option in
371+
// FrontendOptions.
372+
bool AllowModuleWithCompilerErrors = false;
373+
370374
/// Sets the target we are building for and updates platform conditions
371375
/// to match.
372376
///

include/swift/Frontend/Frontend.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@ class CompilerInstance {
416416
std::unique_ptr<Lowering::TypeConverter> TheSILTypes;
417417
std::unique_ptr<DiagnosticVerifier> DiagVerifier;
418418

419+
/// A cache describing the set of inter-module dependencies that have been queried.
420+
/// Null if not present.
421+
std::unique_ptr<ModuleDependenciesCache> ModDepCache;
422+
419423
/// Null if no tracker.
420424
std::unique_ptr<DependencyTracker> DepTracker;
421425
/// If there is no stats output directory by the time the
@@ -487,6 +491,8 @@ class CompilerInstance {
487491
DependencyTracker *getDependencyTracker() { return DepTracker.get(); }
488492
const DependencyTracker *getDependencyTracker() const { return DepTracker.get(); }
489493

494+
ModuleDependenciesCache *getModuleDependencyCache() { return ModDepCache.get(); }
495+
490496
UnifiedStatsReporter *getStatsReporter() const { return Stats.get(); }
491497

492498
/// Retrieve the main module containing the files being compiled.
@@ -552,6 +558,7 @@ class CompilerInstance {
552558
bool setUpVirtualFileSystemOverlays();
553559
void setUpLLVMArguments();
554560
void setUpDiagnosticOptions();
561+
void setUpModuleDependencyCacheIfNeeded();
555562
bool setUpModuleLoaders();
556563
bool setUpInputs();
557564
bool setUpASTContextIfNeeded();

include/swift/Frontend/FrontendOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,12 @@ class FrontendOptions {
292292
/// any merge-modules jobs.
293293
bool EnableExperimentalCrossModuleIncrementalBuild = false;
294294

295+
/// Best effort to output a .swiftmodule regardless of any compilation
296+
/// errors. SIL generation and serialization is skipped entirely when there
297+
/// are errors. The resulting serialized AST may include errors types and
298+
/// skip nodes entirely, depending on the errors involved.
299+
bool AllowModuleWithCompilerErrors = false;
300+
295301
/// The different modes for validating TBD against the LLVM IR.
296302
enum class TBDValidationMode {
297303
Default, ///< Do the default validation for the current platform.

0 commit comments

Comments
 (0)