diff options
author | Chris Lattner <sabre@nondot.org> | 2007-10-29 02:40:02 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-10-29 02:40:02 +0000 |
commit | b361ec31979b2ac40af00d5258b9571239954103 (patch) | |
tree | 2b0c96225dc3c45a170cdba2f2a2d81dae7141ba /lib/Target/TargetData.cpp | |
parent | 3cb63ddd5183a1469e4557b3e22735ed3ace05b2 (diff) |
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
Diffstat (limited to 'lib/Target/TargetData.cpp')
-rw-r--r-- | lib/Target/TargetData.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index b2d76d8418..b1b78a8ada 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -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]; } |