Skip to content

Commit e1914fc

Browse files
committed
---
yaml --- r: 349094 b: refs/heads/master c: d90117b h: refs/heads/master
1 parent 72e1905 commit e1914fc

28 files changed

+85
-246
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9a4abf47a450aeff6a3231225fd2cf18cc7a940a
2+
refs/heads/master: d90117bb8a7e953e080fbb3f6d22e5502e7aa51b
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/benchmark/scripts/run_smoke_bench

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,6 @@ def main():
9393
argparser.add_argument(
9494
'-num-samples', type=int,
9595
help='The (minimum) number of samples to run', default=3)
96-
argparser.add_argument(
97-
'-num-reruns', type=int,
98-
help="The number of re-runs until it's assumed to be a real change",
99-
default=8)
10096
argparser.add_argument(
10197
'-platform', type=str,
10298
help='The benchmark build platform', default='macosx')
@@ -124,7 +120,7 @@ def test_opt_levels(args):
124120
if test_performance(opt_level, args.oldbuilddir[0],
125121
args.newbuilddir[0],
126122
float(args.threshold) / 100, args.num_samples,
127-
args.num_reruns, output_file):
123+
output_file):
128124
changes = True
129125

130126
# There is no point in reporting code size for Onone.
@@ -175,7 +171,7 @@ def merge(results, other_results):
175171

176172

