Skip to content

Commit 72dd69e

Browse files
committed
---
yaml --- r: 342010 b: refs/heads/rxwei-patch-1 c: 2cf9f09 h: refs/heads/master
1 parent 3084b28 commit 72dd69e

File tree

17 files changed

+143
-251
lines changed

17 files changed

+143
-251
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: 8c476c2a540f57c9038e922ee59808144644b191
1018+
refs/heads/rxwei-patch-1: 2cf9f09e2c4033414e14e53a67777bd5e0092691
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/benchmark/README.md

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ impacting changes, and run the benchmarks again. Upon benchmark completion, the
1414
benchmark results for the development branch will be compared to the most
1515
recent benchmark results for `master`.
1616

17-
## Building with build-script
17+
## Building the Swift Benchmarks
18+
19+
The swift benchmark suite currently supports building with CMake and
20+
SwiftPM. We support the following platforms respectively.
21+
22+
* CMake: macOS, iOS, tvOS, watchOS
23+
* SwiftPM: macOS, linux
24+
25+
We describe how to build both standalone and with build-script below.
26+
27+
### build-script invoking CMake
1828

1929
By default, Swift benchmarks for OS X are compiled during the Swift build
2030
process. To build Swift benchmarks for additional platforms, pass the following
@@ -30,7 +40,7 @@ drivers dynamically link Swift standard library dylibs from a path
3040
relative to their run-time location (../lib/swift) so the standard
3141
library should be distributed alongside them.
3242

33-
## Building Independently
43+
### CMake Standalone (no build-script)
3444

3545
To build the Swift benchmarks using only an Xcode installation: install an
3646
Xcode version with Swift support, install cmake 2.8.12, and ensure Xcode is
@@ -106,6 +116,56 @@ installed libraries instead, enable
106116
This will reflect the performance of the Swift standard library
107117
installed on the device, not the one included in the Swift root.
108118

119+
### build-script using SwiftPM+LLBuild
120+
121+
To build the benchmarks using build-script/swiftpm, one must build both
122+
swiftpm/llbuild as part of one's build and create a "just-built" toolchain. This
123+
toolchain is then used by build-script to compile the benchmarks. This is
124+
accomplished by passing to build-script the following options:
125+
126+
```
127+
swift-source$ swift/utils/build-script --swiftpm --llbuild --install-swift --install-swiftpm --install-llbuild --toolchain-benchmarks
128+
```
129+
130+
build-script will then compile the toolchain and then build the benchmarks 3
131+
times, once for each optimization level, at the path
132+
`./build/benchmarks-$PLATFORM-$ARCH/bin/Benchmark_$OPT`:
133+
134+
### Standalone SwiftPM/LLBuild
135+
136+
The benchmark suite can be built with swiftpm/llbuild without needing any help
137+
from build-script by invoking swift build in the benchmark directory:
138+
139+
```
140+
swift-source/swift/benchmark$ swift build -configuration release
141+
swift-source/swift/benchmark$ .build/release/SwiftBench
142+
#,TEST,SAMPLES,MIN(μs),MAX(μs),MEAN(μs),SD(μs),MEDIAN(μs)
143+
1,Ackermann,1,169,169,169,0,169
144+
2,AngryPhonebook,1,2044,2044,2044,0,2044
145+
...
146+
```
147+
148+
## Editing in Xcode
149+
150+
It is now possible to work on swiftpm benchmarks in Xcode! This is done by using
151+
the ability swiftpm build of the benchmarks to generate an xcodeproject. This is
152+
done by running the commands:
153+
154+
```
155+
swift-source/swift/benchmark$ swift package generate-xcodeproj
156+
generated: ./swiftbench.xcodeproj
157+
swift-source/swift/benchmark$ open swiftbench.xcodeproj
158+
```
159+
160+
Assuming that Xcode is installed on ones system, this will open the project in
161+
Xcode. The benchmark binary is built by the target 'SwiftBench'.
162+
163+
**NOTE: Files added to the Xcode project will not be persisted back to the
164+
package! To add new benchmarks follow the instructions from the section below!**
165+
166+
**NOTE: By default if one just builds/runs the benchmarks in Xcode, the
167+
benchmarks will be compiled with -Onone!**
168+
109169
## Using the Benchmark Driver
110170

111171
### Usage
@@ -159,20 +219,29 @@ of some benchmarks.
159219

160220
## Adding New Benchmarks
161221

