1 ; RUN: opt -aa-pipeline=basic-aa -passes=aa-eval -print-all-alias-modref-info -disable-output %s 2>&1 | FileCheck %s
3 target datalayout = "p:32:32:32"
5 ; Test cases with i64 bit GEP indices that will get truncated implicitly to 32
6 ; bit due to the datalayout.
8 declare void @llvm.assume(i1)
10 define void @mustalias_overflow_in_32_bit_constants(ptr %ptr) {
11 ; CHECK-LABEL: Function: mustalias_overflow_in_32_bit_constants: 2 pointers, 0 call sites
12 ; CHECK-NEXT: MustAlias: i8* %gep.1, i8* %ptr
15 %gep.1 = getelementptr i8, ptr %ptr, i64 4294967296
16 store i8 0, ptr %gep.1
20 define void @mustalias_overflow_in_32_with_var_index(ptr %ptr, i64 %n) {
21 ; CHECK-LABEL: Function: mustalias_overflow_in_32_with_var_index
22 ; CHECK: MustAlias: i8* %gep.1, i8* %gep.2
24 load [1 x i8], ptr %ptr
25 %gep.1 = getelementptr [1 x i8], ptr %ptr, i64 %n, i64 4294967296
26 store i8 0, ptr %gep.1
27 %gep.2 = getelementptr [1 x i8], ptr %ptr, i64 %n, i64 0
28 store i8 1, ptr %gep.2
32 define void @noalias_overflow_in_32_bit_constants(ptr %ptr) {
33 ; CHECK-LABEL: Function: noalias_overflow_in_32_bit_constants: 3 pointers, 0 call sites
34 ; CHECK-NEXT: MustAlias: i8* %gep.1, i8* %ptr
35 ; CHECK-NEXT: NoAlias: i8* %gep.2, i8* %ptr
36 ; CHECK-NEXT: NoAlias: i8* %gep.1, i8* %gep.2
39 %gep.1 = getelementptr i8, ptr %ptr, i64 4294967296
40 store i8 0, ptr %gep.1
41 %gep.2 = getelementptr i8, ptr %ptr, i64 1
42 store i8 1, ptr %gep.2
46 ; The GEP indices get implicitly truncated to 32 bit, so multiples of 2^32
47 ; (=4294967296) will be 0.
48 ; See https://alive2.llvm.org/ce/z/HHjQgb.
49 define void @mustalias_overflow_in_32_bit_add_mul_gep(ptr %ptr, i64 %i) {
50 ; CHECK-LABEL: Function: mustalias_overflow_in_32_bit_add_mul_gep: 3 pointers, 1 call sites
51 ; CHECK-NEXT: MayAlias: i8* %gep.1, i8* %ptr
52 ; CHECK-NEXT: MayAlias: i8* %gep.2, i8* %ptr
53 ; CHECK-NEXT: MayAlias: i8* %gep.1, i8* %gep.2
56 %s.1 = icmp sgt i64 %i, 0
57 call void @llvm.assume(i1 %s.1)
59 %mul = mul nuw nsw i64 %i, 4294967296
60 %add = add nuw nsw i64 %mul, %i
61 %gep.1 = getelementptr i8, ptr %ptr, i64 %add
62 store i8 0, ptr %gep.1
63 %gep.2 = getelementptr i8, ptr %ptr, i64 %i
64 store i8 1, ptr %gep.2
68 define void @mayalias_overflow_in_32_bit_non_zero(ptr %ptr, i64 %n) {
69 ; CHECK-LABEL: Function: mayalias_overflow_in_32_bit_non_zero
70 ; CHECK: MayAlias: i8* %gep, i8* %ptr
73 %c = icmp ne i64 %n, 0
74 call void @llvm.assume(i1 %c)
76 %gep = getelementptr i8, ptr %ptr, i64 %n
81 define void @mayalias_overflow_in_32_bit_positive(ptr %ptr, i64 %n) {
82 ; CHECK-LABEL: Function: mayalias_overflow_in_32_bit_positive
83 ; CHECK: NoAlias: i8* %gep.1, i8* %ptr
84 ; CHECK: MayAlias: i8* %gep.2, i8* %ptr
85 ; CHECK: MayAlias: i8* %gep.1, i8* %gep.2
88 %c = icmp sgt i64 %n, 0
89 call void @llvm.assume(i1 %c)
90 %gep.1 = getelementptr i8, ptr %ptr, i64 -1
91 store i8 0, ptr %gep.1
92 %gep.2 = getelementptr i8, ptr %ptr, i64 %n
93 store i8 1, ptr %gep.2