mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 07:34:33 +00:00
Introduce a symbolic constant for ~0u for use with AliasAnalysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110091 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
847a84efd2
commit
ef1cfac9e5
@ -64,6 +64,11 @@ public:
|
|||||||
AliasAnalysis() : TD(0), AA(0) {}
|
AliasAnalysis() : TD(0), AA(0) {}
|
||||||
virtual ~AliasAnalysis(); // We want to be subclassed
|
virtual ~AliasAnalysis(); // We want to be subclassed
|
||||||
|
|
||||||
|
/// UnknownSize - This is a special value which can be used with the
|
||||||
|
/// size arguments in alias queries to indicate that the caller does not
|
||||||
|
/// know the sizes of the potential memory references.
|
||||||
|
static unsigned const UnknownSize = ~0u;
|
||||||
|
|
||||||
/// getTargetData - Return a pointer to the current TargetData object, or
|
/// getTargetData - Return a pointer to the current TargetData object, or
|
||||||
/// null if no TargetData object is available.
|
/// null if no TargetData object is available.
|
||||||
///
|
///
|
||||||
@ -96,7 +101,7 @@ public:
|
|||||||
|
|
||||||
/// alias - A convenience wrapper for the case where the sizes are unknown.
|
/// alias - A convenience wrapper for the case where the sizes are unknown.
|
||||||
AliasResult alias(const Value *V1, const Value *V2) {
|
AliasResult alias(const Value *V1, const Value *V2) {
|
||||||
return alias(V1, ~0u, V2, ~0u);
|
return alias(V1, UnknownSize, V2, UnknownSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isNoAlias - A trivial helper function to check to see if the specified
|
/// isNoAlias - A trivial helper function to check to see if the specified
|
||||||
|
@ -334,7 +334,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 (!isNoAlias(cast<Value>(CI), ~0U, P, ~0U)) {
|
if (!isNoAlias(cast<Value>(CI), UnknownSize, P, UnknownSize)) {
|
||||||
PassedAsArg = true;
|
PassedAsArg = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -353,7 +353,7 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
|||||||
default: break;
|
default: break;
|
||||||
case Intrinsic::memcpy:
|
case Intrinsic::memcpy:
|
||||||
case Intrinsic::memmove: {
|
case Intrinsic::memmove: {
|
||||||
unsigned Len = ~0U;
|
unsigned Len = UnknownSize;
|
||||||
if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II->getArgOperand(2)))
|
if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II->getArgOperand(2)))
|
||||||
Len = LenCI->getZExtValue();
|
Len = LenCI->getZExtValue();
|
||||||
Value *Dest = II->getArgOperand(0);
|
Value *Dest = II->getArgOperand(0);
|
||||||
@ -490,7 +490,8 @@ BasicAliasAnalysis::aliasGEP(const GEPOperator *GEP1, unsigned V1Size,
|
|||||||
// out if the indexes to the GEP tell us anything about the derived pointer.
|
// out if the indexes to the GEP tell us anything about the derived pointer.
|
||||||
if (const GEPOperator *GEP2 = dyn_cast<GEPOperator>(V2)) {
|
if (const GEPOperator *GEP2 = dyn_cast<GEPOperator>(V2)) {
|
||||||
// Do the base pointers alias?
|
// Do the base pointers alias?
|
||||||
AliasResult BaseAlias = aliasCheck(UnderlyingV1, ~0U, UnderlyingV2, ~0U);
|
AliasResult BaseAlias = aliasCheck(UnderlyingV1, UnknownSize,
|
||||||
|
UnderlyingV2, UnknownSize);
|
||||||
|
|
||||||
// If we get a No or May, then return it immediately, no amount of analysis
|
// If we get a No or May, then return it immediately, no amount of analysis
|
||||||
// will improve this situation.
|
// will improve this situation.
|
||||||
@ -527,10 +528,10 @@ BasicAliasAnalysis::aliasGEP(const GEPOperator *GEP1, unsigned V1Size,
|
|||||||
// pointer, we know they cannot alias.
|
// pointer, we know they cannot alias.
|
||||||
|
|
||||||
// If both accesses are unknown size, we can't do anything useful here.
|
// If both accesses are unknown size, we can't do anything useful here.
|
||||||
if (V1Size == ~0U && V2Size == ~0U)
|
if (V1Size == UnknownSize && V2Size == UnknownSize)
|
||||||
return MayAlias;
|
return MayAlias;
|
||||||
|
|
||||||
AliasResult R = aliasCheck(UnderlyingV1, ~0U, V2, V2Size);
|
AliasResult R = aliasCheck(UnderlyingV1, UnknownSize, V2, V2Size);
|
||||||
if (R != MustAlias)
|
if (R != MustAlias)
|
||||||
// If V2 may alias GEP base pointer, conservatively returns MayAlias.
|
// If V2 may alias GEP base pointer, conservatively returns MayAlias.
|
||||||
// If V2 is known not to alias GEP base pointer, then the two values
|
// If V2 is known not to alias GEP base pointer, then the two values
|
||||||
@ -778,8 +779,8 @@ BasicAliasAnalysis::aliasCheck(const Value *V1, unsigned V1Size,
|
|||||||
// If the size of one access is larger than the entire object on the other
|
// If the size of one access is larger than the entire object on the other
|
||||||
// side, then we know such behavior is undefined and can assume no alias.
|
// side, then we know such behavior is undefined and can assume no alias.
|
||||||
if (TD)
|
if (TD)
|
||||||
if ((V1Size != ~0U && isObjectSmallerThan(O2, V1Size, *TD)) ||
|
if ((V1Size != UnknownSize && isObjectSmallerThan(O2, V1Size, *TD)) ||
|
||||||
(V2Size != ~0U && isObjectSmallerThan(O1, V2Size, *TD)))
|
(V2Size != UnknownSize && isObjectSmallerThan(O1, V2Size, *TD)))
|
||||||
return NoAlias;
|
return NoAlias;
|
||||||
|
|
||||||
// FIXME: This isn't aggressively handling alias(GEP, PHI) for example: if the
|
// FIXME: This isn't aggressively handling alias(GEP, PHI) for example: if the
|
||||||
|
@ -155,8 +155,8 @@ ScalarEvolutionAliasAnalysis::alias(const Value *A, unsigned ASize,
|
|||||||
Value *AO = GetBaseValue(AS);
|
Value *AO = GetBaseValue(AS);
|
||||||
Value *BO = GetBaseValue(BS);
|
Value *BO = GetBaseValue(BS);
|
||||||
if ((AO && AO != A) || (BO && BO != B))
|
if ((AO && AO != A) || (BO && BO != B))
|
||||||
if (alias(AO ? AO : A, AO ? ~0u : ASize,
|
if (alias(AO ? AO : A, AO ? UnknownSize : ASize,
|
||||||
BO ? BO : B, BO ? ~0u : BSize) == NoAlias)
|
BO ? BO : B, BO ? UnknownSize : BSize) == NoAlias)
|
||||||
return NoAlias;
|
return NoAlias;
|
||||||
|
|
||||||
// Forward the query to the next analysis.
|
// Forward the query to the next analysis.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user