llvm.org GIT mirror llvm / 34e9d17
fix PR6332, allowing an index of zero into a zero sized array even if the element of the array has no size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101662 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
2 changed file(s) with 10 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
629629 Ty = cast(Ty)->getElementType();
630630
631631 // Get the array index and the size of each array element.
632 int64_t arrayIdx = cast(Indices[CurIDX])->getSExtValue();
633 Result += arrayIdx * (int64_t)getTypeAllocSize(Ty);
632 if (int64_t arrayIdx = cast(Indices[CurIDX])->getSExtValue())
633 Result += arrayIdx * (int64_t)getTypeAllocSize(Ty);
634634 }
635635 }
636636
0 ; RUN: llc %s -o -
1
2 ; PR6332
3 %struct.AVCodecTag = type opaque
4 @ff_codec_bmp_tags = external global [0 x %struct.AVCodecTag]
5 @tags = global [1 x %struct.AVCodecTag*] [%struct.AVCodecTag* getelementptr
6 inbounds ([0 x %struct.AVCodecTag]* @ff_codec_bmp_tags, i32 0, i32 0)]
7