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%.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60743 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2008-12-09 06:28:49 +00:00
parent 312b9a17e6
commit 4012fdda13
2 changed files with 31 additions and 14 deletions

View File

@ -18,6 +18,7 @@
#include "llvm/Pass.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/PointerIntPair.h"
namespace llvm {
@ -28,6 +29,7 @@ namespace llvm {
class AliasAnalysis;
class TargetData;
class MemoryDependenceAnalysis;
class PredIteratorCache;
/// MemDepResult - A memory dependence query can return one of three different
/// answers, described below.
@ -193,23 +195,18 @@ namespace llvm {
/// Current AA implementation, just a cache.
AliasAnalysis *AA;
TargetData *TD;
OwningPtr<PredIteratorCache> PredCache;
public:
MemoryDependenceAnalysis() : FunctionPass(&ID) {}
MemoryDependenceAnalysis();
~MemoryDependenceAnalysis();
static char ID;
/// Pass Implementation stuff. This doesn't do any analysis eagerly.
bool runOnFunction(Function &);
/// Clean up memory in between runs
void releaseMemory() {
LocalDeps.clear();
NonLocalDeps.clear();
NonLocalPointerDeps.clear();
ReverseLocalDeps.clear();
ReverseNonLocalDeps.clear();
ReverseNonLocalPtrDeps.clear();
}
void releaseMemory();
/// getAnalysisUsage - Does not modify anything. It uses Value Numbering
/// and Alias Analysis.
///

View File

@ -21,7 +21,7 @@
#include "llvm/Function.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/PredIteratorCache.h"
#include "llvm/Support/Debug.h"
#include "llvm/Target/TargetData.h"
using namespace llvm;
@ -45,6 +45,25 @@ char MemoryDependenceAnalysis::ID = 0;
static RegisterPass<MemoryDependenceAnalysis> X("memdep",
"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.
///
void MemoryDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
@ -56,6 +75,8 @@ void MemoryDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
bool MemoryDependenceAnalysis::runOnFunction(Function &) {
AA = &getAnalysis<AliasAnalysis>();
TD = &getAnalysis<TargetData>();
if (PredCache == 0)
PredCache.reset(new PredIteratorCache());
return false;
}
@ -468,8 +489,7 @@ getNonLocalPointerDependency(Value *Pointer, bool isLoad, BasicBlock *FromBB,
// While we have blocks to analyze, get their values.
SmallPtrSet<BasicBlock*, 64> Visited;
for (pred_iterator PI = pred_begin(FromBB), E = pred_end(FromBB); PI != E;
++PI) {
for (BasicBlock **PI = PredCache->GetPreds(FromBB); *PI; ++PI) {
// TODO: PHI TRANSLATE.
getNonLocalPointerDepInternal(Pointer, PointeeSize, isLoad, *PI,
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
// 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.
Worklist.push_back(*PI);
}