Skip to content

Commit 8e63318

Browse files
authored
---
yaml --- r: 349102 b: refs/heads/master c: e4504af h: refs/heads/master
1 parent 36375b1 commit 8e63318

34 files changed

+259
-144
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: 9061d3da71063ab8cce9ecc70fd1f4b69fbf614d
2+
refs/heads/master: e4504af618c33caaf4cf23d69c036c0c1c95498f
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: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ 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)
96100
argparser.add_argument(
97101
'-platform', type=str,
98102
help='The benchmark build platform', default='macosx')
@@ -120,7 +124,7 @@ def test_opt_levels(args):
120124
if test_performance(opt_level, args.oldbuilddir[0],
121125
args.newbuilddir[0],
122126
float(args.threshold) / 100, args.num_samples,
123-
output_file):
127+
args.num_reruns, output_file):
124128
changes = True
125129

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

172176

173177
def test_performance(opt_level, old_dir, new_dir, threshold, num_samples,
174-
output_file):
178+
num_reruns, output_file):
175179
"""Detect performance changes in benchmarks.
176180
177181
Start fast with few samples per benchmark and gradually spend more time
@@ -185,7 +189,7 @@ def test_performance(opt_level, old_dir, new_dir, threshold, num_samples,
185189
tests = TestComparator(results[0], results[1], threshold)
186190
changed = tests.decreased + tests.increased
187191

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

trunk/include/swift/SIL/MemoryLifetime.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
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+
2535
/// The MemoryLocations utility provides functions to analyze memory locations.
2636
///
2737
/// Memory locations are limited to addresses which are guaranteed to

trunk/include/swift/SIL/SILArgumentConvention.h

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,6 @@
1717

1818
namespace swift {
1919

20-
enum class InoutAliasingAssumption {
21-
/// Assume that an inout indirect parameter may alias other objects.
22-
/// This is the safe assumption an optimization should make if it may break
23-
/// memory safety in case the inout aliasing rule is violation.
24-
Aliasing,
25-
26-
/// Assume that an inout indirect parameter cannot alias other objects.
27-
/// Optimizations should only use this if they can guarantee that they will
28-
/// not break memory safety even if the inout aliasing rule is violated.
29-
NotAliasing
30-
};
31-
3220
/// Conventions for apply operands and function-entry arguments in SIL.
3321
///
3422
/// This is simply a union of ParameterConvention and ResultConvention
@@ -142,19 +130,14 @@ struct SILArgumentConvention {
142130
}
143131

144132
/// Returns true if \p Value is a not-aliasing indirect parameter.
145-
/// The \p isInoutAliasing specifies what to assume about the inout
146-
/// convention.
147-
/// See InoutAliasingAssumption.
148-
bool isNotAliasedIndirectParameter(InoutAliasingAssumption isInoutAliasing) {
133+
bool isNotAliasedIndirectParameter() {
149134
switch (Value) {
150135
case SILArgumentConvention::Indirect_In:
151136
case SILArgumentConvention::Indirect_In_Constant:
152137
case SILArgumentConvention::Indirect_Out:
153138
case SILArgumentConvention::Indirect_In_Guaranteed:
154-
return true;
155-
156139
case SILArgumentConvention::Indirect_Inout:
157-
return isInoutAliasing == InoutAliasingAssumption::NotAliasing;
140+
return true;
158141

159142
case SILArgumentConvention::Indirect_InoutAliasable:
160143
case SILArgumentConvention::Direct_Unowned:

trunk/include/swift/SILOptimizer/Analysis/ValueTracking.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,14 @@ namespace swift {
2626
/// any other pointer in the function.
2727
/// The \p assumeInoutIsNotAliasing specifies in no-aliasing is assumed for
2828
/// the @inout convention. See swift::isNotAliasedIndirectParameter().
29-
bool isNotAliasingArgument(SILValue V, InoutAliasingAssumption isInoutAliasing =
30-
InoutAliasingAssumption::Aliasing);
29+
bool isNotAliasingArgument(SILValue V);
3130

3231
/// Returns true if \p V is local inside its function. This means its underlying
3332
/// object either is a non-aliasing function argument or a locally allocated
3433
/// object.
3534
/// The \p assumeInoutIsNotAliasing specifies in no-aliasing is assumed for
3635
/// the @inout convention. See swift::isNotAliasedIndirectParameter().
37-
bool pointsToLocalObject(SILValue V, InoutAliasingAssumption isInoutAliasing =
38-
InoutAliasingAssumption::Aliasing);
36+
bool pointsToLocalObject(SILValue V);
3937

4038
enum class IsZeroKind {
4139
Zero,

trunk/lib/IRGen/GenCast.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,12 @@ 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+
}
643647
if (srcSuperclassType) {
644648
checkSuperclassConstraint =
645649
!destInstanceType->getSuperclass()->isExactSuperclassOf(

trunk/lib/SIL/MemoryLifetime.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,28 @@ 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-
3831
/// Debug dump a location bit vector.
39-
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
40-
const SmallBitVector &bits) {
32+
void swift::printBitsAsArray(llvm::raw_ostream &OS, const SmallBitVector &bits) {
4133
const char *separator = "";
4234
OS << '[';
4335
for (int idx = bits.find_first(); idx >= 0; idx = bits.find_next(idx)) {
4436
OS << separator << idx;
4537
separator = ",";
4638
}
4739
OS << ']';
48-
return OS;
4940
}
5041

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+
5153
/// Enlarge the bitset if needed to set the bit with \p idx.
5254
static void setBitAndResize(SmallBitVector &bits, unsigned idx) {
5355
if (bits.size() <= idx)
@@ -240,10 +242,6 @@ void MemoryLocations::dump() const {
240242
}
241243
}
242244

243-
void MemoryLocations::dumpBits(const Bits &bits) {
244-
llvm::errs() << bits << '\n';
245-
}
246-
247245
void MemoryLocations::clear() {
248246
locations.clear();
249247
addr2LocIdx.clear();

trunk/lib/SILOptimizer/Analysis/ValueTracking.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@
2323
using namespace swift;
2424
using namespace swift::PatternMatch;
2525

26-
bool swift::isNotAliasingArgument(SILValue V,
27-
InoutAliasingAssumption isInoutAliasing) {
26+
bool swift::isNotAliasingArgument(SILValue V) {
2827
auto *Arg = dyn_cast<SILFunctionArgument>(V);
2928
if (!Arg)
3029
return false;
3130

3231
SILArgumentConvention Conv = Arg->getArgumentConvention();
33-
return Conv.isNotAliasedIndirectParameter(isInoutAliasing);
32+
return Conv.isNotAliasedIndirectParameter();
3433
}
3534

3635
/// Check if the parameter \V is based on a local object, e.g. it is an
@@ -81,10 +80,9 @@ static bool isLocalObject(SILValue Obj) {
8180
return true;
8281
}
8382

84-
bool swift::pointsToLocalObject(SILValue V,
85-
InoutAliasingAssumption isInoutAliasing) {
83+
bool swift::pointsToLocalObject(SILValue V) {
8684
V = getUnderlyingObject(V);
87-
return isLocalObject(V) || isNotAliasingArgument(V, isInoutAliasing);
85+
return isLocalObject(V) || isNotAliasingArgument(V);
8886
}
8987

9088
/// Check if the value \p Value is known to be zero, non-zero or unknown.

trunk/lib/SILOptimizer/Transforms/DeadStoreElimination.cpp

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

273+
void dump();
274+
272275
/// Initialize the bitvectors for the current basic block.
273276
void init(unsigned LocationNum, bool Optimistic);
274277

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

454+
void dump();
455+
451456
/// Entry point for dead store elimination.
452457
bool run();
453458

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

482487
} // end anonymous namespace
483488

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+
484495
void BlockState::init(unsigned LocationNum, bool Optimistic) {
485496
// For function that requires just 1 iteration of the data flow to converge
486497
// we set the initial state of BBWriteSetIn to 0.
@@ -513,6 +524,21 @@ void BlockState::init(unsigned LocationNum, bool Optimistic) {
513524
BBDeallocateLocation.resize(LocationNum, false);
514525
}
515526

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+
516542
unsigned DSEContext::getLocationBit(const LSLocation &Loc) {
517543
// Return the bit position of the given Loc in the LocationVault. The bit
518544
// position is then used to set/reset the bitvector kept by each BlockState.
@@ -691,6 +717,10 @@ void DSEContext::mergeSuccessorLiveIns(SILBasicBlock *BB) {
691717
// dead for block with no successor.
692718
BlockState *C = getBlockState(BB);
693719
if (BB->succ_empty()) {
720+
if (isa<UnreachableInst>(BB->getTerminator())) {
721+
C->BBWriteSetOut.set();
722+
return;
723+
}
694724
C->BBWriteSetOut |= C->BBDeallocateLocation;
695725
return;
696726
}

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
}

0 commit comments

Comments
 (0)