Skip to content

Commit 2eeeb18

Browse files
committed
---
yaml --- r: 349404 b: refs/heads/master-next c: 9f729f7 h: refs/heads/master
1 parent 00b4340 commit 2eeeb18

File tree

5 files changed

+73
-38
lines changed

5 files changed

+73
-38
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: e1c0cc93bb00b0066b51498436551d9405b535b4
3+
refs/heads/master-next: 9f729f7954204b4e7366a52a91711e16f08a3212
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/lib/SILOptimizer/Transforms/SimplifyCFG.cpp

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,14 +1878,38 @@ static bool onlyForwardsNone(SILBasicBlock *noneBB, SILBasicBlock *someBB,
18781878
/// \ ... (more bbs?)
18791879
/// \ /
18801880
/// ulimateBB
1881-
static bool hasSameUlitmateSuccessor(SILBasicBlock *noneBB, SILBasicBlock *someBB) {
1881+
static bool hasSameUltimateSuccessor(SILBasicBlock *noneBB, SILBasicBlock *someBB) {
1882+
// Make sure that both our some, none blocks both have single successors that
1883+
// are not themselves (which can happen due to single block loops).
18821884
auto *someSuccessorBB = someBB->getSingleSuccessorBlock();
1883-
if (!someSuccessorBB)
1885+
if (!someSuccessorBB || someSuccessorBB == someBB)
18841886
return false;
18851887
auto *noneSuccessorBB = noneBB->getSingleSuccessorBlock();
1886-
while (noneSuccessorBB != nullptr && noneSuccessorBB != someSuccessorBB)
1887-
noneSuccessorBB = noneSuccessorBB->getSingleSuccessorBlock();
1888-
return noneSuccessorBB == someSuccessorBB;
1888+
if (!noneSuccessorBB || noneSuccessorBB == noneBB)
1889+
return false;
1890+
1891+
// If we immediately find a diamond, return true. We are done.
1892+
if (noneSuccessorBB == someSuccessorBB)
1893+
return true;
1894+
1895+
// Otherwise, lets keep looking down the none case.
1896+
auto *next = noneSuccessorBB;
1897+
while (next != someSuccessorBB) {
1898+
noneSuccessorBB = next;
1899+
next = noneSuccessorBB->getSingleSuccessorBlock();
1900+
1901+
// If we find another single successor and it is not our own block (due to a
1902+
// self-loop), continue.
1903+
if (next && next != noneSuccessorBB)
1904+
continue;
1905+
1906+
// Otherwise, we either have multiple successors or a self-loop. We do not
1907+
// support this, return false.
1908+
return false;
1909+
}
1910+
1911+
// At this point, we know that next must be someSuccessorBB.
1912+
return true;
18891913
}
18901914

18911915
/// Simplify switch_enums on class enums that branch to objc_method calls on
@@ -1920,7 +1944,7 @@ bool SimplifyCFG::simplifySwitchEnumOnObjcClassOptional(SwitchEnumInst *SEI) {
19201944
if (SEI->getCaseDestination(someDecl) != someBB)
19211945
std::swap(someBB, noneBB);
19221946

1923-
if (!hasSameUlitmateSuccessor(noneBB, someBB))
1947+
if (!hasSameUltimateSuccessor(noneBB, someBB))
19241948
return false;
19251949

19261950
if (!onlyForwardsNone(noneBB, someBB, SEI))

branches/master-next/lib/Sema/TypeCheckDecl.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,17 +1964,8 @@ void TypeChecker::validateDecl(OperatorDecl *OD) {
19641964
}
19651965

19661966
bool swift::doesContextHaveValueSemantics(DeclContext *dc) {
1967-
if (Type contextTy = dc->getDeclaredInterfaceType()) {
1968-
// If the decl context is an extension, then it could be imposing a class
1969-
// constraint (ex: where Self: SomeClass). Make sure we include that
1970-
// in our check as well.
1971-
auto extensionRequiresClass = false;
1972-
if (auto ED = dyn_cast<ExtensionDecl>(dc)) {
1973-
extensionRequiresClass =
1974-
ED->getGenericSignature()->requiresClass(ED->getSelfInterfaceType());
1975-
}
1976-
return !contextTy->hasReferenceSemantics() && !extensionRequiresClass;
1977-
}
1967+
if (Type contextTy = dc->getDeclaredInterfaceType())
1968+
return !contextTy->hasReferenceSemantics();
19781969
return false;
19791970
}
19801971

branches/master-next/test/SILOptimizer/simplify_switch_enum_objc.sil

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,43 @@ bb8:
381381
bb9:
382382
br bb7
383383
}
384+
385+
sil @infinite_loop_get_optional_nsobject : $@convention(thin) () -> @autoreleased Optional<NSObject>
386+
sil @infinite_loop_get_superview : $@convention(thin) (NSObject) -> @autoreleased Optional<NSObject>
387+
388+
// Just make sure we do not infinite loop here when looking for successors.
389+
// CHECK-LABEL: sil @infinite_loop_1 : $@convention(thin) () -> @owned Optional<NSObject> {
390+
// CHECK: } // end sil function 'infinite_loop_1'
391+
sil @infinite_loop_1 : $@convention(thin) () -> @owned Optional<NSObject> {
392+
bb0:
393+
%13 = function_ref @infinite_loop_get_optional_nsobject : $@convention(thin) () -> @autoreleased Optional<NSObject>
394+
%14 = apply %13() : $@convention(thin) () -> @autoreleased Optional<NSObject>
395+
br bb1(%14 : $Optional<NSObject>)
396+
397+
bb1(%16 : $Optional<NSObject>):
398+
retain_value %16 : $Optional<NSObject>
399+
switch_enum %16 : $Optional<NSObject>, case #Optional.some!enumelt.1: bb2, case #Optional.none!enumelt: bb5
400+
401+
bb2(%19 : $NSObject):
402+
release_value %16 : $Optional<NSObject>
403+
%21 = enum $Optional<NSObject>, #Optional.none!enumelt
404+
release_value %16 : $Optional<NSObject>
405+
return %21 : $Optional<NSObject>
406+
407+
bb3:
408+
%24 = unchecked_enum_data %16 : $Optional<NSObject>, #Optional.some!enumelt.1
409+
strong_retain %24 : $NSObject
410+
%26 = function_ref @infinite_loop_get_superview : $@convention(thin) (NSObject) -> @autoreleased Optional<NSObject>
411+
%27 = apply %26(%24) : $@convention(thin) (NSObject) -> @autoreleased Optional<NSObject>
412+
strong_release %24 : $NSObject
413+
release_value %16 : $Optional<NSObject>
414+
br bb1(%27 : $Optional<NSObject>)
415+
416+
bb4:
417+
release_value %16 : $Optional<NSObject>
418+
br bb1(%16 : $Optional<NSObject>)
419+
420+
bb5:
421+
release_value %16 : $Optional<NSObject>
422+
switch_enum %16 : $Optional<NSObject>, case #Optional.none!enumelt: bb4, default bb3
423+
}

branches/master-next/test/decl/ext/extensions.swift

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,3 @@ struct WrapperContext {
124124
static let propUsingMember = originalValue
125125
}
126126
}
127-
128-
// SR-11298
129-
130-
protocol SR_11298_P {}
131-
132-
class SR_11298_C: SR_11298_P {
133-
var property: String = ""
134-
}
135-
136-
// Self: SR_11298_C requirement constrains this extension to SR_11298C and its subclasses.
137-
// Since this implies a class constraint, the setter should be implicitly nonmutating.
138-
extension SR_11298_P where Self: SR_11298_C {
139-
var wrappingProperty: String {
140-
get { return property }
141-
set { property = newValue }
142-
}
143-
}
144-
145-
let instance = SR_11298_C()
146-
instance.wrappingProperty = "" // Okay

0 commit comments

Comments
 (0)