mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-11 00:39:36 +00:00
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
This commit is contained in:
parent
af10fe63c6
commit
9f5de6dadc
@ -584,6 +584,10 @@ struct DenseMapInfo<AliasAnalysis::Location> {
|
||||
/// function.
|
||||
bool isNoAliasCall(const Value *V);
|
||||
|
||||
/// isNoAliasArgument - Return true if this is an argument with the noalias
|
||||
/// attribute.
|
||||
bool isNoAliasArgument(const Value *V);
|
||||
|
||||
/// isIdentifiedObject - Return true if this pointer refers to a distinct and
|
||||
/// identifiable object. This returns true for:
|
||||
/// Global Variables and Functions (but not Global Aliases)
|
||||
|
@ -537,6 +537,15 @@ bool llvm::isNoAliasCall(const Value *V) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// isNoAliasArgument - Return true if this is an argument with the noalias
|
||||
/// attribute.
|
||||
bool llvm::isNoAliasArgument(const Value *V)
|
||||
{
|
||||
if (const Argument *A = dyn_cast<Argument>(V))
|
||||
return A->hasNoAliasAttr();
|
||||
return false;
|
||||
}
|
||||
|
||||
/// isIdentifiedObject - Return true if this pointer refers to a distinct and
|
||||
/// identifiable object. This returns true for:
|
||||
/// Global Variables and Functions (but not Global Aliases)
|
||||
|
@ -142,6 +142,17 @@ static bool isObjectSize(const Value *V, uint64_t Size,
|
||||
return ObjectSize != AliasAnalysis::UnknownSize && ObjectSize == Size;
|
||||
}
|
||||
|
||||
/// isIdentifiedFunctionLocal - Return true if V is umabigously identified
|
||||
/// at the function-level. Different IdentifiedFunctionLocals can't alias.
|
||||
/// Further, an IdentifiedFunctionLocal can not alias with any function
|
||||
/// arguments other than itself, which is not neccessarily true for
|
||||
/// IdentifiedObjects.
|
||||
static bool isIdentifiedFunctionLocal(const Value *V)
|
||||
{
|
||||
return isa<AllocaInst>(V) || isNoAliasCall(V) || isNoAliasArgument(V);
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// GetElementPtr Instruction Decomposition and Analysis
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -1205,10 +1216,10 @@ BasicAliasAnalysis::aliasCheck(const Value *V1, uint64_t V1Size,
|
||||
(isa<Constant>(O2) && isIdentifiedObject(O1) && !isa<Constant>(O1)))
|
||||
return NoAlias;
|
||||
|
||||
// Arguments can't alias with local allocations or noalias calls
|
||||
// in the same function.
|
||||
if (((isa<Argument>(O1) && (isa<AllocaInst>(O2) || isNoAliasCall(O2))) ||
|
||||
(isa<Argument>(O2) && (isa<AllocaInst>(O1) || isNoAliasCall(O1)))))
|
||||
// Function arguments can't alias with things that are known to be
|
||||
// unambigously identified at the function level.
|
||||
if ((isa<Argument>(O1) && isIdentifiedFunctionLocal(O2)) ||
|
||||
(isa<Argument>(O2) && isIdentifiedFunctionLocal(O1)))
|
||||
return NoAlias;
|
||||
|
||||
// Most objects can't alias null.
|
||||
|
23
test/Analysis/BasicAA/noalias-param.ll
Normal file
23
test/Analysis/BasicAA/noalias-param.ll
Normal file
@ -0,0 +1,23 @@
|
||||
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info 2>&1 | FileCheck %s
|
||||
|
||||
declare i32* @captures(i32* %cap) nounwind readonly
|
||||
|
||||
define void @no(i32* noalias %a, i32* %b) nounwind {
|
||||
entry:
|
||||
store i32 1, i32* %a
|
||||
%cap = call i32* @captures(i32* %a) nounwind readonly
|
||||
%l = load i32* %b
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: NoAlias: i32* %a, i32* %b
|
||||
|
||||
define void @yes(i32* %c, i32* %d) nounwind {
|
||||
entry:
|
||||
store i32 1, i32* %c
|
||||
%cap = call i32* @captures(i32* %c) nounwind readonly
|
||||
%l = load i32* %d
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: MayAlias: i32* %c, i32* %d
|
Loading…
x
Reference in New Issue
Block a user