177173
def test_performance(opt_level, old_dir, new_dir, threshold, num_samples,
178-
num_reruns, output_file):
174+
output_file):
179175
"""Detect performance changes in benchmarks.
180176
181177
Start fast with few samples per benchmark and gradually spend more time
@@ -189,7 +185,7 @@ def test_performance(opt_level, old_dir, new_dir, threshold, num_samples,
189185
tests = TestComparator(results[0], results[1], threshold)
190186
changed = tests.decreased + tests.increased
191187

192-
while len(changed) > 0 and unchanged_length_count < num_reruns:
188+
while len(changed) > 0 and unchanged_length_count < 10:
193189
i += 1
194190
if VERBOSE:
195191
log(' test again: ' + str([test.name for test in changed]))

trunk/include/swift/SIL/MemoryLifetime.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@
2222

2323
namespace swift {
2424

25-
void printBitsAsArray(llvm::raw_ostream &OS, const SmallBitVector &bits);
26-
27-
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
28-
const SmallBitVector &bits) {
29-
printBitsAsArray(OS, bits);
30-
return OS;
31-
}
32-
33-
void dumpBits(const SmallBitVector &bits);
34-
3525
/// The MemoryLocations utility provides functions to analyze memory locations.
3626
///
3727
/// Memory locations are limited to addresses which are guaranteed to

trunk/lib/IRGen/GenCast.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -638,12 +638,8 @@ void irgen::emitScalarExistentialDowncast(IRGenFunction &IGF,
638638
bool checkSuperclassConstraint = false;
639639
if (hasSuperclassConstraint) {
640640
Type srcSuperclassType = srcInstanceType;
641-
if (srcSuperclassType->isExistentialType()) {
641+
if (srcSuperclassType->isExistentialType())
642642
srcSuperclassType = srcSuperclassType->getSuperclass();
643-
// Look for an AnyObject superclass (getSuperclass() returns nil).
644-
if (!srcSuperclassType && srcInstanceType->isClassExistentialType())
645-
checkSuperclassConstraint = true;
646-
}
647643
if (srcSuperclassType) {
648644
checkSuperclassConstraint =
649645
!destInstanceType->getSuperclass()->isExactSuperclassOf(

trunk/lib/SIL/MemoryLifetime.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,26 @@ llvm::cl::opt<bool> DontAbortOnMemoryLifetimeErrors(
2828
llvm::cl::desc("Don't abort compliation if the memory lifetime checker "
2929
"detects an error."));
3030

31+
namespace swift {
32+
namespace {
33+
34+
//===----------------------------------------------------------------------===//
35+
// Utility functions
36+
//===----------------------------------------------------------------------===//
37+
3138
/// Debug dump a location bit vector.
32-
void swift::printBitsAsArray(llvm::raw_ostream &OS, const SmallBitVector &bits) {
39+
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
40+
const SmallBitVector &bits) {
3341
const char *separator = "";
3442
OS << '[';
3543
for (int idx = bits.find_first(); idx >= 0; idx = bits.find_next(idx)) {
3644
OS << separator << idx;
3745
separator = ",";
3846
}
3947
OS << ']';
48+
return OS;
4049
}
4150

42-
void swift::dumpBits(const SmallBitVector &bits) {
43-
llvm::dbgs() << bits << '\n';
44-
}
45-
46-
namespace swift {
47-
namespace {
48-
49-
//===----------------------------------------------------------------------===//
50-
// Utility functions
51-
//===----------------------------------------------------------------------===//
52-
5351
/// Enlarge the bitset if needed to set the bit with \p idx.
5452
static void setBitAndResize(SmallBitVector &bits, unsigned idx) {
5553
if (bits.size() <= idx)
@@ -242,6 +240,10 @@ void MemoryLocations::dump() const {
242240
}
243241
}
244242

243+
void MemoryLocations::dumpBits(const Bits &bits) {
244+
llvm::errs() << bits << '\n';
245+
}
246+
245247
void MemoryLocations::clear() {
246248
locations.clear();
247249
addr2LocIdx.clear();

trunk/lib/SILOptimizer/Transforms/DeadStoreElimination.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
#include "swift/SIL/Projection.h"
6161
#include "swift/SIL/SILArgument.h"
6262
#include "swift/SIL/SILBuilder.h"
63-
#include "swift/SIL/MemoryLifetime.h"
6463
#include "swift/SILOptimizer/Analysis/AliasAnalysis.h"
6564
#include "swift/SILOptimizer/Analysis/PostOrderAnalysis.h"
6665
#include "swift/SILOptimizer/PassManager/Passes.h"
@@ -270,8 +269,6 @@ class BlockState {
270269
init(LocationNum, Optimistic);
271270
}
272271

273-
void dump();
274-
275272
/// Initialize the bitvectors for the current basic block.
276273
void init(unsigned LocationNum, bool Optimistic);
277274

@@ -451,8 +448,6 @@ enum class ProcessKind {
451448
llvm::SpecificBumpPtrAllocator<BlockState> &BPA)
452449
: Mod(M), F(F), PM(PM), AA(AA), TE(TE), EAFI(EAFI), BPA(BPA) {}
453450

454-
void dump();
455-
456451
/// Entry point for dead store elimination.
457452
bool run();
458453

@@ -486,12 +481,6 @@ enum class ProcessKind {
486481

487482
} // end anonymous namespace
488483

489-
void BlockState::dump() {
490-
llvm::dbgs() << " block " << BB->getDebugID() << ": in=" << BBWriteSetIn
491-
<< ", out=" << BBWriteSetOut << ", mid=" << BBWriteSetMid
492-
<< ", gen=" << BBGenSet << ", kill=" << BBKillSet << '\n';
493-
}
494-
495484
void BlockState::init(unsigned LocationNum, bool Optimistic) {
496485
// For function that requires just 1 iteration of the data flow to converge
497486
// we set the initial state of BBWriteSetIn to 0.
@@ -524,21 +513,6 @@ void BlockState::init(unsigned LocationNum, bool Optimistic) {
524513
BBDeallocateLocation.resize(LocationNum, false);
525514
}
526515

527-
#if __has_attribute(used)
528-
__attribute((used))
529-
#endif
530-
void DSEContext::dump() {
531-
llvm::dbgs() << "Locations:\n";
532-
unsigned idx = 0;
533-
for (const LSLocation &loc : LocationVault) {
534-
llvm::dbgs() << " #" << idx << ": " << loc.getBase();
535-
++idx;
536-
}
537-
for (SILBasicBlock &BB : *F) {
538-
getBlockState(&BB)->dump();
539-
}
540-
}
541-
542516
unsigned DSEContext::getLocationBit(const LSLocation &Loc) {
543517
// Return the bit position of the given Loc in the LocationVault. The bit
544518
// position is then used to set/reset the bitvector kept by each BlockState.
@@ -717,10 +691,6 @@ void DSEContext::mergeSuccessorLiveIns(SILBasicBlock *BB) {
717691
// dead for block with no successor.
718692
BlockState *C = getBlockState(BB);
719693
if (BB->succ_empty()) {
720-
if (isa<UnreachableInst>(BB->getTerminator())) {
721-
C->BBWriteSetOut.set();
722-
return;
723-
}
724694
C->BBWriteSetOut |= C->BBDeallocateLocation;
725695
return;
726696
}

trunk/lib/Sema/CSDiagnostics.cpp

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -542,26 +542,11 @@ void RequirementFailure::emitRequirementNote(const Decl *anchor, Type lhs,
542542

543543
bool MissingConformanceFailure::diagnoseAsError() {
544544
auto *anchor = getAnchor();
545-
auto ownerType = getOwnerType();
546545
auto nonConformingType = getLHS();
547546
auto protocolType = getRHS();
548547

549-
auto getArgumentAt = [](const ApplyExpr *AE, unsigned index) -> Expr * {
550-
assert(AE);
551-
552-
auto *arg = AE->getArg();
553-
if (auto *TE = dyn_cast<TupleExpr>(arg))
554-
return TE->getElement(index);
555-
556-
assert(index == 0);
557-
if (auto *PE = dyn_cast<ParenExpr>(arg))
558-
return PE->getSubExpr();
559-
560-
return arg;
561-
};
562-
563548
// If this is a requirement of a pattern-matching operator,
564-
// let's see whether argument is already has a fix associated
549+
// let's see whether argument already has a fix associated
565550
// with it and if so skip conformance error, otherwise we'd
566551
// produce an unrelated `<type> doesn't conform to Equatable protocol`
567552
// diagnostic.
@@ -588,43 +573,14 @@ bool MissingConformanceFailure::diagnoseAsError() {
588573
if (diagnoseAsAmbiguousOperatorRef())
589574
return true;
590575

591-
Optional<unsigned> atParameterPos;
592-
// Sometimes fix is recorded by type-checking sub-expression
593-
// during normal diagnostics, in such case call expression
594-
// is unavailable.
595-
if (Apply) {
596-
if (auto *fnType = ownerType->getAs<AnyFunctionType>()) {
597-
auto parameters = fnType->getParams();
598-
for (auto index : indices(parameters)) {
599-
if (parameters[index].getOldType()->isEqual(nonConformingType)) {
600-
atParameterPos = index;
601-
break;
602-
}
603-
}
604-
}
605-
}
606-
607576
if (nonConformingType->isObjCExistentialType()) {
608577
emitDiagnostic(anchor->getLoc(), diag::protocol_does_not_conform_static,
609578
nonConformingType, protocolType);
610579
return true;
611580
}
612581

613-
if (diagnoseTypeCannotConform((atParameterPos ?
614-
getArgumentAt(Apply, *atParameterPos) : anchor),
615-
nonConformingType, protocolType)) {
616-
return true;
617-
}
618-
619-
if (atParameterPos) {
620-
// Requirement comes from one of the parameter types,
621-
// let's try to point diagnostic to the argument expression.
622-
auto *argExpr = getArgumentAt(Apply, *atParameterPos);
623-
emitDiagnostic(argExpr->getLoc(),
624-
diag::cannot_convert_argument_value_protocol,
625-
nonConformingType, protocolType);
582+
if (diagnoseTypeCannotConform(anchor, nonConformingType, protocolType))
626583
return true;
627-
}
628584

629585
// If none of the special cases could be diagnosed,
630586
// let's fallback to the most general diagnostic.

trunk/test/ClangImporter/newtype_conformance.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ import MoreSwiftNewtypes
1313

1414
func acceptEquatable<T: Equatable>(_: T) {}
1515
func acceptHashable<T: Hashable>(_: T) {}
16+
// expected-note@-1 {{where 'T' = 'WrappedRef'}}
17+
// expected-note@-2 {{where 'T' = 'WrappedValue'}}
1618
func acceptComparable<T: Comparable>(_: T) {}
19+
// expected-note@-1 {{where 'T' = 'NSNotification.Name'}}
1720

1821
func testNewTypeWrapper(x: NSNotification.Name, y: NSNotification.Name) {
1922
acceptEquatable(x)
2023
acceptHashable(x)
21-
acceptComparable(x) // expected-error {{does not conform to expected type 'Comparable'}}
24+
acceptComparable(x) // expected-error {{global function 'acceptComparable' requires that 'NSNotification.Name' conform to 'Comparable'}}
2225

2326
_ = x == y
2427
_ = x != y
@@ -30,6 +33,6 @@ func testNewTypeWrapper(x: NSNotification.Name, y: NSNotification.Name) {
3033
func testCustomWrappers(wrappedRef: WrappedRef, wrappedValue: WrappedValue) {
3134
acceptEquatable(wrappedRef)
3235
acceptEquatable(wrappedValue)
33-
acceptHashable(wrappedRef) // expected-error {{does not conform to expected type 'Hashable'}}
34-
acceptHashable(wrappedValue) // expected-error {{does not conform to expected type 'Hashable'}}
36+
acceptHashable(wrappedRef) // expected-error {{global function 'acceptHashable' requires that 'WrappedRef' conform to 'Hashable'}}
37+
acceptHashable(wrappedValue) // expected-error {{global function 'acceptHashable' requires that 'WrappedValue' conform to 'Hashable'}}
3538
}

trunk/test/Constraints/diagnostics.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func f5<T : P2>(_ : T) { }
3131
// expected-note@-1 {{required by global function 'f5' where 'T' = '(Int) -> Int'}}
3232
// expected-note@-2 {{required by global function 'f5' where 'T' = '(Int, String)'}}
3333
// expected-note@-3 {{required by global function 'f5' where 'T' = 'Int.Type'}}
34+
// expected-note@-4 {{where 'T' = 'Int'}}
3435

3536
func f6<T : P, U : P>(_ t: T, _ u: U) where T.SomeType == U.SomeType {}
3637

@@ -75,10 +76,10 @@ i.wobble() // expected-error{{value of type 'Int' has no member 'wobble'}}
7576

7677
// Generic member does not conform.
7778
extension Int {
78-
func wibble<T: P2>(_ x: T, _ y: T) -> T { return x }
79+
func wibble<T: P2>(_ x: T, _ y: T) -> T { return x } // expected-note {{where 'T' = 'Int'}}
7980
func wubble<T>(_ x: (Int) -> T) -> T { return x(self) }
8081
}
81-
i.wibble(3, 4) // expected-error {{argument type 'Int' does not conform to expected type 'P2'}}
82+
i.wibble(3, 4) // expected-error {{instance method 'wibble' requires that 'Int' conform to 'P2'}}
8283

8384
// Generic member args correct, but return type doesn't match.
8485
struct A : P2 {
@@ -98,9 +99,9 @@ func f7() -> (c: Int, v: A) {
9899
return f6(g) // expected-error {{cannot convert return expression of type '(c: Int, i: A)' to return type '(c: Int, v: A)'}}
99100
}
100101

101-
func f8<T:P2>(_ n: T, _ f: @escaping (T) -> T) {}
102+
func f8<T:P2>(_ n: T, _ f: @escaping (T) -> T) {} // expected-note {{where 'T' = 'Int'}}
102103
// expected-note@-1 {{required by global function 'f8' where 'T' = 'Tup' (aka '(Int, Double)')}}
103-
f8(3, f4) // expected-error {{argument type 'Int' does not conform to expected type 'P2'}}
104+
f8(3, f4) // expected-error {{global function 'f8' requires that 'Int' conform to 'P2'}}
104105
typealias Tup = (Int, Double)
105106
func f9(_ x: Tup) -> Tup { return x }
106107
f8((1,2.0), f9) // expected-error {{type 'Tup' (aka '(Int, Double)') cannot conform to 'P2'; only struct/enum/class types can conform to protocols}}
@@ -111,7 +112,7 @@ f8((1,2.0), f9) // expected-error {{type 'Tup' (aka '(Int, Double)') cannot conf
111112
"awfawf".doesntExist(0) // expected-error {{value of type 'String' has no member 'doesntExist'}}
112113

113114
// Does not conform to protocol.
114-
f5(i) // expected-error {{argument type 'Int' does not conform to expected type 'P2'}}
115+
f5(i) // expected-error {{global function 'f5' requires that 'Int' conform to 'P2'}}
115116

116117
// Make sure we don't leave open existentials when diagnosing.
117118
// <rdar://problem/20598568>

trunk/test/Constraints/generics.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
infix operator +++
44

5-
protocol ConcatToAnything {
5+
protocol ConcatToAnything { // expected-note {{where 'Self' = 'U'}}
66
static func +++ <T>(lhs: Self, other: T)
77
}
88

@@ -14,7 +14,7 @@ func min<T : Comparable>(_ x: T, y: T) -> T {
1414
func weirdConcat<T : ConcatToAnything, U>(_ t: T, u: U) {
1515
t +++ u
1616
t +++ 1
17-
u +++ t // expected-error{{argument type 'U' does not conform to expected type 'ConcatToAnything'}}
17+
u +++ t // expected-error{{referencing operator function '+++' on 'ConcatToAnything' requires that 'U' conform to 'ConcatToAnything'}}
1818
}
1919

2020
// Make sure that the protocol operators don't get in the way.
@@ -647,7 +647,7 @@ struct BottleLayout {
647647
}
648648
let arr = [BottleLayout]()
649649
let layout = BottleLayout(count:1)
650-
let ix = arr.firstIndex(of:layout) // expected-error {{argument type 'BottleLayout' does not conform to expected type 'Equatable'}}
650+
let ix = arr.firstIndex(of:layout) // expected-error {{referencing instance method 'firstIndex(of:)' on 'Collection' requires that 'BottleLayout' conform to 'Equatable'}}
651651

652652
let _: () -> UInt8 = { .init("a" as Unicode.Scalar) } // expected-error {{missing argument label 'ascii:' in call}}
653653

trunk/test/Constraints/protocols.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,10 @@ func rdar_50512161() {
414414
foo(item: item) // expected-error {{generic parameter 'I' could not be inferred}}
415415
}
416416
}
417+
418+
// SR-11609: Compiler crash on missing conformance for default param
419+
func test_sr_11609() {
420+
func foo<T : Initable>(_ x: T = .init()) -> T { x } // expected-note {{where 'T' = 'String'}}
421+
let _: String = foo()
422+
// expected-error@-1 {{local function 'foo' requires that 'String' conform to 'Initable'}}
423+
}

trunk/test/Constraints/rdar40002266.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import Foundation
66
struct S {
77
init<T: NSNumber>(_ num: T) { // expected-note {{where 'T' = 'Bool'}}
88
self.init(num != 0) // expected-error {{initializer 'init(_:)' requires that 'Bool' inherit from 'NSNumber'}}
9-
// expected-error@-1 {{argument type 'T' does not conform to expected type 'BinaryInteger'}}
9+
// expected-error@-1 {{referencing operator function '!=' on 'BinaryInteger' requires that 'T' conform to 'BinaryInteger'}}
1010
}
1111
}

trunk/test/Constraints/tuple.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ variadicWithTrailingClosure(fn: +)
181181
func gcd_23700031<T>(_ a: T, b: T) {
182182
var a = a
183183
var b = b
184-
(a, b) = (b, a % b) // expected-error {{argument type 'T' does not conform to expected type 'BinaryInteger'}}
184+
(a, b) = (b, a % b) // expected-error {{protocol 'BinaryInteger' requires that 'T' conform to 'BinaryInteger'}}
185185
}
186186

187187
// <rdar://problem/24210190>

0 commit comments

Comments
 (0)