mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 00:21:03 +00:00
Some more clean-up, and squash an IDF-Phi related bug.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28680 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -50,7 +50,7 @@ namespace {
|
|||||||
|
|
||||||
|
|
||||||
LoopInfo *LI; // Loop information
|
LoopInfo *LI; // Loop information
|
||||||
DominatorTree *DT; // Dominator Tree for the current Loop...
|
DominatorTree *DT; // Dominator Tree for the current Function...
|
||||||
DominanceFrontier *DF; // Current Dominance Frontier
|
DominanceFrontier *DF; // Current Dominance Frontier
|
||||||
std::vector<BasicBlock*> *LoopBlocks;
|
std::vector<BasicBlock*> *LoopBlocks;
|
||||||
|
|
||||||
@@ -149,7 +149,8 @@ void LCSSA::processInstruction(Instruction* Instr,
|
|||||||
for (std::vector<BasicBlock*>::const_iterator BBI = exitBlocks.begin(),
|
for (std::vector<BasicBlock*>::const_iterator BBI = exitBlocks.begin(),
|
||||||
BBE = exitBlocks.end(); BBI != BBE; ++BBI)
|
BBE = exitBlocks.end(); BBI != BBE; ++BBI)
|
||||||
if (DT->getNode(Instr->getParent())->dominates(DT->getNode(*BBI))) {
|
if (DT->getNode(Instr->getParent())->dominates(DT->getNode(*BBI))) {
|
||||||
PHINode *phi = new PHINode(Instr->getType(), "lcssa", (*BBI)->begin());
|
PHINode *phi = new PHINode(Instr->getType(), Instr->getName()+".lcssa",
|
||||||
|
(*BBI)->begin());
|
||||||
workList.push_back(phi);
|
workList.push_back(phi);
|
||||||
Phis[*BBI] = phi;
|
Phis[*BBI] = phi;
|
||||||
}
|
}
|
||||||
@@ -174,16 +175,19 @@ void LCSSA::processInstruction(Instruction* Instr,
|
|||||||
const DominanceFrontier::DomSetType &S = it->second;
|
const DominanceFrontier::DomSetType &S = it->second;
|
||||||
for (DominanceFrontier::DomSetType::const_iterator P = S.begin(),
|
for (DominanceFrontier::DomSetType::const_iterator P = S.begin(),
|
||||||
PE = S.end(); P != PE; ++P) {
|
PE = S.end(); P != PE; ++P) {
|
||||||
|
if (DT->getNode(Instr->getParent())->dominates(DT->getNode(*P))) {
|
||||||
Instruction *&Phi = Phis[*P];
|
Instruction *&Phi = Phis[*P];
|
||||||
if (Phi == 0) {
|
if (Phi == 0) {
|
||||||
// Still doesn't have operands...
|
// Still doesn't have operands...
|
||||||
Phi = new PHINode(Instr->getType(), "lcssa", (*P)->begin());
|
Phi = new PHINode(Instr->getType(), Instr->getName()+".lcssa",
|
||||||
|
(*P)->begin());
|
||||||
|
|
||||||
workList.push_back(cast<PHINode>(Phi));
|
workList.push_back(cast<PHINode>(Phi));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fill in all Phis we've inserted that need their incoming values filled in.
|
// Fill in all Phis we've inserted that need their incoming values filled in.
|
||||||
for (std::vector<PHINode*>::iterator IVI = needIncomingValues.begin(),
|
for (std::vector<PHINode*>::iterator IVI = needIncomingValues.begin(),
|
||||||
@@ -200,18 +204,11 @@ void LCSSA::processInstruction(Instruction* Instr,
|
|||||||
for (Instruction::use_iterator UI = Instr->use_begin(), UE = Instr->use_end();
|
for (Instruction::use_iterator UI = Instr->use_begin(), UE = Instr->use_end();
|
||||||
UI != UE; ++UI) {
|
UI != UE; ++UI) {
|
||||||
Instruction* use = cast<Instruction>(*UI);
|
Instruction* use = cast<Instruction>(*UI);
|
||||||
// Don't need to update uses within the loop body, and we don't want to
|
// Don't need to update uses within the loop body.
|
||||||
// overwrite the Phi nodes that we inserted into the exit blocks either.
|
if (!inLoopBlocks(use->getParent()))
|
||||||
if (!inLoopBlocks(use->getParent()) &&
|
|
||||||
!(std::binary_search(exitBlocks.begin(), exitBlocks.end(),
|
|
||||||
use->getParent()) && isa<PHINode>(use)))
|
|
||||||
Uses.push_back(use);
|
Uses.push_back(use);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deliberately remove the initial instruction from Phis set. It would mess
|
|
||||||
// up use-replacement.
|
|
||||||
Phis.erase(Instr->getParent());
|
|
||||||
|
|
||||||
for (std::vector<Instruction*>::iterator II = Uses.begin(), IE = Uses.end();
|
for (std::vector<Instruction*>::iterator II = Uses.begin(), IE = Uses.end();
|
||||||
II != IE; ++II) {
|
II != IE; ++II) {
|
||||||
if (PHINode* phi = dyn_cast<PHINode>(*II)) {
|
if (PHINode* phi = dyn_cast<PHINode>(*II)) {
|
||||||
|
Reference in New Issue
Block a user