llvm.org GIT mirror llvm / 80ed97e
LLVM 4.0: cherry-pick r293293 - "Fix BasicAA incorrect assumption on GEP" git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@293294 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 3 years ago
2 changed file(s) with 24 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
11901190 return MayAlias;
11911191
11921192 AliasResult R = aliasCheck(UnderlyingV1, MemoryLocation::UnknownSize,
1193 AAMDNodes(), V2, V2Size, V2AAInfo,
1194 nullptr, UnderlyingV2);
1193 AAMDNodes(), V2, MemoryLocation::UnknownSize,
1194 V2AAInfo, nullptr, UnderlyingV2);
11951195 if (R != MustAlias)
11961196 // If V2 may alias GEP base pointer, conservatively returns MayAlias.
11971197 // If V2 is known not to alias GEP base pointer, then the two values
1198 // cannot alias per GEP semantics: "A pointer value formed from a
1199 // getelementptr instruction is associated with the addresses associated
1200 // with the first operand of the getelementptr".
1198 // cannot alias per GEP semantics: "Any memory access must be done through
1199 // a pointer value associated with an address range of the memory access,
1200 // otherwise the behavior is undefined.".
12011201 return R;
12021202
12031203 // If the max search depth is reached the result is undefined
0 ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
1
2
3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-apple-macosx10.12.0"
5
6 %struct.blam = type { i32, i32 }
7
8
9 ; CHECK-DAG: MayAlias: i32* %tmp, i32* %tmp3
10
11 define i1 @ham(%struct.blam* %arg) {
12 %isNull = icmp eq %struct.blam* %arg, null
13 %tmp = getelementptr %struct.blam, %struct.blam* %arg, i64 0, i32 0
14 %tmp2 = getelementptr %struct.blam, %struct.blam* %arg, i64 0, i32 1
15 %select = select i1 %isNull, i32* null, i32* %tmp2
16 %tmp3 = getelementptr i32, i32* %select, i32 -1
17 ret i1 true
18 }