mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-26 07:24:25 +00:00
use the new isNoAlias method to simplify some code, only do an escaping check if
we have a non-constant pointer. Constant pointers can't be local. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89665 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -127,17 +127,18 @@ AliasAnalysis::getModRefBehavior(Function *F,
|
|||||||
|
|
||||||
AliasAnalysis::ModRefResult
|
AliasAnalysis::ModRefResult
|
||||||
AliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
AliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
||||||
ModRefResult Mask = ModRef;
|
|
||||||
ModRefBehavior MRB = getModRefBehavior(CS);
|
ModRefBehavior MRB = getModRefBehavior(CS);
|
||||||
if (MRB == DoesNotAccessMemory)
|
if (MRB == DoesNotAccessMemory)
|
||||||
return NoModRef;
|
return NoModRef;
|
||||||
else if (MRB == OnlyReadsMemory)
|
|
||||||
|
ModRefResult Mask = ModRef;
|
||||||
|
if (MRB == OnlyReadsMemory)
|
||||||
Mask = Ref;
|
Mask = Ref;
|
||||||
else if (MRB == AliasAnalysis::AccessesArguments) {
|
else if (MRB == AliasAnalysis::AccessesArguments) {
|
||||||
bool doesAlias = false;
|
bool doesAlias = false;
|
||||||
for (CallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
|
for (CallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
|
||||||
AI != AE; ++AI)
|
AI != AE; ++AI)
|
||||||
if (alias(*AI, ~0U, P, Size) != NoAlias) {
|
if (!isNoAlias(*AI, ~0U, P, Size)) {
|
||||||
doesAlias = true;
|
doesAlias = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,8 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
|||||||
// If the pointer is to a locally allocated object that does not escape,
|
// If the pointer is to a locally allocated object that does not escape,
|
||||||
// then the call can not mod/ref the pointer unless the call takes the pointer
|
// then the call can not mod/ref the pointer unless the call takes the pointer
|
||||||
// as an argument, and itself doesn't capture it.
|
// as an argument, and itself doesn't capture it.
|
||||||
if (isNonEscapingLocalObject(Object) && CS.getInstruction() != Object) {
|
if (!isa<Constant>(Object) && CS.getInstruction() != Object &&
|
||||||
|
isNonEscapingLocalObject(Object)) {
|
||||||
bool PassedAsArg = false;
|
bool PassedAsArg = false;
|
||||||
unsigned ArgNo = 0;
|
unsigned ArgNo = 0;
|
||||||
for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
|
for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
|
||||||
@ -304,7 +305,7 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
|||||||
// is impossible to alias the pointer we're checking. If not, we have to
|
// is impossible to alias the pointer we're checking. If not, we have to
|
||||||
// assume that the call could touch the pointer, even though it doesn't
|
// assume that the call could touch the pointer, even though it doesn't
|
||||||
// escape.
|
// escape.
|
||||||
if (alias(cast<Value>(CI), ~0U, P, ~0U) != NoAlias) {
|
if (!isNoAlias(cast<Value>(CI), ~0U, P, ~0U)) {
|
||||||
PassedAsArg = true;
|
PassedAsArg = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -328,18 +329,20 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
|||||||
Len = LenCI->getZExtValue();
|
Len = LenCI->getZExtValue();
|
||||||
Value *Dest = II->getOperand(1);
|
Value *Dest = II->getOperand(1);
|
||||||
Value *Src = II->getOperand(2);
|
Value *Src = II->getOperand(2);
|
||||||
if (alias(Dest, Len, P, Size) == NoAlias) {
|
if (isNoAlias(Dest, Len, P, Size)) {
|
||||||
if (alias(Src, Len, P, Size) == NoAlias)
|
if (isNoAlias(Src, Len, P, Size))
|
||||||
return NoModRef;
|
return NoModRef;
|
||||||
return Ref;
|
return Ref;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Intrinsic::memset:
|
case Intrinsic::memset:
|
||||||
|
// Since memset is 'accesses arguments' only, the AliasAnalysis base class
|
||||||
|
// will handle it for the variable length case.
|
||||||
if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II->getOperand(3))) {
|
if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II->getOperand(3))) {
|
||||||
unsigned Len = LenCI->getZExtValue();
|
unsigned Len = LenCI->getZExtValue();
|
||||||
Value *Dest = II->getOperand(1);
|
Value *Dest = II->getOperand(1);
|
||||||
if (alias(Dest, Len, P, Size) == NoAlias)
|
if (isNoAlias(Dest, Len, P, Size))
|
||||||
return NoModRef;
|
return NoModRef;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -358,7 +361,7 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
|||||||
if (TD) {
|
if (TD) {
|
||||||
Value *Op1 = II->getOperand(1);
|
Value *Op1 = II->getOperand(1);
|
||||||
unsigned Op1Size = TD->getTypeStoreSize(Op1->getType());
|
unsigned Op1Size = TD->getTypeStoreSize(Op1->getType());
|
||||||
if (alias(Op1, Op1Size, P, Size) == NoAlias)
|
if (isNoAlias(Op1, Op1Size, P, Size))
|
||||||
return NoModRef;
|
return NoModRef;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -366,13 +369,13 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
|||||||
case Intrinsic::lifetime_end:
|
case Intrinsic::lifetime_end:
|
||||||
case Intrinsic::invariant_start: {
|
case Intrinsic::invariant_start: {
|
||||||
unsigned PtrSize = cast<ConstantInt>(II->getOperand(1))->getZExtValue();
|
unsigned PtrSize = cast<ConstantInt>(II->getOperand(1))->getZExtValue();
|
||||||
if (alias(II->getOperand(2), PtrSize, P, Size) == NoAlias)
|
if (isNoAlias(II->getOperand(2), PtrSize, P, Size))
|
||||||
return NoModRef;
|
return NoModRef;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Intrinsic::invariant_end: {
|
case Intrinsic::invariant_end: {
|
||||||
unsigned PtrSize = cast<ConstantInt>(II->getOperand(2))->getZExtValue();
|
unsigned PtrSize = cast<ConstantInt>(II->getOperand(2))->getZExtValue();
|
||||||
if (alias(II->getOperand(3), PtrSize, P, Size) == NoAlias)
|
if (isNoAlias(II->getOperand(3), PtrSize, P, Size))
|
||||||
return NoModRef;
|
return NoModRef;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -701,11 +704,11 @@ BasicAliasAnalysis::aliasCheck(const Value *V1, unsigned V1Size,
|
|||||||
// passes true for the StoreCaptures argument to PointerMayBeCaptured).
|
// passes true for the StoreCaptures argument to PointerMayBeCaptured).
|
||||||
if (O1 != O2) {
|
if (O1 != O2) {
|
||||||
if ((isa<CallInst>(O1) || isa<InvokeInst>(O1) || isa<LoadInst>(O1) ||
|
if ((isa<CallInst>(O1) || isa<InvokeInst>(O1) || isa<LoadInst>(O1) ||
|
||||||
isa<Argument(O1)) &&
|
isa<Argument>(O1)) &&
|
||||||
isNonEscapingLocalObject(O2))
|
isNonEscapingLocalObject(O2))
|
||||||
return NoAlias;
|
return NoAlias;
|
||||||
if ((isa<CallInst>(O2) || isa<InvokeInst>(O2) || isa<LoadInst>(O2) ||
|
if ((isa<CallInst>(O2) || isa<InvokeInst>(O2) || isa<LoadInst>(O2) ||
|
||||||
isa<Argument(O2)) &&
|
isa<Argument>(O2)) &&
|
||||||
isNonEscapingLocalObject(O1))
|
isNonEscapingLocalObject(O1))
|
||||||
return NoAlias;
|
return NoAlias;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user