162-
The harness generator supports both single and multiple file tests.
222+
Adding a new benchmark requires some boilerplate updates. To ease this (and
223+
document the behavior), a harness generator script is provided for both
224+
single/multiple file tests.
163225

164-
To add a new single file test, execute the following script with the new of the benchmark:
226+
To add a new single file test, execute the following script with the new of the
227+
benchmark:
165228

166229
```
167230
swift-source$ ./swift/benchmark/scripts/create_benchmark.py YourTestNameHere
168231
```
169232

170233
The script will automatically:
234+
171235
1. Add a new Swift file (`YourTestNameHere.swift`), built according to
172236
the template below, to the `single-source` directory.
173237
2. Add the filename of the new Swift file to `CMakeLists.txt`.
174238
3. Edit `main.swift` by importing and registering your new Swift module.
175239

240+
No changes are needed to the Package.swift file since the benchmark's
241+
Package.swift is set to dynamically lookup each Swift file in `single-source`
242+
and translate each of those individual .swift files into individual modules. So
243+
the new test file will be automatically found.
244+
176245
To add a new multiple file test:
177246

178247
1. Add a new directory and files under the `multi-source` directory as
@@ -193,6 +262,9 @@ To add a new multiple file test:
193262

194263
3. Edit `main.swift`. Import and register your new Swift module.
195264

265+
No changes are needed to the swiftpm build since it knows how to infer
266+
multi-source libraries automatically from the library structure.
267+
196268
**Note:**
197269

198270
The benchmark harness will execute the routine referenced by

branches/rxwei-patch-1/include/swift/AST/Decl.h

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4120,20 +4120,7 @@ class ProtocolDecl final : public NominalTypeDecl {
41204120
Bits.ProtocolDecl.RequiresClass = requiresClass;
41214121
}
41224122

4123-
/// Returns the cached result of \c existentialConformsToSelf or \c None if it
4124-
/// hasn't yet been computed.
4125-
Optional<bool> getCachedExistentialConformsToSelf() const {
4126-
if (Bits.ProtocolDecl.ExistentialConformsToSelfValid)
4127-
return Bits.ProtocolDecl.ExistentialConformsToSelf;
4128-
4129-
return None;
4130-
}
4131-
4132-
/// Caches the result of \c existentialConformsToSelf
4133-
void setCachedExistentialConformsToSelf(bool result) {
4134-
Bits.ProtocolDecl.ExistentialConformsToSelfValid = true;
4135-
Bits.ProtocolDecl.ExistentialConformsToSelf = result;
4136-
}
4123+
bool existentialConformsToSelfSlow();
41374124

41384125
bool existentialTypeSupportedSlow();
41394126

