llvm.org GIT mirror llvm / 9d4c131
[BasicAA] Bugfix for r251016 If the loaded type sizes don't match the element type of the sequential type, all bets are off and the addresses may, indeed, overlap. Surprisingly, this just got caught in one test, on one builder, out of the 30+ builders testing this change. Congratulations go to http://lab.llvm.org:8011/builders/clang-aarch64-lnt/builds/5205. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251112 91177308-0d34-0410-b5e6-96231b3b80d8 James Molloy 4 years ago
2 changed file(s) with 19 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
814814 // Because array indices greater than the number of elements are valid in
815815 // GEPs, unless we know the intermediate indices are identical between
816816 // GEP1 and GEP2 we cannot guarantee that the last indexed arrays don't
817 // partially overlap.
817 // partially overlap. We also need to check that the loaded size matches
818 // the element size, otherwise we could still have overlap.
819 const uint64_t ElementSize =
820 DL.getTypeStoreSize(cast(Ty)->getElementType());
821 if (V1Size != ElementSize || V2Size != ElementSize)
822 return MayAlias;
823
818824 for (unsigned i = 0, e = GEP1->getNumIndices() - 1; i != e; ++i)
819825 if (GEP1->getOperand(i + 1) != GEP2->getOperand(i + 1))
820826 return MayAlias;
821
827
822828 // Now we know that the array/pointer that GEP1 indexes into and that
823829 // that GEP2 indexes into must either precisely overlap or be disjoint.
824830 // Because they cannot partially overlap and because fields in an array
3939 ret void
4040 }
4141
42 ; CHECK: Function: t5
43 ; CHECK: PartialAlias: i32* %gep2, i64* %bc
44 define void @t5([8 x i32]* %p, i32 %addend, i32* %q) {
45 %knownnonzero = load i32, i32* %q, !range !0
46 %add = add nsw nuw i32 %addend, %knownnonzero
47 %gep1 = getelementptr [8 x i32], [8 x i32]* %p, i32 2, i32 %addend
48 %gep2 = getelementptr [8 x i32], [8 x i32]* %p, i32 2, i32 %add
49 %bc = bitcast i32* %gep1 to i64*
50 ret void
51 }
52
4253 !0 = !{ i32 1, i32 5 }