Skip to content

Commit 09a6e38

Browse files
committed
---
yaml --- r: 345011 b: refs/heads/master c: 833fa1f h: refs/heads/master i: 345009: e8b660a 345007: e7533c6
1 parent ae3b86e commit 09a6e38

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
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: 1994be0a75827fe06ff643f9b5d85b74d89f3946
2+
refs/heads/master: 833fa1f82191a37a2bff6329c5f5dabb3fe932ba
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/lib/SILGen/SILGenLValue.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3966,12 +3966,18 @@ void SILGenFunction::emitAssignToLValue(SILLocation loc, RValue &&src,
39663966
void SILGenFunction::emitAssignToLValue(SILLocation loc,
39673967
ArgumentSource &&src,
39683968
LValue &&dest) {
3969-
FormalEvaluationScope scope(*this);
3969+
// Enter a FormalEvaluationScope so that formal access to independent LValue
3970+
// components do not overlap. Furthermore, use an ArgumentScope to force
3971+
// cleanup of materialized LValues immediately, before evaluating the next
3972+
// LValue. For example: (x[i], x[j]) = a, b
3973+
ArgumentScope argScope(*this, loc);
39703974

39713975
// If the last component is a getter/setter component, use a special
39723976
// generation pattern that allows us to peephole the emission of the RHS.
3973-
if (trySetterPeephole(*this, loc, std::move(src), std::move(dest)))
3977+
if (trySetterPeephole(*this, loc, std::move(src), std::move(dest))) {
3978+
argScope.pop();
39743979
return;
3980+
}
39753981

39763982
// Otherwise, force the RHS now to preserve evaluation order.
39773983
auto srcLoc = src.getLocation();
@@ -4008,6 +4014,7 @@ void SILGenFunction::emitAssignToLValue(SILLocation loc,
40084014

40094015
// The writeback scope closing will propagate the value back up through the
40104016
// writeback chain.
4017+
argScope.pop();
40114018
}
40124019

40134020
void SILGenFunction::emitCopyLValueInto(SILLocation loc, LValue &&src,

trunk/test/SILGen/tuples.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,26 @@ extension P {
156156
return tuple.value.foo()
157157
}
158158
}
159+
160+
// CHECK-LABEL: sil @$S6tuples15testTupleAssign1xySaySiGz_tF : $@convention(thin) (@inout Array<Int>) -> () {
161+
// CHECK: [[ACCESS:%.*]] = begin_access [modify] [unknown] %0 : $*Array<Int>
162+
// function_ref Array.subscript.nativeOwningMutableAddressor
163+
// CHECK: [[ADDRESSOR:%.*]] = function_ref @$SSayxSiciao : $@convention(method) <τ_0_0> (Int, @inout Array<τ_0_0>) -> (UnsafeMutablePointer<τ_0_0>, @owned Builtin.NativeObject)
164+
// CHECK: [[TUPLE:%.*]] = apply [[ADDRESSOR]]<Int>(%{{.*}}, [[ACCESS]]) : $@convention(method) <τ_0_0> (Int, @inout Array<τ_0_0>) -> (UnsafeMutablePointer<τ_0_0>, @owned Builtin.NativeObject)
165+
// CHECK: ([[PTR:%.*]], [[OBJ:%.*]]) = destructure_tuple [[TUPLE]] : $(UnsafeMutablePointer<Int>, Builtin.NativeObject)
166+
// CHECK: assign %{{.*}} to %{{.*}} : $*Int
167+
// CHECK: end_access [[ACCESS]] : $*Array<Int>
168+
// CHECK: destroy_value [[OBJ]] : $Builtin.NativeObject
169+
//
170+
// CHECK: [[ACCESS:%.*]] = begin_access [modify] [unknown] %0 : $*Array<Int>
171+
// function_ref Array.subscript.nativeOwningMutableAddressor
172+
// CHECK: [[ADDRESSOR:%.*]] = function_ref @$SSayxSiciao : $@convention(method) <τ_0_0> (Int, @inout Array<τ_0_0>) -> (UnsafeMutablePointer<τ_0_0>, @owned Builtin.NativeObject)
173+
// CHECK: [[TUPLE:%.*]] = apply [[ADDRESSOR]]<Int>(%{{.*}}, [[ACCESS]]) : $@convention(method) <τ_0_0> (Int, @inout Array<τ_0_0>) -> (UnsafeMutablePointer<τ_0_0>, @owned Builtin.NativeObject)
174+
// CHECK: ([[PTR:%.*]], [[OBJ:%.*]]) = destructure_tuple [[TUPLE]] : $(UnsafeMutablePointer<Int>, Builtin.NativeObject)
175+
// CHECK: assign %{{.*}} to %{{.*}} : $*Int
176+
// CHECK: end_access [[ACCESS]] : $*Array<Int>
177+
// CHECK: destroy_value [[OBJ]] : $Builtin.NativeObject
178+
// CHECK-LABEL: } // end sil function '$S6tuples15testTupleAssign1xySaySiGz_tF'
179+
public func testTupleAssign(x: inout [Int]) {
180+
(x[0], x[1]) = (0, 1)
181+
}

0 commit comments

Comments
 (0)