mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-29 06:30:39 +00:00
Finish making AliasAnalysis aware of the fact that most atomic intrinsics only dereference their arguments, and enhance
BasicAA to make use of this fact when computing ModRef info. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63718 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
39355f9fea
commit
fe9388ccb4
@ -150,6 +150,27 @@ AliasAnalysis::getModRefBehavior(CallSite CS,
|
|||||||
AliasAnalysis::ModRefBehavior
|
AliasAnalysis::ModRefBehavior
|
||||||
AliasAnalysis::getModRefBehavior(Function *F,
|
AliasAnalysis::getModRefBehavior(Function *F,
|
||||||
std::vector<PointerAccessInfo> *Info) {
|
std::vector<PointerAccessInfo> *Info) {
|
||||||
|
if (F->isIntrinsic()) {
|
||||||
|
switch (F->getIntrinsicID()) {
|
||||||
|
case Intrinsic::atomic_cmp_swap:
|
||||||
|
case Intrinsic::atomic_load_add:
|
||||||
|
case Intrinsic::atomic_load_and:
|
||||||
|
case Intrinsic::atomic_load_max:
|
||||||
|
case Intrinsic::atomic_load_min:
|
||||||
|
case Intrinsic::atomic_load_nand:
|
||||||
|
case Intrinsic::atomic_load_or:
|
||||||
|
case Intrinsic::atomic_load_sub:
|
||||||
|
case Intrinsic::atomic_load_umax:
|
||||||
|
case Intrinsic::atomic_load_umin:
|
||||||
|
case Intrinsic::atomic_load_xor:
|
||||||
|
case Intrinsic::atomic_swap:
|
||||||
|
// CAS and related intrinsics only access their arguments.
|
||||||
|
return AliasAnalysis::AccessesArguments;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (F->doesNotAccessMemory())
|
if (F->doesNotAccessMemory())
|
||||||
// Can't do better than this.
|
// Can't do better than this.
|
||||||
return DoesNotAccessMemory;
|
return DoesNotAccessMemory;
|
||||||
|
@ -256,6 +256,22 @@ bool BasicAliasAnalysis::pointsToConstantMemory(const Value *P) {
|
|||||||
//
|
//
|
||||||
AliasAnalysis::ModRefResult
|
AliasAnalysis::ModRefResult
|
||||||
BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
||||||
|
// If the function only accesses its arguments, it suffices to check that
|
||||||
|
// P does not alias any of those arguments.
|
||||||
|
if (AliasAnalysis::getModRefBehavior(CS, 0) ==
|
||||||
|
AliasAnalysis::AccessesArguments) {
|
||||||
|
bool doesAlias = false;
|
||||||
|
for (CallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
|
||||||
|
AI != AE; ++AI)
|
||||||
|
if (alias(*AI, ~0U, P, Size) != NoAlias) {
|
||||||
|
doesAlias = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!doesAlias)
|
||||||
|
return NoModRef;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isa<Constant>(P)) {
|
if (!isa<Constant>(P)) {
|
||||||
const Value *Object = P->getUnderlyingObject();
|
const Value *Object = P->getUnderlyingObject();
|
||||||
|
|
||||||
|
14
test/Analysis/BasicAA/cas.ll
Normal file
14
test/Analysis/BasicAA/cas.ll
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
; RUN: llvm-as < %s | opt -basicaa -gvn | llvm-dis | grep load | count 1
|
||||||
|
|
||||||
|
@flag0 = internal global i32 zeroinitializer
|
||||||
|
@turn = internal global i32 zeroinitializer
|
||||||
|
|
||||||
|
|
||||||
|
define i32 @main() {
|
||||||
|
%a = load i32* @flag0
|
||||||
|
%b = tail call i32 @llvm.atomic.swap.i32.p0i32(i32* @turn, i32 1)
|
||||||
|
%c = load i32* @flag0
|
||||||
|
ret i32 %c
|
||||||
|
}
|
||||||
|
|
||||||
|
declare i32 @llvm.atomic.swap.i32.p0i32(i32*, i32) nounwind
|
Loading…
Reference in New Issue
Block a user