mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
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
This commit is contained in:
parent
2a6a645709
commit
b70a571c99
@ -719,10 +719,11 @@ namespace {
|
|||||||
|
|
||||||
// This transformation requires dominator postdominator info
|
// This transformation requires dominator postdominator info
|
||||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.setPreservesCFG();
|
|
||||||
AU.addRequired<DominatorTree>();
|
AU.addRequired<DominatorTree>();
|
||||||
AU.addRequired<MemoryDependenceAnalysis>();
|
AU.addRequired<MemoryDependenceAnalysis>();
|
||||||
AU.addRequired<AliasAnalysis>();
|
AU.addRequired<AliasAnalysis>();
|
||||||
|
|
||||||
|
AU.addPreserved<DominatorTree>();
|
||||||
AU.addPreserved<AliasAnalysis>();
|
AU.addPreserved<AliasAnalysis>();
|
||||||
AU.addPreserved<MemoryDependenceAnalysis>();
|
AU.addPreserved<MemoryDependenceAnalysis>();
|
||||||
}
|
}
|
||||||
@ -1019,7 +1020,11 @@ bool GVN::processLoad(LoadInst *L, DenseMap<Value*, LoadInst*> &lastLoad,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Value* GVN::lookupNumber(BasicBlock* BB, uint32_t num) {
|
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) {
|
while (locals) {
|
||||||
DenseMap<uint32_t, Value*>::iterator I = locals->table.find(num);
|
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(),
|
for (BasicBlock::iterator BI = CurrentBlock->begin(),
|
||||||
BE = CurrentBlock->end(); BI != BE; ) {
|
BE = CurrentBlock->end(); BI != BE; ) {
|
||||||
if (isa<AllocaInst>(BI) || isa<TerminatorInst>(BI) ||
|
if (isa<AllocationInst>(BI) || isa<TerminatorInst>(BI) ||
|
||||||
isa<LoadInst>(BI) || isa<StoreInst>(BI) ||
|
isa<PHINode>(BI) || BI->mayReadFromMemory() ||
|
||||||
isa<CallInst>(BI) || isa<PHINode>(BI)) {
|
BI->mayWriteToMemory()) {
|
||||||
BI++;
|
BI++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1282,13 +1287,6 @@ bool GVN::performPRE(Function& F) {
|
|||||||
Phi->addIncoming(predMap[*PI], *PI);
|
Phi->addIncoming(predMap[*PI], *PI);
|
||||||
|
|
||||||
VN.add(Phi, valno);
|
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;
|
localAvail[CurrentBlock]->table[valno] = Phi;
|
||||||
|
|
||||||
BI->replaceAllUsesWith(Phi);
|
BI->replaceAllUsesWith(Phi);
|
||||||
|
Loading…
Reference in New Issue
Block a user