mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 23:32:27 +00:00
The VersionNumbers vector is only used during PHI placement. Turn it into an argument, allowing us to get rid of the vector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8864 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
afa060ea3f
commit
3c881cb4ce
@ -49,9 +49,6 @@ namespace {
|
|||||||
// AllocaLookup - Reverse mapping of Allocas
|
// AllocaLookup - Reverse mapping of Allocas
|
||||||
std::map<AllocaInst*, unsigned> AllocaLookup;
|
std::map<AllocaInst*, unsigned> AllocaLookup;
|
||||||
|
|
||||||
// VersionNumbers - Current version counters for each alloca
|
|
||||||
std::vector<unsigned> VersionNumbers;
|
|
||||||
|
|
||||||
// NewPhiNodes - The PhiNodes we're adding.
|
// NewPhiNodes - The PhiNodes we're adding.
|
||||||
std::map<BasicBlock*, std::vector<PHINode*> > NewPhiNodes;
|
std::map<BasicBlock*, std::vector<PHINode*> > NewPhiNodes;
|
||||||
|
|
||||||
@ -67,15 +64,13 @@ namespace {
|
|||||||
private:
|
private:
|
||||||
void RenamePass(BasicBlock *BB, BasicBlock *Pred,
|
void RenamePass(BasicBlock *BB, BasicBlock *Pred,
|
||||||
std::vector<Value*> &IncVals);
|
std::vector<Value*> &IncVals);
|
||||||
bool QueuePhiNode(BasicBlock *BB, unsigned AllocaIdx);
|
bool QueuePhiNode(BasicBlock *BB, unsigned AllocaIdx, unsigned &Version);
|
||||||
};
|
};
|
||||||
} // end of anonymous namespace
|
} // end of anonymous namespace
|
||||||
|
|
||||||
void PromoteMem2Reg::run() {
|
void PromoteMem2Reg::run() {
|
||||||
Function &F = *DF.getRoot()->getParent();
|
Function &F = *DF.getRoot()->getParent();
|
||||||
|
|
||||||
VersionNumbers.resize(Allocas.size());
|
|
||||||
|
|
||||||
for (unsigned i = 0; i != Allocas.size(); ++i) {
|
for (unsigned i = 0; i != Allocas.size(); ++i) {
|
||||||
AllocaInst *AI = Allocas[i];
|
AllocaInst *AI = Allocas[i];
|
||||||
|
|
||||||
@ -101,6 +96,7 @@ void PromoteMem2Reg::run() {
|
|||||||
// Compute the locations where PhiNodes need to be inserted. Look at the
|
// Compute the locations where PhiNodes need to be inserted. Look at the
|
||||||
// dominance frontier of EACH basic-block we have a write in.
|
// dominance frontier of EACH basic-block we have a write in.
|
||||||
//
|
//
|
||||||
|
unsigned CurrentVersion = 0;
|
||||||
while (!DefiningBlocks.empty()) {
|
while (!DefiningBlocks.empty()) {
|
||||||
BasicBlock *BB = DefiningBlocks.back();
|
BasicBlock *BB = DefiningBlocks.back();
|
||||||
DefiningBlocks.pop_back();
|
DefiningBlocks.pop_back();
|
||||||
@ -111,7 +107,7 @@ void PromoteMem2Reg::run() {
|
|||||||
const DominanceFrontier::DomSetType &S = it->second;
|
const DominanceFrontier::DomSetType &S = it->second;
|
||||||
for (DominanceFrontier::DomSetType::iterator P = S.begin(),PE = S.end();
|
for (DominanceFrontier::DomSetType::iterator P = S.begin(),PE = S.end();
|
||||||
P != PE; ++P)
|
P != PE; ++P)
|
||||||
if (QueuePhiNode(*P, i))
|
if (QueuePhiNode(*P, i, CurrentVersion))
|
||||||
DefiningBlocks.push_back(*P);
|
DefiningBlocks.push_back(*P);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,7 +195,8 @@ void PromoteMem2Reg::run() {
|
|||||||
// QueuePhiNode - queues a phi-node to be added to a basic-block for a specific
|
// QueuePhiNode - queues a phi-node to be added to a basic-block for a specific
|
||||||
// Alloca returns true if there wasn't already a phi-node for that variable
|
// Alloca returns true if there wasn't already a phi-node for that variable
|
||||||
//
|
//
|
||||||
bool PromoteMem2Reg::QueuePhiNode(BasicBlock *BB, unsigned AllocaNo) {
|
bool PromoteMem2Reg::QueuePhiNode(BasicBlock *BB, unsigned AllocaNo,
|
||||||
|
unsigned &Version) {
|
||||||
// Look up the basic-block in question
|
// Look up the basic-block in question
|
||||||
std::vector<PHINode*> &BBPNs = NewPhiNodes[BB];
|
std::vector<PHINode*> &BBPNs = NewPhiNodes[BB];
|
||||||
if (BBPNs.empty()) BBPNs.resize(Allocas.size());
|
if (BBPNs.empty()) BBPNs.resize(Allocas.size());
|
||||||
@ -211,8 +208,7 @@ bool PromoteMem2Reg::QueuePhiNode(BasicBlock *BB, unsigned AllocaNo) {
|
|||||||
// BasicBlock.
|
// BasicBlock.
|
||||||
BBPNs[AllocaNo] = new PHINode(Allocas[AllocaNo]->getAllocatedType(),
|
BBPNs[AllocaNo] = new PHINode(Allocas[AllocaNo]->getAllocatedType(),
|
||||||
Allocas[AllocaNo]->getName() + "." +
|
Allocas[AllocaNo]->getName() + "." +
|
||||||
utostr(VersionNumbers[AllocaNo]++),
|
utostr(Version++), BB->begin());
|
||||||
BB->begin());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user