[llvm-commits] [llvm] r44786 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
Owen Anderson
resistor at mac.com
Mon Dec 10 00:07:09 PST 2007
Author: resistor
Date: Mon Dec 10 02:07:09 2007
New Revision: 44786
URL: http://llvm.org/viewvc/llvm-project?rev=44786&view=rev
Log:
A little more progress on StrongPHIElimination, now that I have a better sense of
how the CodeGen machinery works.
Modified:
llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=44786&r1=44785&r2=44786&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Mon Dec 10 02:07:09 2007
@@ -39,6 +39,9 @@
static char ID; // Pass identification, replacement for typeid
StrongPHIElimination() : MachineFunctionPass((intptr_t)&ID) {}
+ DenseMap<MachineBasicBlock*,
+ SmallVector<std::pair<unsigned, unsigned>, 2> > Waiting;
+
bool runOnMachineFunction(MachineFunction &Fn);
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
@@ -263,6 +266,8 @@
while (P->getOpcode() == TargetInstrInfo::PHI) {
LiveVariables::VarInfo& PHIInfo = LV.getVarInfo(P->getOperand(0).getReg());
+ unsigned DestReg = P->getOperand(0).getReg();
+
// Hold the names that are currently in the candidate set.
std::set<unsigned> PHIUnion;
std::set<MachineBasicBlock*> UnionedBlocks;
@@ -271,17 +276,17 @@
unsigned SrcReg = P->getOperand(i-1).getReg();
LiveVariables::VarInfo& SrcInfo = LV.getVarInfo(SrcReg);
- if (isLiveIn(SrcInfo, P->getParent())) {
+ // Check for trivial interferences
+ if (isLiveIn(SrcInfo, P->getParent()) ||
+ isLiveOut(PHIInfo, SrcInfo.DefInst->getParent()) ||
+ ( PHIInfo.DefInst->getOpcode() == TargetInstrInfo::PHI &&
+ isLiveIn(PHIInfo, SrcInfo.DefInst->getParent()) ) ||
+ ProcessedNames.count(SrcReg) ||
+ UnionedBlocks.count(SrcInfo.DefInst->getParent())) {
+
// add a copy from a_i to p in Waiting[From[a_i]]
- } else if (isLiveOut(PHIInfo, SrcInfo.DefInst->getParent())) {
- // add a copy to Waiting[From[a_i]]
- } else if (PHIInfo.DefInst->getOpcode() == TargetInstrInfo::PHI &&
- isLiveIn(PHIInfo, SrcInfo.DefInst->getParent())) {
- // add a copy to Waiting[From[a_i]]
- } else if (ProcessedNames.count(SrcReg)) {
- // add a copy to Waiting[From[a_i]]
- } else if (UnionedBlocks.count(SrcInfo.DefInst->getParent())) {
- // add a copy to Waiting[From[a_i]]
+ MachineBasicBlock* From = P->getOperand(i).getMachineBasicBlock();
+ Waiting[From].push_back(std::make_pair(SrcReg, DestReg));
} else {
PHIUnion.insert(SrcReg);
UnionedBlocks.insert(SrcInfo.DefInst->getParent());
@@ -291,7 +296,7 @@
std::vector<StrongPHIElimination::DomForestNode*> DF =
computeDomForest(PHIUnion);
- // DO STUFF HERE
+ // Walk DomForest to resolve interferences
ProcessedNames.insert(PHIUnion.begin(), PHIUnion.end());
++P;
More information about the llvm-commits
mailing list