Skip to content

Commit f6885e2

Browse files
author
Itai Ferber
authored
---
yaml --- r: 285631 b: refs/heads/master c: 6171d68 h: refs/heads/master i: 285629: 614fc8c 285627: d4cf5e8 285623: a3364b9 285615: 0219f8e 285599: b03f199 285567: 9081c32
1 parent 47a18ff commit f6885e2

28 files changed

+198
-157
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: 55b300f852031bb8daea8ae85c3d18acf9d5d114
2+
refs/heads/master: 6171d68bfae60d98919f8a7680b83bbefab1e445
33
refs/heads/master-next: 90f691eef4aee378af27084030679214a1a39d50
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/ABI/Metadata.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3121,10 +3121,6 @@ struct MetadataCompletionContext {
31213121
/// it may be called many times as successive dependencies are resolved.
31223122
/// If the function ever completes successfully (by returning null), it
31233123
/// will not be called again for the same type.
3124-
///
3125-
/// \return null to indicate that the type has been completed, or a non-null
3126-
/// pointer to indicate that completion is blocked on the completion of
3127-
/// some other type
31283124
using MetadataCompleter =
31293125
SWIFT_CC(swift)
31303126
MetadataDependency(const Metadata *type,

trunk/lib/SILOptimizer/Utils/CastOptimizer.cpp

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,17 +321,45 @@ CastOptimizer::optimizeBridgedObjCToSwiftCast(SILDynamicCastInst dynamicCast) {
321321
auto *CCABI = cast<CheckedCastAddrBranchInst>(Inst);
322322
switch (CCABI->getConsumptionKind()) {
323323
case CastConsumptionKind::TakeAlways:
324-
Builder.createReleaseValue(Loc, srcOp, Builder.getDefaultAtomicity());
324+
Builder.emitDestroyValueOperation(Loc, srcOp);
325325
break;
326326
case CastConsumptionKind::TakeOnSuccess: {
327-
// Insert a release in the success BB.
328-
SILBuilderWithScope SuccessBuilder(SuccessBB->begin());
329-
SuccessBuilder.emitDestroyValueOperation(Loc, srcOp);
327+
{
328+
// Insert a release in the success BB.
329+
SILBuilderWithScope successBuilder(SuccessBB->begin());
330+
successBuilder.emitDestroyValueOperation(Loc, srcOp);
331+
}
332+
{
333+
// And a store in the failure BB.
334+
if (Builder.hasOwnership()) {
335+
SILBuilderWithScope failureBuilder(FailureBB->begin());
336+
SILValue writeback = srcOp;
337+
SILType srcType = src->getType().getObjectType();
338+
if (writeback->getType() != srcType) {
339+
writeback =
340+
failureBuilder.createUncheckedRefCast(Loc, writeback, srcType);
341+
}
342+
failureBuilder.emitStoreValueOperation(Loc, writeback, src,
343+
StoreOwnershipQualifier::Init);
344+
}
345+
}
330346
break;
331347
}
332348
case CastConsumptionKind::BorrowAlways:
333349
llvm_unreachable("checked_cast_addr_br never has BorrowAlways");
334350
case CastConsumptionKind::CopyOnSuccess:
351+
// If we are performing copy_on_success, store the value back into memory
352+
// here since we loaded it. We may need to cast back to the actual
353+
// underlying type.
354+
if (Builder.hasOwnership()) {
355+
SILValue writeback = srcOp;
356+
SILType srcType = src->getType().getObjectType();
357+
if (writeback->getType() != srcType) {
358+
writeback = Builder.createUncheckedRefCast(Loc, writeback, srcType);
359+
}
360+
Builder.emitStoreValueOperation(Loc, writeback, src,
361+
StoreOwnershipQualifier::Init);
362+
}
335363
break;
336364
}
337365

trunk/lib/Sema/TypeCheckAttr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,6 +2735,10 @@ void TypeChecker::addImplicitDynamicAttribute(Decl *D) {
27352735
// Don't add dynamic to functions with a cdecl.
27362736
if (FD->getAttrs().hasAttribute<CDeclAttr>())
27372737
return;
2738+
// Don't add dynamic to local function definitions.
2739+
if (!FD->getDeclContext()->isTypeContext() &&
2740+
FD->getDeclContext()->isLocalContext())
2741+
return;
27382742
}
27392743

27402744
// Don't add dynamic if accessor is inlinable or tranparent.

trunk/stdlib/public/Darwin/Foundation/Collections+DataProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ extension Repeated: DataProtocol where Element == UInt8 {
4949
public typealias Regions = Repeated<Data>
5050

5151
public var regions: Repeated<Data> {
52-
guard self.count > 0 else { return repeatElement(Data(), count: 0) }
52+
guard !self.isEmpty else { return repeatElement(Data(), count: 0) }
5353
return repeatElement(Data(CollectionOfOne(self.first!)), count: self.count)
5454
}
5555
}

trunk/stdlib/public/Darwin/Foundation/Data.swift

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
639639
@inlinable // This is @inlinable as a convenience initializer.
640640
init(_ srcBuffer: UnsafeRawBufferPointer) {
641641
self.init(count: srcBuffer.count)
642-
if srcBuffer.count > 0 {
642+
if !srcBuffer.isEmpty {
643643
Swift.withUnsafeMutableBytes(of: &bytes) { dstBuffer in
644644
dstBuffer.baseAddress?.copyMemory(from: srcBuffer.baseAddress!, byteCount: srcBuffer.count)
645645
}
@@ -729,7 +729,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
729729

730730
@inlinable // This is @inlinable as trivially computable.
731731
mutating func append(contentsOf buffer: UnsafeRawBufferPointer) {
732-
guard buffer.count > 0 else { return }
732+
guard !buffer.isEmpty else { return }
733733
assert(count + buffer.count <= MemoryLayout<Buffer>.size)
734734
let cnt = count
735735
_ = Swift.withUnsafeMutableBytes(of: &bytes) { rawBuffer in
@@ -1270,7 +1270,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
12701270

12711271
@inlinable // This is @inlinable as a trivial initializer.
12721272
init(_ buffer: UnsafeRawBufferPointer) {
1273-
if buffer.count == 0 {
1273+
if buffer.isEmpty {
12741274
self = .empty
12751275
} else if InlineData.canStore(count: buffer.count) {
12761276
self = .inline(InlineData(buffer))
@@ -1283,7 +1283,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
12831283

12841284
@inlinable // This is @inlinable as a trivial initializer.
12851285
init(_ buffer: UnsafeRawBufferPointer, owner: AnyObject) {
1286-
if buffer.count == 0 {
1286+
if buffer.isEmpty {
12871287
self = .empty
12881288
} else if InlineData.canStore(count: buffer.count) {
12891289
self = .inline(InlineData(buffer))
@@ -1580,7 +1580,6 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
15801580
precondition(range.lowerBound <= endIndex, "index \(range.lowerBound) is out of bounds of \(startIndex)..<\(endIndex)")
15811581
self = .large(LargeSlice(count: range.upperBound))
15821582
}
1583-
break
15841583
case .inline(var inline):
15851584
if inline.count < range.upperBound {
15861585
if InlineSlice.canStore(count: range.upperBound) {
@@ -1596,7 +1595,6 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
15961595
inline.resetBytes(in: range)
15971596
self = .inline(inline)
15981597
}
1599-
break
16001598
case .slice(var slice):
16011599
if InlineSlice.canStore(count: range.upperBound) {
16021600
self = .empty
@@ -1608,7 +1606,6 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
16081606
newSlice.resetBytes(in: range)
16091607
self = .large(newSlice)
16101608
}
1611-
break
16121609
case .large(var slice):
16131610
self = .empty
16141611
slice.resetBytes(in: range)
@@ -1630,7 +1627,6 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
16301627
} else {
16311628
self = .large(LargeSlice(UnsafeRawBufferPointer(start: bytes, count: cnt)))
16321629
}
1633-
break
16341630
case .inline(var inline):
16351631
let resultingCount = inline.count + cnt - (subrange.upperBound - subrange.lowerBound)
16361632
if resultingCount == 0 {
@@ -1647,7 +1643,6 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
16471643
slice.replaceSubrange(subrange, with: bytes, count: cnt)
16481644
self = .large(slice)
16491645
}
1650-
break
16511646
case .slice(var slice):
16521647
let resultingUpper = slice.endIndex + cnt - (subrange.upperBound - subrange.lowerBound)
16531648
if slice.startIndex == 0 && resultingUpper == 0 {
@@ -1820,7 +1815,6 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
18201815
return
18211816
case .inline(let inline):
18221817
inline.copyBytes(to: pointer, from: range)
1823-
break
18241818
case .slice(let slice):
18251819
slice.copyBytes(to: pointer, from: range)
18261820
case .large(let slice):
@@ -2319,7 +2313,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
23192313
}
23202314

23212315
public mutating func append(_ other: Data) {
2322-
guard other.count > 0 else { return }
2316+
guard !other.isEmpty else { return }
23232317
other.withUnsafeBytes { (buffer: UnsafeRawBufferPointer) in
23242318
_representation.append(contentsOf: buffer)
23252319
}

0 commit comments

Comments
 (0)