Skip to content

Commit 3819961

Browse files
authored
Merge pull request #1449 from swiftwasm/master
[pull] swiftwasm from master
2 parents 05bf9da + ee0955a commit 3819961

File tree

13 files changed

+59
-18
lines changed

13 files changed

+59
-18
lines changed

include/swift/SIL/MemAccessUtils.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050

5151
namespace swift {
5252

53-
/// Get the base address of a formal access by stripping access markers and
54-
/// borrows.
53+
/// Get the base address of a formal access by stripping access markers.
5554
///
5655
/// If \p v is an address, then the returned value is also an address
5756
/// (pointer-to-address is not stripped).

lib/SIL/Utils/InstructionUtils.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ SILValue swift::stripCastsWithoutMarkDependence(SILValue V) {
127127
V = stripSinglePredecessorArgs(V);
128128

129129
auto K = V->getKind();
130-
if (isRCIdentityPreservingCast(K) ||
131-
K == ValueKind::UncheckedTrivialBitCastInst ||
132-
K == ValueKind::EndCOWMutationInst) {
130+
if (isRCIdentityPreservingCast(K)
131+
|| K == ValueKind::UncheckedTrivialBitCastInst
132+
|| K == ValueKind::BeginAccessInst
133+
|| K == ValueKind::EndCOWMutationInst) {
133134
V = cast<SingleValueInstruction>(V)->getOperand(0);
134135
continue;
135136
}
@@ -145,7 +146,8 @@ SILValue swift::stripCasts(SILValue v) {
145146
auto k = v->getKind();
146147
if (isRCIdentityPreservingCast(k)
147148
|| k == ValueKind::UncheckedTrivialBitCastInst
148-
|| k == ValueKind::MarkDependenceInst) {
149+
|| k == ValueKind::MarkDependenceInst
150+
|| k == ValueKind::BeginAccessInst) {
149151
v = cast<SingleValueInstruction>(v)->getOperand(0);
150152
continue;
151153
}

lib/SIL/Utils/Projection.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,13 @@ Optional<ProjectionPath> ProjectionPath::getProjectionPath(SILValue Start,
371371

372372
auto Iter = End;
373373
while (Start != Iter) {
374-
// end_cow_mutation is not a projection, but we want to "see through" it.
375-
if (!isa<EndCOWMutationInst>(Iter)) {
374+
// end_cow_mutation and begin_access are not projections, but we need to be
375+
// able to form valid ProjectionPaths across them, otherwise optimization
376+
// passes like RLE/DSE cannot recognize their locations.
377+
//
378+
// TODO: migrate users to getProjectionPath to the AccessPath utility to
379+
// avoid this hack.
380+
if (!isa<EndCOWMutationInst>(Iter) && !isa<BeginAccessInst>(Iter)) {
376381
Projection AP(Iter);
377382
if (!AP.isValid())
378383
break;

lib/Sema/CSBindings.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,28 @@ ConstraintSystem::getPotentialBindings(TypeVariableType *typeVar) const {
547547
}
548548
break;
549549
}
550+
case ConstraintKind::KeyPathApplication: {
551+
if (result.FullyBound)
552+
continue;
553+
554+
// If this variable is in the application projected result type, mark the
555+
// result as `FullyBound` to ensure we delay binding until we've bound
556+
// other type variables in the KeyPathApplication constraint. This ensures
557+
// we try to bind the key path type first, which can allow us to discover
558+
// additional bindings for the result type.
559+
SmallPtrSet<TypeVariableType *, 4> typeVars;
560+
findInferableTypeVars(simplifyType(constraint->getThirdType()), typeVars);
561+
if (typeVars.count(typeVar))
562+
result.FullyBound = true;
563+
564+
break;
565+
}
550566

551567
case ConstraintKind::BridgingConversion:
552568
case ConstraintKind::CheckedCast:
553569
case ConstraintKind::EscapableFunctionOf:
554570
case ConstraintKind::OpenedExistentialOf:
555571
case ConstraintKind::KeyPath:
556-
case ConstraintKind::KeyPathApplication:
557572
case ConstraintKind::FunctionInput:
558573
case ConstraintKind::FunctionResult:
559574
case ConstraintKind::OpaqueUnderlyingType:

stdlib/public/stubs/Stubs.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,11 @@ swift_stdlib_readLine_stdin(unsigned char **LinePtr) {
337337
return Pos;
338338
#else
339339
size_t Capacity = 0;
340-
return getline((char **)LinePtr, &Capacity, stdin);
340+
int result;
341+
do {
342+
result = getline((char **)LinePtr, &Capacity, stdin);
343+
} while (result < 0 && errno == EINTR);
344+
return result;
341345
#endif
342346
}
343347

test/Constraints/keypath.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,18 @@ func test_mismatch_with_contextual_optional_result() {
137137
let _ = A(B(), keyPath: \.arr)
138138
// expected-error@-1 {{key path value type '[Int]' cannot be converted to contextual type '[Int]?'}}
139139
}
140+
141+
// SR-11184
142+
class SR11184 {}
143+
144+
func fSR11184(_ c: SR11184!, _ kp: ReferenceWritableKeyPath<SR11184, String?>, _ str: String) {
145+
c[keyPath: kp] = str // OK
146+
c![keyPath: kp] = str // OK
147+
c?[keyPath: kp] = str // OK
148+
}
149+
150+
func fSR11184_O(_ c: SR11184!, _ kp: ReferenceWritableKeyPath<SR11184, String?>, _ str: String?) {
151+
c[keyPath: kp] = str // OK
152+
c![keyPath: kp] = str // OK
153+
c?[keyPath: kp] = str // OK
154+
}

test/Prototypes/BigInt.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// REQUIRES: executable_test
1717
// REQUIRES: CPU=x86_64
1818

19+
// REQUIRES: rdar65251059
1920
// rdar://problem/65015626
2021
// XFAIL: asserts
2122

test/SILGen/magic_identifier_file_conflicting.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %gyb -D TEMPDIR=%t %s > %t/magic_identifier_file_conflicting.swift
3-
// RUN: %{python} -c "import sys; t = open(sys.argv[1], 'rb').read().replace('\r\n', '\n'); open(sys.argv[1], 'wb').write(t)" %t/magic_identifier_file_conflicting.swift
3+
// RUN: %{python} -c "import io; import sys; t = io.open(sys.argv[1], 'r', encoding='utf-8').read().replace('\r\n', '\n'); io.open(sys.argv[1], 'w', encoding='utf-8', newline='\n').write(t)" %t/magic_identifier_file_conflicting.swift
44

55
// We want to check both the diagnostics and the SIL output.
66
// RUN: %target-swift-emit-silgen -verify -emit-sorted-sil -enable-experimental-concise-pound-file -module-name Foo %t/magic_identifier_file_conflicting.swift %S/Inputs/magic_identifier_file_conflicting_other.swift | %FileCheck %s

test/SILOptimizer/escape_analysis.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1938,7 +1938,7 @@ bb0(%0 : $*SomeData):
19381938
// CHECK: to set_deallocating %0 : $IntWrapper
19391939
// CHECK: NoEscape: %3 = ref_element_addr %0 : $IntWrapper, #IntWrapper.property
19401940
// CHECK: to set_deallocating %0 : $IntWrapper
1941-
// CHECK: MayEscape: %4 = begin_access [modify] [dynamic] [no_nested_conflict] %3 : $*Int64
1941+
// CHECK: NoEscape: %4 = begin_access [modify] [dynamic] [no_nested_conflict] %3 : $*Int64
19421942
// CHECK: to set_deallocating %0 : $IntWrapper
19431943
sil @testEndAccess : $@convention(thin) () -> () {
19441944
bb0:

test/SPI/private_swiftinterface.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ private class PrivateClassLocal {}
9393
// CHECK-PUBLIC-NOT: SPIProto3
9494

9595
associatedtype AssociatedType
96-
// CHECK-PRIVATE: associatedtype AssociatedType
97-
// CHECK-PRIVATE-NOT: @_spi(LocalSPI) associatedtype AssociatedType
96+
// CHECK-PRIVATE: {{^}} associatedtype AssociatedType
9897
// CHECK-PUBLIC-NOT: AssociatedType
9998

10099
func implicitSPIMethod()

0 commit comments

Comments
 (0)