mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
Fix PR1749 and InstCombine/2007-10-28-EmptyField.ll by handling
zero-length fields better. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43427 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -83,9 +83,15 @@ unsigned StructLayout::getElementContainingOffset(uint64_t Offset) const {
|
||||
assert(SI != &MemberOffsets[0] && "Offset not in structure type!");
|
||||
--SI;
|
||||
assert(*SI <= Offset && "upper_bound didn't work");
|
||||
assert((SI == &MemberOffsets[0] || *(SI-1) < Offset) &&
|
||||
assert((SI == &MemberOffsets[0] || *(SI-1) <= Offset) &&
|
||||
(SI+1 == &MemberOffsets[NumElements] || *(SI+1) > Offset) &&
|
||||
"Upper bound didn't work!");
|
||||
|
||||
// Multiple fields can have the same offset if any of them are zero sized.
|
||||
// For example, in { i32, [0 x i32], i32 }, searching for offset 4 will stop
|
||||
// at the i32 element, because it is the last element at that offset. This is
|
||||
// the right one to return, because anything after it will have a higher
|
||||
// offset, implying that this element is non-empty.
|
||||
return SI-&MemberOffsets[0];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user