llvm.org GIT mirror llvm / 0a01243
[BasicAA] Compare GEP indices based on value (Fix PR27418) Equivalent GEP indices with different types are treated as different indices altogether, leading to an incorrect AA result. Fix the issue by comparing indices based on their values. Thanks to Mikael Holmén for reporting the issue! Differential Revision: http://reviews.llvm.org/D19935 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269197 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 3 years ago
2 changed file(s) with 10 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
846846
847847 // If the last (struct) indices are constants and are equal, the other indices
848848 // might be also be dynamically equal, so the GEPs can alias.
849 if (C1 && C2 && C1 == C2)
849 if (C1 && C2 && C1->getSExtValue() == C2->getSExtValue())
850850 return MayAlias;
851851
852852 // Find the last-indexed type of the GEP, i.e., the type you'd get if
161161 %y = getelementptr %struct2, %struct2* %st, i32 0, i32 0, i32 1, i32 1
162162 ret void
163163 }
164
165 ; PR27418 - Treat GEP indices with the same value but different types the same
166 ; CHECK-LABEL: test_different_index_types
167 ; CHECK: MustAlias: i16* %tmp1, i16* %tmp2
168 define void @test_different_index_types([2 x i16]* %arr) {
169 %tmp1 = getelementptr [2 x i16], [2 x i16]* %arr, i16 0, i32 1
170 %tmp2 = getelementptr [2 x i16], [2 x i16]* %arr, i16 0, i16 1
171 ret void
172 }