@@ -4147,7 +4134,6 @@ class ProtocolDecl final : public NominalTypeDecl {
41474134
friend class SuperclassTypeRequest;
41484135
friend class RequirementSignatureRequest;
41494136
friend class ProtocolRequiresClassRequest;
4150-
friend class ExistentialConformsToSelfRequest;
41514137
friend class TypeChecker;
41524138

41534139
public:
@@ -4218,7 +4204,13 @@ class ProtocolDecl final : public NominalTypeDecl {
42184204
/// This is only permitted if there is nothing "non-trivial" that we
42194205
/// can do with the metatype, which means the protocol must not have
42204206
/// any static methods and must be declared @objc.
4221-
bool existentialConformsToSelf() const;
4207+
bool existentialConformsToSelf() const {
4208+
if (Bits.ProtocolDecl.ExistentialConformsToSelfValid)
4209+
return Bits.ProtocolDecl.ExistentialConformsToSelf;
4210+
4211+
return const_cast<ProtocolDecl *>(this)
4212+
->existentialConformsToSelfSlow();
4213+
}
42224214

42234215
/// Does this protocol require a self-conformance witness table?
42244216
bool requiresSelfConformanceWitnessTable() const;

branches/rxwei-patch-1/include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4523,9 +4523,6 @@ WARNING(property_wrapper_init_initialValue,none,
45234523
())
45244524
ERROR(property_wrapper_projection_value_missing,none,
45254525
"could not find projection value property %0", (Identifier))
4526-
ERROR(property_wrapper_missing_arg_init, none, "missing argument for parameter "
4527-
"%0 in property wrapper initializer; add 'wrappedValue' and %0 "
4528-
"arguments in '@%1(...)'", (Identifier, StringRef))
45294526

45304527
//------------------------------------------------------------------------------
45314528
// MARK: function builder diagnostics

branches/rxwei-patch-1/include/swift/AST/TypeCheckRequests.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -201,32 +201,6 @@ class ProtocolRequiresClassRequest:
201201
void cacheResult(bool value) const;
202202
};
203203

204-
/// Determine whether an existential conforming to a protocol can be matched
205-
/// with a generic type parameter constrained to that protocol.
206-
class ExistentialConformsToSelfRequest:
207-
public SimpleRequest<ExistentialConformsToSelfRequest,
208-
bool(ProtocolDecl *),
209-
CacheKind::SeparatelyCached> {
210-
public:
211-
using SimpleRequest::SimpleRequest;
212-
213-
private:
214-
friend SimpleRequest;
215-
216-
// Evaluation.
217-
llvm::Expected<bool> evaluate(Evaluator &evaluator, ProtocolDecl *decl) const;
218-
219-
public:
220-
// Cycle handling.
221-
void diagnoseCycle(DiagnosticEngine &diags) const;
222-
void noteCycleStep(DiagnosticEngine &diags) const;
223-
224-
// Separate caching.
225-
bool isCached() const { return true; }
226-
Optional<bool> getCachedResult() const;
227-
void cacheResult(bool value) const;
228-
};
229-
230204
/// Determine whether the given declaration is 'final'.
231205
class IsFinalRequest :
232206
public SimpleRequest<IsFinalRequest,

branches/rxwei-patch-1/include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ SWIFT_TYPEID(EnumRawTypeRequest)
2020
SWIFT_TYPEID(OverriddenDeclsRequest)
2121
SWIFT_TYPEID(IsObjCRequest)
2222
SWIFT_TYPEID(ProtocolRequiresClassRequest)
23-
SWIFT_TYPEID(ExistentialConformsToSelfRequest)
2423
SWIFT_TYPEID(IsFinalRequest)
2524
SWIFT_TYPEID(IsDynamicRequest)
2625
SWIFT_TYPEID(RequirementRequest)

branches/rxwei-patch-1/lib/AST/Decl.cpp

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4329,9 +4329,43 @@ bool ProtocolDecl::requiresSelfConformanceWitnessTable() const {
43294329
return isSpecificProtocol(KnownProtocolKind::Error);
43304330
}
43314331

4332-
bool ProtocolDecl::existentialConformsToSelf() const {
4333-
return evaluateOrDefault(getASTContext().evaluator,
4334-
ExistentialConformsToSelfRequest{const_cast<ProtocolDecl *>(this)}, true);
4332+
bool ProtocolDecl::existentialConformsToSelfSlow() {
4333+
// Assume for now that the existential conforms to itself; this
4334+
// prevents circularity issues.
4335+
Bits.ProtocolDecl.ExistentialConformsToSelfValid = true;
4336+
Bits.ProtocolDecl.ExistentialConformsToSelf = true;
4337+
4338+
// If it's not @objc, it conforms to itself only if it has a
4339+
// self-conformance witness table.
4340+
if (!isObjC()) {
4341+
bool hasSelfConformance = requiresSelfConformanceWitnessTable();
4342+
Bits.ProtocolDecl.ExistentialConformsToSelf = hasSelfConformance;
4343+
return hasSelfConformance;
4344+
}
4345+
4346+
// Check whether this protocol conforms to itself.
4347+
for (auto member : getMembers()) {
4348+
if (member->isInvalid())
4349+
continue;
4350+
4351+
if (auto vd = dyn_cast<ValueDecl>(member)) {
4352+
if (!vd->isInstanceMember()) {
4353+
// A protocol cannot conform to itself if it has static members.
4354+
Bits.ProtocolDecl.ExistentialConformsToSelf = false;
4355+
return false;
4356+
}
4357+
}
4358+
}
4359+
4360+
// Check whether any of the inherited protocols fail to conform to
4361+
// themselves.
4362+
for (auto proto : getInheritedProtocols()) {
4363+
if (!proto->existentialConformsToSelf()) {
4364+
Bits.ProtocolDecl.ExistentialConformsToSelf = false;
4365+
return false;
4366+
}
4367+
}
4368+
return true;
43354369
}
43364370

43374371
/// Classify usages of Self in the given type.

branches/rxwei-patch-1/lib/AST/TypeCheckRequests.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -211,31 +211,6 @@ void ProtocolRequiresClassRequest::cacheResult(bool value) const {
211211
decl->setCachedRequiresClass(value);
212212
}
213213

214-
//----------------------------------------------------------------------------//
215-
// existentialConformsToSelf computation.
216-
//----------------------------------------------------------------------------//
217-
218-
void ExistentialConformsToSelfRequest::diagnoseCycle(DiagnosticEngine &diags) const {
219-
auto decl = std::get<0>(getStorage());
220-
diags.diagnose(decl, diag::circular_protocol_def, decl->getName());
221-
}
222-
223-
void ExistentialConformsToSelfRequest::noteCycleStep(DiagnosticEngine &diags) const {
224-
auto requirement = std::get<0>(getStorage());
225-
diags.diagnose(requirement, diag::kind_declname_declared_here,
226-
DescriptiveDeclKind::Protocol, requirement->getName());
227-
}
228-
229-
Optional<bool> ExistentialConformsToSelfRequest::getCachedResult() const {
230-
auto decl = std::get<0>(getStorage());
231-
return decl->getCachedExistentialConformsToSelf();
232-
}
233-
234-
void ExistentialConformsToSelfRequest::cacheResult(bool value) const {
235-
auto decl = std::get<0>(getStorage());
236-
decl->setCachedExistentialConformsToSelf(value);
237-
}
238-
239214
//----------------------------------------------------------------------------//
240215
// isFinal computation.
241216
//----------------------------------------------------------------------------//

branches/rxwei-patch-1/lib/IDE/ExprContextAnalysis.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -583,15 +583,6 @@ class ExprContextAnalyzer {
583583
case ExprKind::Array: {
584584
if (auto type = ParsedExpr->getType()) {
585585
recordPossibleType(type);
586-
break;
587-
}
588-
589-
// Check context types of the array literal expression.
590-
ExprContextInfo arrayCtxtInfo(DC, Parent);
591-
for (auto arrayT : arrayCtxtInfo.getPossibleTypes()) {
592-
if (auto boundGenericT = arrayT->getAs<BoundGenericType>())
593-
if (boundGenericT->getDecl() == Context.getArrayDecl())
594-
recordPossibleType(boundGenericT->getGenericArgs()[0]);
595586
}
596587
break;
597588
}

branches/rxwei-patch-1/lib/Sema/CSDiag.cpp

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3219,20 +3219,13 @@ class ArgumentMatcher : public MatchCallArgumentListener {
32193219

32203220
assert(insertLoc.isValid() && "missing argument after trailing closure?");
32213221

3222-
if (name.empty()) {
3222+
if (name.empty())
32233223
TC.diagnose(insertLoc, diag::missing_argument_positional,
32243224
missingParamIdx + 1)
32253225
.fixItInsert(insertLoc, insertText.str());
3226-
} else {
3227-
if (isPropertyWrapperImplicitInit()) {
3228-
auto TE = cast<TypeExpr>(FnExpr);
3229-
TC.diagnose(TE->getLoc(), diag::property_wrapper_missing_arg_init, name,
3230-
TE->getInstanceType()->getString());
3231-
} else {
3232-
TC.diagnose(insertLoc, diag::missing_argument_named, name)
3233-
.fixItInsert(insertLoc, insertText.str());
3234-
}
3235-
}
3226+
else
3227+
TC.diagnose(insertLoc, diag::missing_argument_named, name)
3228+
.fixItInsert(insertLoc, insertText.str());
32363229

32373230
auto candidate = CandidateInfo[0];
32383231
if (candidate.getDecl())
@@ -3242,27 +3235,6 @@ class ArgumentMatcher : public MatchCallArgumentListener {
32423235
Diagnosed = true;
32433236
}
32443237

3245-
bool isPropertyWrapperImplicitInit() {
3246-
auto TE = dyn_cast<TypeExpr>(FnExpr);
3247-
if (!TE)
3248-
return false;
3249-
3250-
auto instanceTy = TE->getInstanceType();
3251-
if (!instanceTy)
3252-
return false;
3253-
3254-
auto nominalDecl = instanceTy->getAnyNominal();
3255-
if (!(nominalDecl &&
3256-
nominalDecl->getAttrs().hasAttribute<PropertyWrapperAttr>()))
3257-
return false;
3258-
3259-
if (auto *parentExpr = CandidateInfo.CS.getParentExpr(FnExpr)) {
3260-
return parentExpr->isImplicit() && isa<CallExpr>(parentExpr);
3261-
}
3262-
3263-
return false;
3264-
}
3265-
32663238
bool missingLabel(unsigned paramIdx) override {
32673239
return false;
32683240
}

0 commit comments

Comments
 (0)