forked from OSchip/llvm-project
Fix PR10104 by adding a bounds check on a vector element access check. It was
assuming that all offsets are legal vector accesses, and thus trying to access the float member of { <2 x float>, float } as the 3rd element of the first member. llvm-svn: 132766
This commit is contained in:
parent
11edab6a46
commit
77a699a829
|
@ -342,7 +342,10 @@ void ConvertToScalarInfo::MergeInType(const Type *In, uint64_t Offset,
|
||||||
// If we're accessing something that could be an element of a vector, see
|
// If we're accessing something that could be an element of a vector, see
|
||||||
// if the implied vector agrees with what we already have and if Offset is
|
// if the implied vector agrees with what we already have and if Offset is
|
||||||
// compatible with it.
|
// compatible with it.
|
||||||
if (Offset % EltSize == 0 && AllocaSize % EltSize == 0) {
|
if (Offset % EltSize == 0 && AllocaSize % EltSize == 0 &&
|
||||||
|
Offset * 8 <
|
||||||
|
(VectorTy ? VectorTy->getPrimitiveSizeInBits()
|
||||||
|
: (AllocaSize / EltSize) * In->getPrimitiveSizeInBits())) {
|
||||||
if (!VectorTy) {
|
if (!VectorTy) {
|
||||||
VectorTy = VectorType::get(In, AllocaSize/EltSize);
|
VectorTy = VectorType::get(In, AllocaSize/EltSize);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -41,9 +41,11 @@ entry:
|
||||||
|
|
||||||
; CHECK: test2
|
; CHECK: test2
|
||||||
; CHECK-NOT: alloca
|
; CHECK-NOT: alloca
|
||||||
; CHECK: insertelement <2 x float> zeroinitializer
|
; CHECK: and i128
|
||||||
; CHECK: extractelement <2 x float> %tmp2
|
; CHECK: or i128
|
||||||
; CHECK: extractelement <2 x float> %tmp2
|
; CHECK: trunc i128
|
||||||
|
; CHECK-NOT: insertelement
|
||||||
|
; CHECK-NOT: extractelement
|
||||||
|
|
||||||
define float @test2() uwtable ssp {
|
define float @test2() uwtable ssp {
|
||||||
entry:
|
entry:
|
||||||
|
|
Loading…
Reference in New Issue