mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 20:23:59 +00:00
Don't bother counting alias results, allow the AliasAnalysisCounter to do that.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5505 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -25,14 +25,10 @@
|
|||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/GlobalValue.h"
|
#include "llvm/GlobalValue.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "Support/Statistic.h"
|
|
||||||
|
|
||||||
// Register the AliasAnalysis interface, providing a nice name to refer to.
|
// Register the AliasAnalysis interface, providing a nice name to refer to.
|
||||||
namespace {
|
namespace {
|
||||||
RegisterAnalysisGroup<AliasAnalysis> Z("Alias Analysis");
|
RegisterAnalysisGroup<AliasAnalysis> Z("Alias Analysis");
|
||||||
Statistic<> NumNoAlias ("basic-aa", "Number of 'no alias' replies");
|
|
||||||
Statistic<> NumMayAlias ("basic-aa", "Number of 'may alias' replies");
|
|
||||||
Statistic<> NumMustAlias("basic-aa", "Number of 'must alias' replies");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CanModify - Define a little visitor class that is used to check to see if
|
// CanModify - Define a little visitor class that is used to check to see if
|
||||||
@ -145,20 +141,6 @@ static const Value *getUnderlyingObject(const Value *V) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline AliasAnalysis::Result MustAlias() {
|
|
||||||
++NumMustAlias;
|
|
||||||
return AliasAnalysis::MustAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline AliasAnalysis::Result MayAlias() {
|
|
||||||
++NumMayAlias;
|
|
||||||
return AliasAnalysis::MayAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline AliasAnalysis::Result NoAlias() {
|
|
||||||
++NumNoAlias;
|
|
||||||
return AliasAnalysis::NoAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
// alias - Provide a bunch of ad-hoc rules to disambiguate in common cases, such
|
// alias - Provide a bunch of ad-hoc rules to disambiguate in common cases, such
|
||||||
// as array references. Note that this function is heavily tail recursive.
|
// as array references. Note that this function is heavily tail recursive.
|
||||||
@ -173,11 +155,11 @@ AliasAnalysis::Result BasicAliasAnalysis::alias(const Value *V1,
|
|||||||
V2 = CPR->getValue();
|
V2 = CPR->getValue();
|
||||||
|
|
||||||
// Are we checking for alias of the same value?
|
// Are we checking for alias of the same value?
|
||||||
if (V1 == V2) return ::MustAlias();
|
if (V1 == V2) return MustAlias;
|
||||||
|
|
||||||
if ((!isa<PointerType>(V1->getType()) || !isa<PointerType>(V2->getType())) &&
|
if ((!isa<PointerType>(V1->getType()) || !isa<PointerType>(V2->getType())) &&
|
||||||
V1->getType() != Type::LongTy && V2->getType() != Type::LongTy)
|
V1->getType() != Type::LongTy && V2->getType() != Type::LongTy)
|
||||||
return ::NoAlias(); // Scalars cannot alias each other
|
return NoAlias; // Scalars cannot alias each other
|
||||||
|
|
||||||
// Strip off cast instructions...
|
// Strip off cast instructions...
|
||||||
if (const Instruction *I = dyn_cast<CastInst>(V1))
|
if (const Instruction *I = dyn_cast<CastInst>(V1))
|
||||||
@ -216,7 +198,7 @@ AliasAnalysis::Result BasicAliasAnalysis::alias(const Value *V1,
|
|||||||
//
|
//
|
||||||
if (AllConstant &&
|
if (AllConstant &&
|
||||||
alias(GEP1->getOperand(0), GEP2->getOperand(1)) != MayAlias)
|
alias(GEP1->getOperand(0), GEP2->getOperand(1)) != MayAlias)
|
||||||
return ::NoAlias();
|
return NoAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Figure out what objects these things are pointing to if we can...
|
// Figure out what objects these things are pointing to if we can...
|
||||||
@ -226,16 +208,16 @@ AliasAnalysis::Result BasicAliasAnalysis::alias(const Value *V1,
|
|||||||
// Pointing at a discernable object?
|
// Pointing at a discernable object?
|
||||||
if (O1 && O2) {
|
if (O1 && O2) {
|
||||||
// If they are two different objects, we know that we have no alias...
|
// If they are two different objects, we know that we have no alias...
|
||||||
if (O1 != O2) return ::NoAlias();
|
if (O1 != O2) return NoAlias;
|
||||||
|
|
||||||
// If they are the same object, they we can look at the indexes. If they
|
// If they are the same object, they we can look at the indexes. If they
|
||||||
// index off of the object is the same for both pointers, they must alias.
|
// index off of the object is the same for both pointers, they must alias.
|
||||||
// If they are provably different, they must not alias. Otherwise, we can't
|
// If they are provably different, they must not alias. Otherwise, we can't
|
||||||
// tell anything.
|
// tell anything.
|
||||||
} else if (O1 && isa<ConstantPointerNull>(V2)) {
|
} else if (O1 && isa<ConstantPointerNull>(V2)) {
|
||||||
return ::NoAlias(); // Unique values don't alias null
|
return NoAlias; // Unique values don't alias null
|
||||||
} else if (O2 && isa<ConstantPointerNull>(V1)) {
|
} else if (O2 && isa<ConstantPointerNull>(V1)) {
|
||||||
return ::NoAlias(); // Unique values don't alias null
|
return NoAlias; // Unique values don't alias null
|
||||||
}
|
}
|
||||||
|
|
||||||
return MayAlias;
|
return MayAlias;
|
||||||
|
@ -9,12 +9,6 @@
|
|||||||
#include "llvm/Analysis/DSGraph.h"
|
#include "llvm/Analysis/DSGraph.h"
|
||||||
#include "llvm/Analysis/AliasAnalysis.h"
|
#include "llvm/Analysis/AliasAnalysis.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "Support/Statistic.h"
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
Statistic<> NumNoAlias ("ds-aa", "Number of 'no alias' replies");
|
|
||||||
Statistic<> NumMayAlias ("ds-aa", "Number of 'may alias' replies");
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class DSAA : public Pass, public AliasAnalysis {
|
class DSAA : public Pass, public AliasAnalysis {
|
||||||
@ -104,25 +98,20 @@ AliasAnalysis::Result DSAA::alias(const Value *V1, const Value *V2) {
|
|||||||
if (I->second.getNode() != J->second.getNode()) {
|
if (I->second.getNode() != J->second.getNode()) {
|
||||||
// Return noalias if one of the nodes is complete...
|
// Return noalias if one of the nodes is complete...
|
||||||
if ((~I->second.getNode()->NodeType | ~J->second.getNode()->NodeType)
|
if ((~I->second.getNode()->NodeType | ~J->second.getNode()->NodeType)
|
||||||
& DSNode::Incomplete) {
|
& DSNode::Incomplete)
|
||||||
++NumNoAlias;
|
|
||||||
return NoAlias;
|
return NoAlias;
|
||||||
}
|
|
||||||
// both are incomplete, they may alias...
|
// both are incomplete, they may alias...
|
||||||
} else {
|
} else {
|
||||||
// Both point to the same node, see if they point to different
|
// Both point to the same node, see if they point to different
|
||||||
// offsets... FIXME: This needs to know the size of the alias query
|
// offsets... FIXME: This needs to know the size of the alias query
|
||||||
if (I->second.getOffset() != J->second.getOffset()) {
|
if (I->second.getOffset() != J->second.getOffset())
|
||||||
++NumNoAlias;
|
|
||||||
return NoAlias;
|
return NoAlias;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: we could improve on this by checking the globals graph for aliased
|
// FIXME: we could improve on this by checking the globals graph for aliased
|
||||||
// global queries...
|
// global queries...
|
||||||
++NumMayAlias;
|
|
||||||
return getAnalysis<AliasAnalysis>().alias(V1, V2);
|
return getAnalysis<AliasAnalysis>().alias(V1, V2);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user