[Refactor] Have getNonLocalPointerDependency take the query instruction

Previously, MemoryDependenceAnalysis::getNonLocalPointerDependency was taking a list of properties about the instruction being queried. Since I'm about to need one more property to be passed down through the infrastructure - I need to know a query instruction is non-volatile in an inner helper - fix the interface once and for all.

I also added some assertions and behaviour clarifications around volatile and ordered field accesses. At the moment, this is mostly to document expected behaviour. The only non-standard instructions which can currently reach this are atomic, but unordered, loads and stores. Neither ordered or volatile accesses can reach here.

The call in GVN is protected by an isSimple check when it first considers the load. The calls in MemDepPrinter are protected by isUnordered checks. Both utilities also check isVolatile for loads and stores.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225481 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Philip Reames
2015-01-09 00:04:22 +00:00
parent cce3a8acec
commit dba2d12578
4 changed files with 56 additions and 16 deletions

View File

@ -92,7 +92,6 @@ const char *const MemDepPrinter::DepTypeStr[]
bool MemDepPrinter::runOnFunction(Function &F) {
this->F = &F;
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
MemoryDependenceAnalysis &MDA = getAnalysis<MemoryDependenceAnalysis>();
// All this code uses non-const interfaces because MemDep is not
@ -126,8 +125,7 @@ bool MemDepPrinter::runOnFunction(Function &F) {
static_cast<BasicBlock *>(nullptr)));
continue;
}
AliasAnalysis::Location Loc = AA.getLocation(LI);
MDA.getNonLocalPointerDependency(Loc, true, LI->getParent(), NLDI);
MDA.getNonLocalPointerDependency(LI, NLDI);
} else if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
if (!SI->isUnordered()) {
// FIXME: Handle atomic/volatile stores.
@ -135,11 +133,9 @@ bool MemDepPrinter::runOnFunction(Function &F) {
static_cast<BasicBlock *>(nullptr)));
continue;
}
AliasAnalysis::Location Loc = AA.getLocation(SI);
MDA.getNonLocalPointerDependency(Loc, false, SI->getParent(), NLDI);
MDA.getNonLocalPointerDependency(SI, NLDI);
} else if (VAArgInst *VI = dyn_cast<VAArgInst>(Inst)) {
AliasAnalysis::Location Loc = AA.getLocation(VI);
MDA.getNonLocalPointerDependency(Loc, false, VI->getParent(), NLDI);
MDA.getNonLocalPointerDependency(VI, NLDI);
} else {
llvm_unreachable("Unknown memory instruction!");
}