forked from OSchip/llvm-project
use hte new pred cache to speed up the new non-local memdep
queries. This speeds up GVN using the new queries (not yet checked in) by just over 10%. llvm-svn: 60743
This commit is contained in:
parent
4c9bb5336a
commit
768e5bcafc
|
@ -18,6 +18,7 @@
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/ADT/DenseMap.h"
|
#include "llvm/ADT/DenseMap.h"
|
||||||
#include "llvm/ADT/SmallPtrSet.h"
|
#include "llvm/ADT/SmallPtrSet.h"
|
||||||
|
#include "llvm/ADT/OwningPtr.h"
|
||||||
#include "llvm/ADT/PointerIntPair.h"
|
#include "llvm/ADT/PointerIntPair.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
@ -28,6 +29,7 @@ namespace llvm {
|
||||||
class AliasAnalysis;
|
class AliasAnalysis;
|
||||||
class TargetData;
|
class TargetData;
|
||||||
class MemoryDependenceAnalysis;
|
class MemoryDependenceAnalysis;
|
||||||
|
class PredIteratorCache;
|
||||||
|
|
||||||
/// MemDepResult - A memory dependence query can return one of three different
|
/// MemDepResult - A memory dependence query can return one of three different
|
||||||
/// answers, described below.
|
/// answers, described below.
|
||||||
|
@ -193,23 +195,18 @@ namespace llvm {
|
||||||
/// Current AA implementation, just a cache.
|
/// Current AA implementation, just a cache.
|
||||||
AliasAnalysis *AA;
|
AliasAnalysis *AA;
|
||||||
TargetData *TD;
|
TargetData *TD;
|
||||||
|
OwningPtr<PredIteratorCache> PredCache;
|
||||||
public:
|
public:
|
||||||
MemoryDependenceAnalysis() : FunctionPass(&ID) {}
|
MemoryDependenceAnalysis();
|
||||||
|
~MemoryDependenceAnalysis();
|
||||||
static char ID;
|
static char ID;
|
||||||
|
|
||||||
/// Pass Implementation stuff. This doesn't do any analysis eagerly.
|
/// Pass Implementation stuff. This doesn't do any analysis eagerly.
|
||||||
bool runOnFunction(Function &);
|
bool runOnFunction(Function &);
|
||||||
|
|
||||||
/// Clean up memory in between runs
|
/// Clean up memory in between runs
|
||||||
void releaseMemory() {
|
void releaseMemory();
|
||||||
LocalDeps.clear();
|
|
||||||
NonLocalDeps.clear();
|
|
||||||
NonLocalPointerDeps.clear();
|
|
||||||
ReverseLocalDeps.clear();
|
|
||||||
ReverseNonLocalDeps.clear();
|
|
||||||
ReverseNonLocalPtrDeps.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// getAnalysisUsage - Does not modify anything. It uses Value Numbering
|
/// getAnalysisUsage - Does not modify anything. It uses Value Numbering
|
||||||
/// and Alias Analysis.
|
/// and Alias Analysis.
|
||||||
///
|
///
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/Analysis/AliasAnalysis.h"
|
#include "llvm/Analysis/AliasAnalysis.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/Support/CFG.h"
|
#include "llvm/Support/PredIteratorCache.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
@ -45,6 +45,25 @@ char MemoryDependenceAnalysis::ID = 0;
|
||||||
static RegisterPass<MemoryDependenceAnalysis> X("memdep",
|
static RegisterPass<MemoryDependenceAnalysis> X("memdep",
|
||||||
"Memory Dependence Analysis", false, true);
|
"Memory Dependence Analysis", false, true);
|
||||||
|
|
||||||
|
MemoryDependenceAnalysis::MemoryDependenceAnalysis()
|
||||||
|
: FunctionPass(&ID), PredCache(0) {
|
||||||
|
}
|
||||||
|
MemoryDependenceAnalysis::~MemoryDependenceAnalysis() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Clean up memory in between runs
|
||||||
|
void MemoryDependenceAnalysis::releaseMemory() {
|
||||||
|
LocalDeps.clear();
|
||||||
|
NonLocalDeps.clear();
|
||||||
|
NonLocalPointerDeps.clear();
|
||||||
|
ReverseLocalDeps.clear();
|
||||||
|
ReverseNonLocalDeps.clear();
|
||||||
|
ReverseNonLocalPtrDeps.clear();
|
||||||
|
PredCache->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// getAnalysisUsage - Does not modify anything. It uses Alias Analysis.
|
/// getAnalysisUsage - Does not modify anything. It uses Alias Analysis.
|
||||||
///
|
///
|
||||||
void MemoryDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
|
void MemoryDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
|
@ -56,6 +75,8 @@ void MemoryDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
bool MemoryDependenceAnalysis::runOnFunction(Function &) {
|
bool MemoryDependenceAnalysis::runOnFunction(Function &) {
|
||||||
AA = &getAnalysis<AliasAnalysis>();
|
AA = &getAnalysis<AliasAnalysis>();
|
||||||
TD = &getAnalysis<TargetData>();
|
TD = &getAnalysis<TargetData>();
|
||||||
|
if (PredCache == 0)
|
||||||
|
PredCache.reset(new PredIteratorCache());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,8 +489,7 @@ getNonLocalPointerDependency(Value *Pointer, bool isLoad, BasicBlock *FromBB,
|
||||||
// While we have blocks to analyze, get their values.
|
// While we have blocks to analyze, get their values.
|
||||||
SmallPtrSet<BasicBlock*, 64> Visited;
|
SmallPtrSet<BasicBlock*, 64> Visited;
|
||||||
|
|
||||||
for (pred_iterator PI = pred_begin(FromBB), E = pred_end(FromBB); PI != E;
|
for (BasicBlock **PI = PredCache->GetPreds(FromBB); *PI; ++PI) {
|
||||||
++PI) {
|
|
||||||
// TODO: PHI TRANSLATE.
|
// TODO: PHI TRANSLATE.
|
||||||
getNonLocalPointerDepInternal(Pointer, PointeeSize, isLoad, *PI,
|
getNonLocalPointerDepInternal(Pointer, PointeeSize, isLoad, *PI,
|
||||||
Result, Visited);
|
Result, Visited);
|
||||||
|
@ -592,7 +612,7 @@ getNonLocalPointerDepInternal(Value *Pointer, uint64_t PointeeSize,
|
||||||
|
|
||||||
// Otherwise, we have to process all the predecessors of this block to scan
|
// Otherwise, we have to process all the predecessors of this block to scan
|
||||||
// them as well.
|
// them as well.
|
||||||
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
|
for (BasicBlock **PI = PredCache->GetPreds(BB); *PI; ++PI) {
|
||||||
// TODO: PHI TRANSLATE.
|
// TODO: PHI TRANSLATE.
|
||||||
Worklist.push_back(*PI);
|
Worklist.push_back(*PI);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue