File tree Expand file tree Collapse file tree 3 files changed +37
-3
lines changed Expand file tree Collapse file tree 3 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -79,9 +79,7 @@ SingleValueInstruction *isAccessProjection(SILValue v);
79
79
SILValue getAddressAccess (SILValue v);
80
80
81
81
// / Convenience for stripAccessMarkers(getAddressAccess(v)).
82
- inline SILValue getAccessedAddress (SILValue v) {
83
- return stripAccessMarkers (getAddressAccess (v));
84
- }
82
+ SILValue getAccessedAddress (SILValue v);
85
83
86
84
// / Return true if \p accessedAddress points to a let-variable.
87
85
// /
Original file line number Diff line number Diff line change @@ -58,6 +58,15 @@ SILValue swift::getAddressAccess(SILValue v) {
58
58
}
59
59
}
60
60
61
+ SILValue swift::getAccessedAddress (SILValue v) {
62
+ while (true ) {
63
+ SILValue v2 = stripAccessMarkers (getAddressAccess (v));
64
+ if (v2 == v)
65
+ return v;
66
+ v = v2;
67
+ }
68
+ }
69
+
61
70
bool swift::isLetAddress (SILValue accessedAddress) {
62
71
assert (accessedAddress == getAccessedAddress (accessedAddress)
63
72
&& " caller must find the address root" );
Original file line number Diff line number Diff line change @@ -141,3 +141,30 @@ bb0(%0 : $C):
141
141
%8 = tuple ()
142
142
return %8 : $()
143
143
}
144
+
145
+ // ===-----------------------------------------------------------------------===
146
+ // Test that isLetAccess does not assert on nested access markers with
147
+ // interprosed projections.
148
+
149
+ struct Int64Wrapper {
150
+ var val : Int64
151
+ }
152
+
153
+ // CHECK-LABEL: @testNestedAccessWithInterposedProjection
154
+ // CHECK: PAIR #2.
155
+ // CHECK: %1 = begin_access [modify] [static] %0 : $*Int64Wrapper // users: %7, %2
156
+ // CHECK: %3 = begin_access [read] [static] %2 : $*Int64 // users: %6, %4
157
+ // CHECK: r=0,w=1,se=1
158
+ // CHECK: PAIR #3.
159
+ sil @testNestedAccessWithInterposedProjection : $@convention(thin) (@inout Int64Wrapper) -> () {
160
+ bb0(%0 : $*Int64Wrapper):
161
+ %1 = begin_access [modify] [static] %0 : $*Int64Wrapper
162
+ %2 = struct_element_addr %1 : $*Int64Wrapper, #Int64Wrapper.val
163
+ %3 = begin_access [read] [static] %2 : $*Int64
164
+ %4 = struct_element_addr %3 : $*Int64, #Int64._value
165
+ %5 = load %4 : $*Builtin.Int64
166
+ end_access %3 : $*Int64
167
+ end_access %1 : $*Int64Wrapper
168
+ %8 = tuple ()
169
+ return %8 : $()
170
+ }
You can’t perform that action at this time.
0 commit comments