mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-09 10:31:14 +00:00
Use global info for alias analysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31035 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5f1b698aeb
commit
096c22ea3d
@ -256,10 +256,18 @@ namespace {
|
|||||||
void GatherAllAliases(SDNode *N, SDOperand OriginalChain,
|
void GatherAllAliases(SDNode *N, SDOperand OriginalChain,
|
||||||
SmallVector<SDOperand, 8> &Aliases);
|
SmallVector<SDOperand, 8> &Aliases);
|
||||||
|
|
||||||
|
/// isAlias - Return true if there is any possibility that the two addresses
|
||||||
|
/// overlap.
|
||||||
|
bool isAlias(SDOperand Ptr1, int64_t Size1,
|
||||||
|
const Value *SrcValue1, int SrcValueOffset1,
|
||||||
|
SDOperand Ptr2, int64_t Size2,
|
||||||
|
const Value *SrcValue2, int SrcValueOffset1);
|
||||||
|
|
||||||
/// FindAliasInfo - Extracts the relevant alias information from the memory
|
/// FindAliasInfo - Extracts the relevant alias information from the memory
|
||||||
/// node. Returns true if the operand was a load.
|
/// node. Returns true if the operand was a load.
|
||||||
bool FindAliasInfo(SDNode *N,
|
bool FindAliasInfo(SDNode *N,
|
||||||
SDOperand &Ptr, int64_t &Size, const Value *&SrcValue);
|
SDOperand &Ptr, int64_t &Size,
|
||||||
|
const Value *&SrcValue, int &SrcValueOffset);
|
||||||
|
|
||||||
/// FindBetterChain - Walk up chain skipping non-aliasing memory nodes,
|
/// FindBetterChain - Walk up chain skipping non-aliasing memory nodes,
|
||||||
/// looking for a better chain (aliasing node.)
|
/// looking for a better chain (aliasing node.)
|
||||||
@ -4005,8 +4013,11 @@ static bool FindBaseOffset(SDOperand Ptr, SDOperand &Base, int64_t &Offset) {
|
|||||||
|
|
||||||
/// isAlias - Return true if there is any possibility that the two addresses
|
/// isAlias - Return true if there is any possibility that the two addresses
|
||||||
/// overlap.
|
/// overlap.
|
||||||
static bool isAlias(SDOperand Ptr1, int64_t Size1, const Value *SrcValue1,
|
bool DAGCombiner::isAlias(SDOperand Ptr1, int64_t Size1,
|
||||||
SDOperand Ptr2, int64_t Size2, const Value *SrcValue2) {
|
const Value *SrcValue1, int SrcValueOffset1,
|
||||||
|
SDOperand Ptr2, int64_t Size2,
|
||||||
|
const Value *SrcValue2, int SrcValueOffset2)
|
||||||
|
{
|
||||||
// If they are the same then they must be aliases.
|
// If they are the same then they must be aliases.
|
||||||
if (Ptr1 == Ptr2) return true;
|
if (Ptr1 == Ptr2) return true;
|
||||||
|
|
||||||
@ -4022,23 +4033,37 @@ static bool isAlias(SDOperand Ptr1, int64_t Size1, const Value *SrcValue1,
|
|||||||
return!((Offset1 + Size1) <= Offset2 || (Offset2 + Size2) <= Offset1);
|
return!((Offset1 + Size1) <= Offset2 || (Offset2 + Size2) <= Offset1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise they alias if either is unknown.
|
// If we know both bases then they can't alias.
|
||||||
return !KnownBase1 || !KnownBase2;
|
if (KnownBase1 && KnownBase2) return false;
|
||||||
|
|
||||||
|
// Use alias analysis information.
|
||||||
|
int Overlap1 = Size1 + SrcValueOffset1 + Offset1;
|
||||||
|
int Overlap2 = Size2 + SrcValueOffset2 + Offset2;
|
||||||
|
AliasAnalysis::AliasResult AAResult =
|
||||||
|
AA.alias(SrcValue1, Overlap1, SrcValue2, Overlap2);
|
||||||
|
if (AAResult == AliasAnalysis::NoAlias)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Otherwise we have to assume they alias.
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// FindAliasInfo - Extracts the relevant alias information from the memory
|
/// FindAliasInfo - Extracts the relevant alias information from the memory
|
||||||
/// node. Returns true if the operand was a load.
|
/// node. Returns true if the operand was a load.
|
||||||
bool DAGCombiner::FindAliasInfo(SDNode *N,
|
bool DAGCombiner::FindAliasInfo(SDNode *N,
|
||||||
SDOperand &Ptr, int64_t &Size, const Value *&SrcValue) {
|
SDOperand &Ptr, int64_t &Size,
|
||||||
|
const Value *&SrcValue, int &SrcValueOffset) {
|
||||||
if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N)) {
|
if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N)) {
|
||||||
Ptr = LD->getBasePtr();
|
Ptr = LD->getBasePtr();
|
||||||
Size = MVT::getSizeInBits(LD->getLoadedVT()) >> 3;
|
Size = MVT::getSizeInBits(LD->getLoadedVT()) >> 3;
|
||||||
SrcValue = LD->getSrcValue();
|
SrcValue = LD->getSrcValue();
|
||||||
|
SrcValueOffset = LD->getSrcValueOffset();
|
||||||
return true;
|
return true;
|
||||||
} else if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
|
} else if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
|
||||||
Ptr = ST->getBasePtr();
|
Ptr = ST->getBasePtr();
|
||||||
Size = MVT::getSizeInBits(ST->getStoredVT()) >> 3;
|
Size = MVT::getSizeInBits(ST->getStoredVT()) >> 3;
|
||||||
SrcValue = ST->getSrcValue();
|
SrcValue = ST->getSrcValue();
|
||||||
|
SrcValueOffset = ST->getSrcValueOffset();
|
||||||
} else {
|
} else {
|
||||||
assert(0 && "FindAliasInfo expected a memory operand");
|
assert(0 && "FindAliasInfo expected a memory operand");
|
||||||
}
|
}
|
||||||
@ -4057,7 +4082,8 @@ void DAGCombiner::GatherAllAliases(SDNode *N, SDOperand OriginalChain,
|
|||||||
SDOperand Ptr;
|
SDOperand Ptr;
|
||||||
int64_t Size;
|
int64_t Size;
|
||||||
const Value *SrcValue;
|
const Value *SrcValue;
|
||||||
bool IsLoad = FindAliasInfo(N, Ptr, Size, SrcValue);
|
int SrcValueOffset;
|
||||||
|
bool IsLoad = FindAliasInfo(N, Ptr, Size, SrcValue, SrcValueOffset);
|
||||||
|
|
||||||
// Starting off.
|
// Starting off.
|
||||||
Chains.push_back(OriginalChain);
|
Chains.push_back(OriginalChain);
|
||||||
@ -4084,11 +4110,14 @@ void DAGCombiner::GatherAllAliases(SDNode *N, SDOperand OriginalChain,
|
|||||||
SDOperand OpPtr;
|
SDOperand OpPtr;
|
||||||
int64_t OpSize;
|
int64_t OpSize;
|
||||||
const Value *OpSrcValue;
|
const Value *OpSrcValue;
|
||||||
bool IsOpLoad = FindAliasInfo(Chain.Val, OpPtr, OpSize, OpSrcValue);
|
int OpSrcValueOffset;
|
||||||
|
bool IsOpLoad = FindAliasInfo(Chain.Val, OpPtr, OpSize,
|
||||||
|
OpSrcValue, OpSrcValueOffset);
|
||||||
|
|
||||||
// If chain is alias then stop here.
|
// If chain is alias then stop here.
|
||||||
if (!(IsLoad && IsOpLoad) &&
|
if (!(IsLoad && IsOpLoad) &&
|
||||||
isAlias(Ptr, Size, SrcValue, OpPtr, OpSize, OpSrcValue)) {
|
isAlias(Ptr, Size, SrcValue, SrcValueOffset,
|
||||||
|
OpPtr, OpSize, OpSrcValue, OpSrcValueOffset)) {
|
||||||
Aliases.push_back(Chain);
|
Aliases.push_back(Chain);
|
||||||
} else {
|
} else {
|
||||||
// Look further up the chain.
|
// Look further up the chain.
|
||||||
|
Loading…
Reference in New Issue
Block a user