summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2015-01-09 00:26:45 +0000
committerPhilip Reames <listmail@philipreames.com>2015-01-09 00:26:45 +0000
commit33d7f9de332701294f6528ae7151bc40ba008737 (patch)
tree80d87d15adc64f4a3cfc6526f8f07f87fb2fafed /llvm/lib/Analysis
parentbecb60ffd9e9d0147a4136330f527009ee10c7ec (diff)
downloadbcm5719-llvm-33d7f9de332701294f6528ae7151bc40ba008737.tar.gz
bcm5719-llvm-33d7f9de332701294f6528ae7151bc40ba008737.zip
[REFACTOR] Push logic from MemDepPrinter into getNonLocalPointerDependency
Previously, MemDepPrinter handled volatile and unordered accesses without involving MemoryDependencyAnalysis. By making a slight tweak to the documented interface - which is respected by both callers - we can move this responsibility to MDA for the benefit of any future callers. This is basically just cleanup. In the future, we may decide to extend MDA's non local dependency analysis to return useful results for ordered or volatile loads. I believe (but have not really checked in detail) that local dependency analyis does get useful results for ordered, but not volatile, loads. llvm-svn: 225483
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/MemDepPrinter.cpp24
-rw-r--r--llvm/lib/Analysis/MemoryDependenceAnalysis.cpp35
2 files changed, 24 insertions, 35 deletions
diff --git a/llvm/lib/Analysis/MemDepPrinter.cpp b/llvm/lib/Analysis/MemDepPrinter.cpp
index ed77da02690..ffc9fe64cc5 100644
--- a/llvm/lib/Analysis/MemDepPrinter.cpp
+++ b/llvm/lib/Analysis/MemDepPrinter.cpp
@@ -118,27 +118,9 @@ bool MemDepPrinter::runOnFunction(Function &F) {
}
} else {
SmallVector<NonLocalDepResult, 4> NLDI;
- if (LoadInst *LI = dyn_cast<LoadInst>(Inst)) {
- if (!LI->isUnordered()) {
- // FIXME: Handle atomic/volatile loads.
- Deps[Inst].insert(std::make_pair(getInstTypePair(nullptr, Unknown),
- static_cast<BasicBlock *>(nullptr)));
- continue;
- }
- MDA.getNonLocalPointerDependency(LI, NLDI);
- } else if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
- if (!SI->isUnordered()) {
- // FIXME: Handle atomic/volatile stores.
- Deps[Inst].insert(std::make_pair(getInstTypePair(nullptr, Unknown),
- static_cast<BasicBlock *>(nullptr)));
- continue;
- }
- MDA.getNonLocalPointerDependency(SI, NLDI);
- } else if (VAArgInst *VI = dyn_cast<VAArgInst>(Inst)) {
- MDA.getNonLocalPointerDependency(VI, NLDI);
- } else {
- llvm_unreachable("Unknown memory instruction!");
- }
+ assert( (isa<LoadInst>(Inst) || isa<StoreInst>(Inst) ||
+ isa<VAArgInst>(Inst)) && "Unknown memory instruction!");
+ MDA.getNonLocalPointerDependency(Inst, NLDI);
DepSet &InstDeps = Deps[Inst];
for (SmallVectorImpl<NonLocalDepResult>::const_iterator
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
index cc459482b2c..c505aa48817 100644
--- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -881,18 +881,23 @@ getNonLocalPointerDependency(Instruction *QueryInst,
bool isLoad = isa<LoadInst>(QueryInst);
BasicBlock *FromBB = QueryInst->getParent();
assert(FromBB);
+
+ assert(Loc.Ptr->getType()->isPointerTy() &&
+ "Can't get pointer deps of a non-pointer!");
+ Result.clear();
- // This routine does not expect to deal with volatile instructions. Doing so
- // would require piping through the QueryInst all the way through.
+ // This routine does not expect to deal with volatile instructions.
+ // Doing so would require piping through the QueryInst all the way through.
// TODO: volatiles can't be elided, but they can be reordered with other
- // non-volatile accesses.
- if (LoadInst *LI = dyn_cast<LoadInst>(QueryInst)) {
- assert(!LI->isVolatile());
- } else if (StoreInst *SI = dyn_cast<StoreInst>(QueryInst)) {
- assert(!SI->isVolatile());
- }
-
-
+ // non-volatile accesses.
+ auto isVolatile = [](Instruction *Inst) {
+ if (LoadInst *LI = dyn_cast<LoadInst>(Inst)) {
+ return LI->isVolatile();
+ } else if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
+ return SI->isVolatile();
+ }
+ return false;
+ };
// We currently give up on any instruction which is ordered, but we do handle
// atomic instructions which are unordered.
// TODO: Handle ordered instructions
@@ -904,11 +909,13 @@ getNonLocalPointerDependency(Instruction *QueryInst,
}
return false;
};
- assert(!isOrdered(QueryInst) && "ordered instructions not expected");
+ if (isVolatile(QueryInst) || isOrdered(QueryInst)) {
+ Result.push_back(NonLocalDepResult(FromBB,
+ MemDepResult::getUnknown(),
+ const_cast<Value *>(Loc.Ptr)));
+ return;
+ }
- assert(Loc.Ptr->getType()->isPointerTy() &&
- "Can't get pointer deps of a non-pointer!");
- Result.clear();
PHITransAddr Address(const_cast<Value *>(Loc.Ptr), DL, AC);
OpenPOWER on IntegriCloud