llvm.org GIT mirror llvm / 9f5de6d
Make BasicAliasAnalysis recognize the fact a noalias argument cannot alias another argument, even if the other argument is not itself marked noalias. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182755 91177308-0d34-0410-b5e6-96231b3b80d8 Michael Kuperstein 7 years ago
4 changed file(s) with 51 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
583583 /// function.
584584 bool isNoAliasCall(const Value *V);
585585
586 /// isNoAliasArgument - Return true if this is an argument with the noalias
587 /// attribute.
588 bool isNoAliasArgument(const Value *V);
589
586590 /// isIdentifiedObject - Return true if this pointer refers to a distinct and
587591 /// identifiable object. This returns true for:
588592 /// Global Variables and Functions (but not Global Aliases)
536536 return false;
537537 }
538538
539 /// isNoAliasArgument - Return true if this is an argument with the noalias
540 /// attribute.
541 bool llvm::isNoAliasArgument(const Value *V)
542 {
543 if (const Argument *A = dyn_cast(V))
544 return A->hasNoAliasAttr();
545 return false;
546 }
547
539548 /// isIdentifiedObject - Return true if this pointer refers to a distinct and
540549 /// identifiable object. This returns true for:
541550 /// Global Variables and Functions (but not Global Aliases)
140140 uint64_t ObjectSize = getObjectSize(V, TD, TLI);
141141 return ObjectSize != AliasAnalysis::UnknownSize && ObjectSize == Size;
142142 }
143
144 /// isIdentifiedFunctionLocal - Return true if V is umabigously identified
145 /// at the function-level. Different IdentifiedFunctionLocals can't alias.
146 /// Further, an IdentifiedFunctionLocal can not alias with any function
147 /// arguments other than itself, which is not neccessarily true for
148 /// IdentifiedObjects.
149 static bool isIdentifiedFunctionLocal(const Value *V)
150 {
151 return isa(V) || isNoAliasCall(V) || isNoAliasArgument(V);
152 }
153
143154
144155 //===----------------------------------------------------------------------===//
145156 // GetElementPtr Instruction Decomposition and Analysis
12041215 (isa(O2) && isIdentifiedObject(O1) && !isa(O1)))
12051216 return NoAlias;
12061217
1207 // Arguments can't alias with local allocations or noalias calls
1208 // in the same function.
1209 if (((isa(O1) && (isa(O2) || isNoAliasCall(O2))) ||
1210 (isa(O2) && (isa(O1) || isNoAliasCall(O1)))))
1218 // Function arguments can't alias with things that are known to be
1219 // unambigously identified at the function level.
1220 if ((isa(O1) && isIdentifiedFunctionLocal(O2)) ||
1221 (isa(O2) && isIdentifiedFunctionLocal(O1)))
12111222 return NoAlias;
12121223
12131224 // Most objects can't alias null.
0 ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info 2>&1 | FileCheck %s
1
2 declare i32* @captures(i32* %cap) nounwind readonly
3
4 define void @no(i32* noalias %a, i32* %b) nounwind {
5 entry:
6 store i32 1, i32* %a
7 %cap = call i32* @captures(i32* %a) nounwind readonly
8 %l = load i32* %b
9 ret void
10 }
11
12 ; CHECK: NoAlias: i32* %a, i32* %b
13
14 define void @yes(i32* %c, i32* %d) nounwind {
15 entry:
16 store i32 1, i32* %c
17 %cap = call i32* @captures(i32* %c) nounwind readonly
18 %l = load i32* %d
19 ret void
20 }
21
22 ; CHECK: MayAlias: i32* %c, i32* %d