1; RUN: opt -mtriple=i386-pc-linux-gnu -aa-pipeline=basic-aa -passes=inferattrs,aa-eval -print-all-alias-modref-info -disable-output 2>&1 %s | FileCheck %s 2 3; CHECK-LABEL: Function: test_memcmp_const_size 4; CHECK: Just Ref: Ptr: i8* %a <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 4) 5; CHECK-NEXT: Just Ref: Ptr: i8* %b <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 4) 6; CHECK-NEXT: Just Ref: Ptr: i8* %a.gep.1 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 4) 7; CHECK-NEXT: NoModRef: Ptr: i8* %a.gep.5 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 4) 8; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 4) 9; CHECK-NEXT: NoModRef: Ptr: i8* %b.gep.5 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 4) 10define i32 @test_memcmp_const_size(i8* noalias %a, i8* noalias %b) { 11entry: 12 load i8, i8* %a 13 load i8, i8* %b 14 %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 4) 15 %a.gep.1 = getelementptr i8, i8* %a, i32 1 16 store i8 0, i8* %a.gep.1 17 %a.gep.5 = getelementptr i8, i8* %a, i32 5 18 store i8 1, i8* %a.gep.5 19 %b.gep.1 = getelementptr i8, i8* %b, i32 1 20 store i8 2, i8* %b.gep.1 21 %b.gep.5 = getelementptr i8, i8* %b, i32 5 22 store i8 3, i8* %b.gep.5 23 ret i32 %res 24} 25 26; CHECK-LABEL: Function: test_memcmp_variable_size 27; CHECK: Just Ref: Ptr: i8* %a <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 %n) 28; CHECK-NEXT: Just Ref: Ptr: i8* %b <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 %n) 29; CHECK-NEXT: Just Ref: Ptr: i8* %a.gep.1 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 %n) 30; CHECK-NEXT: Just Ref: Ptr: i8* %a.gep.5 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 %n) 31; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 %n) 32; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.5 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 %n) 33define i32 @test_memcmp_variable_size(i8* noalias %a, i8* noalias %b, i64 %n) { 34entry: 35 load i8, i8* %a 36 load i8, i8* %b 37 %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 %n) 38 %a.gep.1 = getelementptr i8, i8* %a, i32 1 39 store i8 0, i8* %a.gep.1 40 %a.gep.5 = getelementptr i8, i8* %a, i32 5 41 store i8 1, i8* %a.gep.5 42 %b.gep.1 = getelementptr i8, i8* %b, i32 1 43 store i8 2, i8* %b.gep.1 44 %b.gep.5 = getelementptr i8, i8* %b, i32 5 45 store i8 3, i8* %b.gep.5 46 ret i32 %res 47} 48 49declare i32 @memcmp(i8*, i8*, i64) 50declare i32 @bcmp(i8*, i8*, i64) 51 52; CHECK-LABEL: Function: test_bcmp_const_size 53; CHECK: Just Ref: Ptr: i8* %a <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 4) 54; CHECK-NEXT: Just Ref: Ptr: i8* %b <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 4) 55; CHECK-NEXT: Just Ref: Ptr: i8* %a.gep.1 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 4) 56; CHECK-NEXT: NoModRef: Ptr: i8* %a.gep.5 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 4) 57; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 4) 58; CHECK-NEXT: NoModRef: Ptr: i8* %b.gep.5 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 4) 59define i32 @test_bcmp_const_size(i8* noalias %a, i8* noalias %b) { 60entry: 61 load i8, i8* %a 62 load i8, i8* %b 63 %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 4) 64 %a.gep.1 = getelementptr i8, i8* %a, i32 1 65 store i8 0, i8* %a.gep.1 66 %a.gep.5 = getelementptr i8, i8* %a, i32 5 67 store i8 1, i8* %a.gep.5 68 %b.gep.1 = getelementptr i8, i8* %b, i32 1 69 store i8 2, i8* %b.gep.1 70 %b.gep.5 = getelementptr i8, i8* %b, i32 5 71 store i8 3, i8* %b.gep.5 72 ret i32 %res 73} 74 75; CHECK-LABEL: Function: test_bcmp_variable_size 76; CHECK: Just Ref: Ptr: i8* %a <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 %n) 77; CHECK-NEXT: Just Ref: Ptr: i8* %b <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 %n) 78; CHECK-NEXT: Just Ref: Ptr: i8* %a.gep.1 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 %n) 79; CHECK-NEXT: Just Ref: Ptr: i8* %a.gep.5 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 %n) 80; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 %n) 81; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.5 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 %n) 82define i32 @test_bcmp_variable_size(i8* noalias %a, i8* noalias %b, i64 %n) { 83entry: 84 load i8, i8* %a 85 load i8, i8* %b 86 %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 %n) 87 %a.gep.1 = getelementptr i8, i8* %a, i32 1 88 store i8 0, i8* %a.gep.1 89 %a.gep.5 = getelementptr i8, i8* %a, i32 5 90 store i8 1, i8* %a.gep.5 91 %b.gep.1 = getelementptr i8, i8* %b, i32 1 92 store i8 2, i8* %b.gep.1 93 %b.gep.5 = getelementptr i8, i8* %b, i32 5 94 store i8 3, i8* %b.gep.5 95 ret i32 %res 96} 97 98declare i8* @memchr(i8*, i32, i64) 99 100; CHECK-LABEL: Function: test_memchr_const_size 101; CHECK: Just Ref: Ptr: i8* %res <-> %res = call i8* @memchr(i8* %a, i32 42, i64 4) 102; CHECK-NEXT: Just Ref: Ptr: i8* %a.gep.1 <-> %res = call i8* @memchr(i8* %a, i32 42, i64 4) 103; CHECK-NEXT: NoModRef: Ptr: i8* %a.gep.5 <-> %res = call i8* @memchr(i8* %a, i32 42, i64 4) 104define i8* @test_memchr_const_size(i8* noalias %a) { 105entry: 106 %res = call i8* @memchr(i8* %a, i32 42, i64 4) 107 load i8, i8* %res 108 %a.gep.1 = getelementptr i8, i8* %a, i32 1 109 store i8 0, i8* %a.gep.1 110 %a.gep.5 = getelementptr i8, i8* %a, i32 5 111 store i8 1, i8* %a.gep.5 112 ret i8* %res 113} 114 115declare i8* @memccpy(i8*, i8*, i32, i64) 116 117; CHECK-LABEL: Function: test_memccpy_const_size 118; CHECK: Just Mod: Ptr: i8* %a <-> %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4) 119; CHECK-NEXT: Just Ref: Ptr: i8* %b <-> %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4) 120; CHECK-NEXT: Just Mod: Ptr: i8* %res <-> %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4) 121; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.1 <-> %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4) 122; CHECK-NEXT: NoModRef: Ptr: i8* %a.gep.5 <-> %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4) 123; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4) 124; CHECK-NEXT: NoModRef: Ptr: i8* %b.gep.5 <-> %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4) 125 126define i8* @test_memccpy_const_size(i8* noalias %a, i8* noalias %b) { 127entry: 128 load i8, i8* %a 129 load i8, i8* %b 130 %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4) 131 load i8, i8* %res 132 %a.gep.1 = getelementptr i8, i8* %a, i32 1 133 store i8 0, i8* %a.gep.1 134 %a.gep.5 = getelementptr i8, i8* %a, i32 5 135 store i8 1, i8* %a.gep.5 136 %b.gep.1 = getelementptr i8, i8* %b, i32 1 137 store i8 2, i8* %b.gep.1 138 %b.gep.5 = getelementptr i8, i8* %b, i32 5 139 store i8 3, i8* %b.gep.5 140 ret i8* %res 141} 142 143declare i8* @strcat(i8*, i8*) 144 145define i8* @test_strcat_read_write_after(i8* noalias %a, i8* noalias %b) { 146; CHECK-LABEL: Function: test_strcat_read_write_after 147; CHECK: NoModRef: Ptr: i8* %a <-> %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1) 148; CHECK-NEXT: NoModRef: Ptr: i8* %b <-> %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1) 149; CHECK-NEXT: Both ModRef: Ptr: i8* %a.gep.1 <-> %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1) 150; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1) 151; CHECK-NEXT: Both ModRef: Ptr: i8* %res <-> %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1) 152; CHECK-NEXT: Both ModRef: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1) 153; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.5 <-> %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1) 154; 155entry: 156 store i8 0, i8* %a 157 store i8 2, i8* %b 158 %a.gep.1 = getelementptr i8, i8* %a, i32 1 159 load i8, i8* %a.gep.1 160 %b.gep.1 = getelementptr i8, i8* %b, i32 1 161 load i8, i8* %b.gep.1 162 %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1) 163 load i8, i8* %res 164 %a.gep.5 = getelementptr i8, i8* %a, i32 5 165 store i8 1, i8* %a.gep.5 166 %b.gep.5 = getelementptr i8, i8* %b, i32 5 167 store i8 3, i8* %b.gep.5 168 ret i8* %res 169} 170 171declare i8* @strncat(i8*, i8*, i64) 172 173define i8* @test_strncat_read_write_after(i8* noalias %a, i8* noalias %b, i64 %n) { 174; CHECK-LABEL: Function: test_strncat_read_write_after 175; CHECK: NoModRef: Ptr: i8* %a <-> %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n) 176; CHECK-NEXT: NoModRef: Ptr: i8* %b <-> %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n) 177; CHECK-NEXT: Both ModRef: Ptr: i8* %a.gep.1 <-> %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n) 178; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n) 179; CHECK-NEXT: Both ModRef: Ptr: i8* %res <-> %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n) 180; CHECK-NEXT: Both ModRef: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n) 181; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.5 <-> %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n) 182; 183entry: 184 store i8 0, i8* %a 185 store i8 2, i8* %b 186 %a.gep.1 = getelementptr i8, i8* %a, i32 1 187 load i8, i8* %a.gep.1 188 %b.gep.1 = getelementptr i8, i8* %b, i32 1 189 load i8, i8* %b.gep.1 190 %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n) 191 load i8, i8* %res 192 %a.gep.5 = getelementptr i8, i8* %a, i32 5 193 store i8 1, i8* %a.gep.5 194 %b.gep.5 = getelementptr i8, i8* %b, i32 5 195 store i8 3, i8* %b.gep.5 196 ret i8* %res 197} 198 199declare i8* @strcpy(i8*, i8*) 200 201define i8* @test_strcpy_read_write_after(i8* noalias %a, i8* noalias %b) { 202; CHECK-LABEL: Function: test_strcpy_read_write_after 203; CHECK: NoModRef: Ptr: i8* %a <-> %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1) 204; CHECK-NEXT: NoModRef: Ptr: i8* %b <-> %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1) 205; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.1 <-> %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1) 206; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1) 207; CHECK-NEXT: Just Mod: Ptr: i8* %res <-> %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1) 208; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1) 209; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.5 <-> %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1) 210; 211entry: 212 store i8 0, i8* %a 213 store i8 2, i8* %b 214 %a.gep.1 = getelementptr i8, i8* %a, i32 1 215 load i8, i8* %a.gep.1 216 %b.gep.1 = getelementptr i8, i8* %b, i32 1 217 load i8, i8* %b.gep.1 218 %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1) 219 load i8, i8* %res 220 %a.gep.5 = getelementptr i8, i8* %a, i32 5 221 store i8 1, i8* %a.gep.5 222 %b.gep.5 = getelementptr i8, i8* %b, i32 5 223 store i8 3, i8* %b.gep.5 224 ret i8* %res 225} 226 227declare i8* @strncpy(i8*, i8*, i64) 228 229define i8* @test_strncpy_const_size(i8* noalias %a, i8* noalias %b) { 230; CHECK-LABEL: Function: test_strncpy_const_size 231; CHECK: Just Mod: Ptr: i8* %a <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4) 232; CHECK-NEXT: Just Ref: Ptr: i8* %b <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4) 233; CHECK-NEXT: Just Mod: Ptr: i8* %res <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4) 234; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.1 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4) 235; CHECK-NEXT: NoModRef: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4) 236; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4) 237; CHECK-NEXT: NoModRef: Ptr: i8* %b.gep.5 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4) 238; 239entry: 240 load i8, i8* %a 241 load i8, i8* %b 242 %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4) 243 load i8, i8* %res 244 %a.gep.1 = getelementptr i8, i8* %a, i32 1 245 store i8 0, i8* %a.gep.1 246 %a.gep.5 = getelementptr i8, i8* %a, i32 5 247 store i8 1, i8* %a.gep.5 248 %b.gep.1 = getelementptr i8, i8* %b, i32 1 249 store i8 2, i8* %b.gep.1 250 %b.gep.5 = getelementptr i8, i8* %b, i32 5 251 store i8 3, i8* %b.gep.5 252 ret i8* %res 253} 254 255define i8* @test_strncpy_variable_size(i8* noalias %a, i8* noalias %b, i64 %n) { 256; CHECK-LABEL: Function: test_strncpy_variable_size 257; CHECK: Just Mod: Ptr: i8* %a <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n) 258; CHECK-NEXT: Just Ref: Ptr: i8* %b <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n) 259; CHECK-NEXT: Just Mod: Ptr: i8* %res <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n) 260; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.1 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n) 261; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n) 262; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n) 263; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.5 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n) 264; 265entry: 266 load i8, i8* %a 267 load i8, i8* %b 268 %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n) 269 load i8, i8* %res 270 %a.gep.1 = getelementptr i8, i8* %a, i32 1 271 store i8 0, i8* %a.gep.1 272 %a.gep.5 = getelementptr i8, i8* %a, i32 5 273 store i8 1, i8* %a.gep.5 274 %b.gep.1 = getelementptr i8, i8* %b, i32 1 275 store i8 2, i8* %b.gep.1 276 %b.gep.5 = getelementptr i8, i8* %b, i32 5 277 store i8 3, i8* %b.gep.5 278 ret i8* %res 279} 280 281declare i8* @__memset_chk(i8* writeonly, i32, i64, i64) 282 283; CHECK-LABEL: Function: test_memset_chk_const_size 284define i8* @test_memset_chk_const_size(i8* noalias %a, i64 %n) { 285; CHECK: Just Mod (MustAlias): Ptr: i8* %a <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 4, i64 %n) 286; CHECK-NEXT: Just Mod: Ptr: i8* %res <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 4, i64 %n) 287; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.1 <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 4, i64 %n) 288; CHECK-NEXT: NoModRef: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 4, i64 %n) 289; 290entry: 291 load i8, i8* %a 292 %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 4, i64 %n) 293 load i8, i8* %res 294 %a.gep.1 = getelementptr i8, i8* %a, i32 1 295 store i8 0, i8* %a.gep.1 296 %a.gep.5 = getelementptr i8, i8* %a, i32 5 297 store i8 1, i8* %a.gep.5 298 ret i8* %res 299} 300 301define i8* @test_memset_chk_variable_size(i8* noalias %a, i64 %n.1, i64 %n.2) { 302; CHECK-LABEL: Function: test_memset_chk_variable_size 303; CHECK: Just Mod (MustAlias): Ptr: i8* %a <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 %n.1, i64 %n.2) 304; CHECK-NEXT: Just Mod: Ptr: i8* %res <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 %n.1, i64 %n.2) 305; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.1 <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 %n.1, i64 %n.2) 306; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 %n.1, i64 %n.2) 307; 308entry: 309 load i8, i8* %a 310 %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 %n.1, i64 %n.2) 311 load i8, i8* %res 312 %a.gep.1 = getelementptr i8, i8* %a, i32 1 313 store i8 0, i8* %a.gep.1 314 %a.gep.5 = getelementptr i8, i8* %a, i32 5 315 store i8 1, i8* %a.gep.5 316 ret i8* %res 317} 318