diff options
author | Owen Anderson <resistor@mac.com> | 2008-06-23 17:49:45 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2008-06-23 17:49:45 +0000 |
commit | b70a571c99932464ed828fa425ea1e2783d08fab (patch) | |
tree | 92844c25cf3f354d346b27341f9200563265bb20 /lib/Transforms | |
parent | 2a6a6457094e05e5f5ab34f90dbd25c13d61f8b5 (diff) |
Tighten the conditions under which we do PRE, remove some unneeded code, and correct our preserved analyses list, since we
do now change the CFG by splitting critical edges during PRE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52631 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/GVN.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index 26dec0fa9a..9d9dcca247 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -719,10 +719,11 @@ namespace { // This transformation requires dominator postdominator info virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesCFG(); AU.addRequired<DominatorTree>(); AU.addRequired<MemoryDependenceAnalysis>(); AU.addRequired<AliasAnalysis>(); + + AU.addPreserved<DominatorTree>(); AU.addPreserved<AliasAnalysis>(); AU.addPreserved<MemoryDependenceAnalysis>(); } @@ -1019,7 +1020,11 @@ bool GVN::processLoad(LoadInst *L, DenseMap<Value*, LoadInst*> &lastLoad, } Value* GVN::lookupNumber(BasicBlock* BB, uint32_t num) { - ValueNumberScope* locals = localAvail[BB]; + DenseMap<BasicBlock*, ValueNumberScope*>::iterator I = localAvail.find(BB); + if (I == localAvail.end()) + return 0; + + ValueNumberScope* locals = I->second; while (locals) { DenseMap<uint32_t, Value*>::iterator I = locals->table.find(num); @@ -1167,9 +1172,9 @@ bool GVN::performPRE(Function& F) { for (BasicBlock::iterator BI = CurrentBlock->begin(), BE = CurrentBlock->end(); BI != BE; ) { - if (isa<AllocaInst>(BI) || isa<TerminatorInst>(BI) || - isa<LoadInst>(BI) || isa<StoreInst>(BI) || - isa<CallInst>(BI) || isa<PHINode>(BI)) { + if (isa<AllocationInst>(BI) || isa<TerminatorInst>(BI) || + isa<PHINode>(BI) || BI->mayReadFromMemory() || + BI->mayWriteToMemory()) { BI++; continue; } @@ -1282,13 +1287,6 @@ bool GVN::performPRE(Function& F) { Phi->addIncoming(predMap[*PI], *PI); VN.add(Phi, valno); - - // The newly created PHI completely replaces the old instruction, - // so we need to update the maps to reflect this. - DomTreeNode* DTN = getAnalysis<DominatorTree>()[CurrentBlock]; - for (DomTreeNode::iterator UI = DTN->begin(), UE = DTN->end(); - UI != UE; ++UI) - localAvail[(*UI)->getBlock()]->table[valno] = Phi; localAvail[CurrentBlock]->table[valno] = Phi; BI->replaceAllUsesWith(Phi); |