[compiler-rt] [TySan] Fix struct access with different bases (PR #120412)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 6 02:21:11 PST 2025
================
@@ -131,6 +131,14 @@ static bool isAliasingLegalUp(tysan_type_descriptor *TDA,
break;
}
+ // This offset can't be negative. Therefore we must be accessing something
+ // partially inside the last type
+ // We shouldn't check this if we are on the first member, Idx will
+ // underflow The first member can be offset in rare cases such as
----------------
gbMattN wrote:
`Idx` would underflow because the next line subtracts one from it. This is so we check the previous member, which we are partially inside. We could merge it into the above loop like this if you think its better?
```
for (; Idx < TDA->Struct.MemberCount - 1; ++Idx) {
auto MemberOffset = TDA->Struct.Members[Idx].Offset;
if (MemberOffset >= OffsetA){
// Explanitory comment
if (MemberOffset > OffsetA && Idx)
Idx -= 1;
break;
}
}
```
https://github.com/llvm/llvm-project/pull/120412
More information about the llvm-commits
mailing list