mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 00:24:26 +00:00
Extend the getDependence query with support for PHI translation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113521 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -340,17 +340,20 @@ public:
|
|||||||
/// WARNING: This is an experimental interface.
|
/// WARNING: This is an experimental interface.
|
||||||
DependenceResult getDependence(const Instruction *First,
|
DependenceResult getDependence(const Instruction *First,
|
||||||
const Instruction *Second) {
|
const Instruction *Second) {
|
||||||
return getDependence(First, Default, Second, Default);
|
return getDependence(First, 0, Default, Second, 0, Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getDependence - Determine the dependence relationship between the
|
/// getDependence - Determine the dependence relationship between the
|
||||||
/// instructions. This does not include "register" dependencies; it just
|
/// instructions. This does not include "register" dependencies; it just
|
||||||
/// considers memory references and other side effects. This overload
|
/// considers memory references and other side effects. This overload
|
||||||
/// accepts additional flags to refine the query.
|
/// has additional parameters to allow phi-translated addresses to be
|
||||||
|
/// specified, and additional flags to refine the query.
|
||||||
/// WARNING: This is an experimental interface.
|
/// WARNING: This is an experimental interface.
|
||||||
virtual DependenceResult getDependence(const Instruction *First,
|
virtual DependenceResult getDependence(const Instruction *First,
|
||||||
|
const Value *FirstPHITranslatedAddr,
|
||||||
DependenceQueryFlags FirstFlags,
|
DependenceQueryFlags FirstFlags,
|
||||||
const Instruction *Second,
|
const Instruction *Second,
|
||||||
|
const Value *SecondPHITranslatedAddr,
|
||||||
DependenceQueryFlags SecondFlags);
|
DependenceQueryFlags SecondFlags);
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
@ -403,8 +406,10 @@ protected:
|
|||||||
/// getDependenceViaModRefInfo - Helper function for implementing getDependence
|
/// getDependenceViaModRefInfo - Helper function for implementing getDependence
|
||||||
/// in implementations which already have getModRefInfo implementations.
|
/// in implementations which already have getModRefInfo implementations.
|
||||||
DependenceResult getDependenceViaModRefInfo(const Instruction *First,
|
DependenceResult getDependenceViaModRefInfo(const Instruction *First,
|
||||||
|
const Value *FirstPHITranslatedAddr,
|
||||||
DependenceQueryFlags FirstFlags,
|
DependenceQueryFlags FirstFlags,
|
||||||
const Instruction *Second,
|
const Instruction *Second,
|
||||||
|
const Value *SecondPHITranslatedAddr,
|
||||||
DependenceQueryFlags SecondFlags);
|
DependenceQueryFlags SecondFlags);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -190,11 +190,14 @@ AliasAnalysis::getModRefBehavior(const Function *F) {
|
|||||||
|
|
||||||
AliasAnalysis::DependenceResult
|
AliasAnalysis::DependenceResult
|
||||||
AliasAnalysis::getDependence(const Instruction *First,
|
AliasAnalysis::getDependence(const Instruction *First,
|
||||||
|
const Value *FirstPHITranslatedAddr,
|
||||||
DependenceQueryFlags FirstFlags,
|
DependenceQueryFlags FirstFlags,
|
||||||
const Instruction *Second,
|
const Instruction *Second,
|
||||||
|
const Value *SecondPHITranslatedAddr,
|
||||||
DependenceQueryFlags SecondFlags) {
|
DependenceQueryFlags SecondFlags) {
|
||||||
assert(AA && "AA didn't call InitializeAliasAnalyais in its run method!");
|
assert(AA && "AA didn't call InitializeAliasAnalyais in its run method!");
|
||||||
return AA->getDependence(First, FirstFlags, Second, SecondFlags);
|
return AA->getDependence(First, FirstPHITranslatedAddr, FirstFlags,
|
||||||
|
Second, SecondPHITranslatedAddr, SecondFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -255,17 +258,23 @@ AliasAnalysis::getModRefInfo(const VAArgInst *V, const Value *P, unsigned Size)
|
|||||||
|
|
||||||
AliasAnalysis::DependenceResult
|
AliasAnalysis::DependenceResult
|
||||||
AliasAnalysis::getDependenceViaModRefInfo(const Instruction *First,
|
AliasAnalysis::getDependenceViaModRefInfo(const Instruction *First,
|
||||||
|
const Value *FirstPHITranslatedAddr,
|
||||||
DependenceQueryFlags FirstFlags,
|
DependenceQueryFlags FirstFlags,
|
||||||
const Instruction *Second,
|
const Instruction *Second,
|
||||||
|
const Value *SecondPHITranslatedAddr,
|
||||||
DependenceQueryFlags SecondFlags) {
|
DependenceQueryFlags SecondFlags) {
|
||||||
if (const LoadInst *L = dyn_cast<LoadInst>(First)) {
|
if (const LoadInst *L = dyn_cast<LoadInst>(First)) {
|
||||||
// Be over-conservative with volatile for now.
|
// Be over-conservative with volatile for now.
|
||||||
if (L->isVolatile())
|
if (L->isVolatile())
|
||||||
return Unknown;
|
return Unknown;
|
||||||
|
|
||||||
|
// If we don't have a phi-translated address, use the actual one.
|
||||||
|
if (!FirstPHITranslatedAddr)
|
||||||
|
FirstPHITranslatedAddr = L->getPointerOperand();
|
||||||
|
|
||||||
// Forward this query to getModRefInfo.
|
// Forward this query to getModRefInfo.
|
||||||
switch (getModRefInfo(Second,
|
switch (getModRefInfo(Second,
|
||||||
L->getPointerOperand(),
|
FirstPHITranslatedAddr,
|
||||||
getTypeStoreSize(L->getType()))) {
|
getTypeStoreSize(L->getType()))) {
|
||||||
case NoModRef:
|
case NoModRef:
|
||||||
// Second doesn't reference First's memory, so they're independent.
|
// Second doesn't reference First's memory, so they're independent.
|
||||||
@ -280,10 +289,14 @@ AliasAnalysis::getDependenceViaModRefInfo(const Instruction *First,
|
|||||||
// If it's loading the same size from the same address, we can
|
// If it's loading the same size from the same address, we can
|
||||||
// give a more precise result.
|
// give a more precise result.
|
||||||
if (const LoadInst *SecondL = dyn_cast<LoadInst>(Second)) {
|
if (const LoadInst *SecondL = dyn_cast<LoadInst>(Second)) {
|
||||||
|
// If we don't have a phi-translated address, use the actual one.
|
||||||
|
if (!SecondPHITranslatedAddr)
|
||||||
|
SecondPHITranslatedAddr = SecondL->getPointerOperand();
|
||||||
|
|
||||||
unsigned LSize = getTypeStoreSize(L->getType());
|
unsigned LSize = getTypeStoreSize(L->getType());
|
||||||
unsigned SecondLSize = getTypeStoreSize(SecondL->getType());
|
unsigned SecondLSize = getTypeStoreSize(SecondL->getType());
|
||||||
if (alias(L->getPointerOperand(), LSize,
|
if (alias(FirstPHITranslatedAddr, LSize,
|
||||||
SecondL->getPointerOperand(), SecondLSize) ==
|
SecondPHITranslatedAddr, SecondLSize) ==
|
||||||
MustAlias) {
|
MustAlias) {
|
||||||
// If the loads are the same size, it's ReadThenRead.
|
// If the loads are the same size, it's ReadThenRead.
|
||||||
if (LSize == SecondLSize)
|
if (LSize == SecondLSize)
|
||||||
@ -307,10 +320,14 @@ AliasAnalysis::getDependenceViaModRefInfo(const Instruction *First,
|
|||||||
// If it's storing the same size to the same address, we can
|
// If it's storing the same size to the same address, we can
|
||||||
// give a more precise result.
|
// give a more precise result.
|
||||||
if (const StoreInst *SecondS = dyn_cast<StoreInst>(Second)) {
|
if (const StoreInst *SecondS = dyn_cast<StoreInst>(Second)) {
|
||||||
|
// If we don't have a phi-translated address, use the actual one.
|
||||||
|
if (!SecondPHITranslatedAddr)
|
||||||
|
SecondPHITranslatedAddr = SecondS->getPointerOperand();
|
||||||
|
|
||||||
unsigned LSize = getTypeStoreSize(L->getType());
|
unsigned LSize = getTypeStoreSize(L->getType());
|
||||||
unsigned SecondSSize = getTypeStoreSize(SecondS->getType());
|
unsigned SecondSSize = getTypeStoreSize(SecondS->getType());
|
||||||
if (alias(L->getPointerOperand(), LSize,
|
if (alias(FirstPHITranslatedAddr, LSize,
|
||||||
SecondS->getPointerOperand(), SecondSSize) ==
|
SecondPHITranslatedAddr, SecondSSize) ==
|
||||||
MustAlias) {
|
MustAlias) {
|
||||||
// If the load and the store are the same size, it's ReadThenWrite.
|
// If the load and the store are the same size, it's ReadThenWrite.
|
||||||
if (LSize == SecondSSize)
|
if (LSize == SecondSSize)
|
||||||
@ -332,9 +349,13 @@ AliasAnalysis::getDependenceViaModRefInfo(const Instruction *First,
|
|||||||
if (S->isVolatile())
|
if (S->isVolatile())
|
||||||
return Unknown;
|
return Unknown;
|
||||||
|
|
||||||
|
// If we don't have a phi-translated address, use the actual one.
|
||||||
|
if (!FirstPHITranslatedAddr)
|
||||||
|
FirstPHITranslatedAddr = S->getPointerOperand();
|
||||||
|
|
||||||
// Forward this query to getModRefInfo.
|
// Forward this query to getModRefInfo.
|
||||||
switch (getModRefInfo(Second,
|
switch (getModRefInfo(Second,
|
||||||
S->getPointerOperand(),
|
FirstPHITranslatedAddr,
|
||||||
getTypeStoreSize(S->getValueOperand()->getType()))) {
|
getTypeStoreSize(S->getValueOperand()->getType()))) {
|
||||||
case NoModRef:
|
case NoModRef:
|
||||||
// Second doesn't reference First's memory, so they're independent.
|
// Second doesn't reference First's memory, so they're independent.
|
||||||
@ -349,10 +370,14 @@ AliasAnalysis::getDependenceViaModRefInfo(const Instruction *First,
|
|||||||
// If it's loading the same size from the same address, we can
|
// If it's loading the same size from the same address, we can
|
||||||
// give a more precise result.
|
// give a more precise result.
|
||||||
if (const LoadInst *SecondL = dyn_cast<LoadInst>(Second)) {
|
if (const LoadInst *SecondL = dyn_cast<LoadInst>(Second)) {
|
||||||
|
// If we don't have a phi-translated address, use the actual one.
|
||||||
|
if (!SecondPHITranslatedAddr)
|
||||||
|
SecondPHITranslatedAddr = SecondL->getPointerOperand();
|
||||||
|
|
||||||
unsigned SSize = getTypeStoreSize(S->getValueOperand()->getType());
|
unsigned SSize = getTypeStoreSize(S->getValueOperand()->getType());
|
||||||
unsigned SecondLSize = getTypeStoreSize(SecondL->getType());
|
unsigned SecondLSize = getTypeStoreSize(SecondL->getType());
|
||||||
if (alias(S->getPointerOperand(), SSize,
|
if (alias(FirstPHITranslatedAddr, SSize,
|
||||||
SecondL->getPointerOperand(), SecondLSize) ==
|
SecondPHITranslatedAddr, SecondLSize) ==
|
||||||
MustAlias) {
|
MustAlias) {
|
||||||
// If the store and the load are the same size, it's WriteThenRead.
|
// If the store and the load are the same size, it's WriteThenRead.
|
||||||
if (SSize == SecondLSize)
|
if (SSize == SecondLSize)
|
||||||
@ -376,10 +401,14 @@ AliasAnalysis::getDependenceViaModRefInfo(const Instruction *First,
|
|||||||
// If it's storing the same size to the same address, we can
|
// If it's storing the same size to the same address, we can
|
||||||
// give a more precise result.
|
// give a more precise result.
|
||||||
if (const StoreInst *SecondS = dyn_cast<StoreInst>(Second)) {
|
if (const StoreInst *SecondS = dyn_cast<StoreInst>(Second)) {
|
||||||
|
// If we don't have a phi-translated address, use the actual one.
|
||||||
|
if (!SecondPHITranslatedAddr)
|
||||||
|
SecondPHITranslatedAddr = SecondS->getPointerOperand();
|
||||||
|
|
||||||
unsigned SSize = getTypeStoreSize(S->getValueOperand()->getType());
|
unsigned SSize = getTypeStoreSize(S->getValueOperand()->getType());
|
||||||
unsigned SecondSSize = getTypeStoreSize(SecondS->getType());
|
unsigned SecondSSize = getTypeStoreSize(SecondS->getType());
|
||||||
if (alias(S->getPointerOperand(), SSize,
|
if (alias(FirstPHITranslatedAddr, SSize,
|
||||||
SecondS->getPointerOperand(), SecondSSize) ==
|
SecondPHITranslatedAddr, SecondSSize) ==
|
||||||
MustAlias) {
|
MustAlias) {
|
||||||
// If the stores are the same size, it's WriteThenWrite.
|
// If the stores are the same size, it's WriteThenWrite.
|
||||||
if (SSize == SecondSSize)
|
if (SSize == SecondSSize)
|
||||||
@ -401,12 +430,20 @@ AliasAnalysis::getDependenceViaModRefInfo(const Instruction *First,
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (const VAArgInst *V = dyn_cast<VAArgInst>(First)) {
|
} else if (const VAArgInst *V = dyn_cast<VAArgInst>(First)) {
|
||||||
|
// If we don't have a phi-translated address, use the actual one.
|
||||||
|
if (!FirstPHITranslatedAddr)
|
||||||
|
FirstPHITranslatedAddr = V->getPointerOperand();
|
||||||
|
|
||||||
// Forward this query to getModRefInfo.
|
// Forward this query to getModRefInfo.
|
||||||
if (getModRefInfo(Second, V->getOperand(0), UnknownSize) == NoModRef)
|
if (getModRefInfo(Second, FirstPHITranslatedAddr, UnknownSize) == NoModRef)
|
||||||
// Second doesn't reference First's memory, so they're independent.
|
// Second doesn't reference First's memory, so they're independent.
|
||||||
return Independent;
|
return Independent;
|
||||||
|
|
||||||
} else if (ImmutableCallSite FirstCS = cast<Value>(First)) {
|
} else if (ImmutableCallSite FirstCS = cast<Value>(First)) {
|
||||||
|
assert(!FirstPHITranslatedAddr &&
|
||||||
|
!SecondPHITranslatedAddr &&
|
||||||
|
"PHI translation with calls not supported yet!");
|
||||||
|
|
||||||
// If both instructions are calls/invokes we can use the two-callsite
|
// If both instructions are calls/invokes we can use the two-callsite
|
||||||
// form of getModRefInfo.
|
// form of getModRefInfo.
|
||||||
if (ImmutableCallSite SecondCS = cast<Value>(Second))
|
if (ImmutableCallSite SecondCS = cast<Value>(Second))
|
||||||
|
@ -172,8 +172,10 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual DependenceResult getDependence(const Instruction *First,
|
virtual DependenceResult getDependence(const Instruction *First,
|
||||||
|
const Value *FirstPHITranslatedAddr,
|
||||||
DependenceQueryFlags FirstFlags,
|
DependenceQueryFlags FirstFlags,
|
||||||
const Instruction *Second,
|
const Instruction *Second,
|
||||||
|
const Value *SecondPHITranslatedAddr,
|
||||||
DependenceQueryFlags SecondFlags) {
|
DependenceQueryFlags SecondFlags) {
|
||||||
return Unknown;
|
return Unknown;
|
||||||
}
|
}
|
||||||
@ -531,8 +533,10 @@ namespace {
|
|||||||
virtual ModRefBehavior getModRefBehavior(const Function *F);
|
virtual ModRefBehavior getModRefBehavior(const Function *F);
|
||||||
|
|
||||||
virtual DependenceResult getDependence(const Instruction *First,
|
virtual DependenceResult getDependence(const Instruction *First,
|
||||||
|
const Value *FirstPHITranslatedAddr,
|
||||||
DependenceQueryFlags FirstFlags,
|
DependenceQueryFlags FirstFlags,
|
||||||
const Instruction *Second,
|
const Instruction *Second,
|
||||||
|
const Value *SecondPHITranslatedAddr,
|
||||||
DependenceQueryFlags SecondFlags);
|
DependenceQueryFlags SecondFlags);
|
||||||
|
|
||||||
/// getAdjustedAnalysisPointer - This method is used when a pass implements
|
/// getAdjustedAnalysisPointer - This method is used when a pass implements
|
||||||
@ -748,11 +752,14 @@ BasicAliasAnalysis::getModRefInfo(ImmutableCallSite CS,
|
|||||||
|
|
||||||
AliasAnalysis::DependenceResult
|
AliasAnalysis::DependenceResult
|
||||||
BasicAliasAnalysis::getDependence(const Instruction *First,
|
BasicAliasAnalysis::getDependence(const Instruction *First,
|
||||||
|
const Value *FirstPHITranslatedAddr,
|
||||||
DependenceQueryFlags FirstFlags,
|
DependenceQueryFlags FirstFlags,
|
||||||
const Instruction *Second,
|
const Instruction *Second,
|
||||||
|
const Value *SecondPHITranslatedAddr,
|
||||||
DependenceQueryFlags SecondFlags) {
|
DependenceQueryFlags SecondFlags) {
|
||||||
// We don't have anything special to say yet.
|
// We don't have anything special to say yet.
|
||||||
return getDependenceViaModRefInfo(First, FirstFlags, Second, SecondFlags);
|
return getDependenceViaModRefInfo(First, FirstPHITranslatedAddr, FirstFlags,
|
||||||
|
Second, SecondPHITranslatedAddr, SecondFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// aliasGEP - Provide a bunch of ad-hoc rules to disambiguate a GEP instruction
|
/// aliasGEP - Provide a bunch of ad-hoc rules to disambiguate a GEP instruction
|
||||||
|
Reference in New Issue
Block a user