@@ -102,6 +102,7 @@ static tysan_type_descriptor *getRootTD(tysan_type_descriptor *TD) {
102
102
return RootTD;
103
103
}
104
104
105
+ // Walk up TDA to see if it reaches TDB
105
106
bool walkAliasTree (tysan_type_descriptor *TDA, tysan_type_descriptor *TDB,
106
107
uptr OffsetA, uptr OffsetB) {
107
108
do {
@@ -158,24 +159,29 @@ static bool isAliasingLegalUp(tysan_type_descriptor *TDA,
158
159
return walkAliasTree (TDA, TDB, OffsetA, OffsetB);
159
160
}
160
161
161
- static bool isAliasingLegalWithOffset (tysan_type_descriptor *AccessTD ,
162
- tysan_type_descriptor *ShadowTD ,
163
- int OffsetInShadow ) {
162
+ static bool isAliasingLegalWithOffset (tysan_type_descriptor *TDA ,
163
+ tysan_type_descriptor *TDB ,
164
+ int OffsetB ) {
164
165
// This is handled in the other cases
165
- if (OffsetInShadow == 0 )
166
+ if (OffsetB == 0 )
166
167
return false ;
167
168
168
169
// You can't have an offset into a member
169
- if (ShadowTD ->Tag == TYSAN_MEMBER_TD)
170
+ if (TDB ->Tag == TYSAN_MEMBER_TD)
170
171
return false ;
171
172
172
- int OffsetInAccess = 0 ;
173
- if (AccessTD ->Tag == TYSAN_MEMBER_TD) {
174
- OffsetInAccess = AccessTD ->Member .Offset ;
175
- AccessTD = AccessTD ->Member .Base ;
173
+ int OffsetA = 0 ;
174
+ if (TDA ->Tag == TYSAN_MEMBER_TD) {
175
+ OffsetA = TDA ->Member .Offset ;
176
+ TDA = TDA ->Member .Base ;
176
177
}
177
178
178
- return walkAliasTree (ShadowTD, AccessTD, OffsetInShadow, OffsetInAccess);
179
+ // Since the access was partially inside TDB (the shadow), it can be assumed
180
+ // that we are accessing a member in an object. This means that rather than
181
+ // walk up the scalar access TDA to reach an object, we should walk up the
182
+ // object TBD to reach the scalar we are accessing it with. The offsets will
183
+ // still be checked at the end to make sure this alias is legal.
184
+ return walkAliasTree (TDB, TDA, OffsetB, OffsetA);
179
185
}
180
186
181
187
static bool isAliasingLegal (tysan_type_descriptor *TDA,
0 commit comments