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 | 9a641510bd1a512805430a103668f52a7b4694e7 (patch) | |
| tree | a18b601599118988175033df186640035a29b905 /llvm/lib | |
| parent | 4a15e04aee7436b080b76717193c8dd6ef8d66c1 (diff) | |
| download | bcm5719-llvm-9a641510bd1a512805430a103668f52a7b4694e7.tar.gz bcm5719-llvm-9a641510bd1a512805430a103668f52a7b4694e7.zip | |
Fix PR1749 and InstCombine/2007-10-28-EmptyField.ll by handling
zero-length fields better.
llvm-svn: 43427
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/TargetData.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Target/TargetData.cpp b/llvm/lib/Target/TargetData.cpp index b2d76d84180..b1b78a8adad 100644 --- a/llvm/lib/Target/TargetData.cpp +++ b/llvm/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]; } |

