[llvm-commits] [llvm] r44019 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
Owen Anderson
resistor at mac.com
Mon Nov 12 09:27:28 PST 2007
Author: resistor
Date: Mon Nov 12 11:27:27 2007
New Revision: 44019
URL: http://llvm.org/viewvc/llvm-project?rev=44019&view=rev
Log:
Break critical edges coming into blocks with PHI nodes.
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=44019&r1=44018&r2=44019&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Mon Nov 12 11:27:27 2007
@@ -93,6 +93,7 @@
void processBlock(MachineBasicBlock* MBB);
std::vector<DomForestNode*> computeDomForest(std::set<unsigned>& instrs);
+ void breakCriticalEdges(MachineFunction &Fn);
};
@@ -295,7 +296,32 @@
}
}
+void StrongPHIElimination::breakCriticalEdges(MachineFunction &Fn) {
+ typedef std::pair<MachineBasicBlock*, MachineBasicBlock*> MBB_pair;
+
+ MachineDominatorTree& MDT = getAnalysis<MachineDominatorTree>();
+ //LiveVariables& LV = getAnalysis<LiveVariables>();
+
+ std::vector<MBB_pair> criticals;
+ for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
+ if (!I->empty() &&
+ I->begin()->getOpcode() == TargetInstrInfo::PHI &&
+ I->pred_size() > 1)
+ for (MachineBasicBlock::pred_iterator PI = I->pred_begin(),
+ PE = I->pred_end(); PI != PE; ++PI)
+ if ((*PI)->succ_size() > 1)
+ criticals.push_back(std::make_pair(*PI, I));
+
+ for (std::vector<MBB_pair>::iterator I = criticals.begin(),
+ E = criticals.end(); I != E; ++I) {
+ SplitCriticalMachineEdge(I->first, I->second);
+
+ MDT.splitBlock(I->first);
+ }
+}
+
bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) {
+ breakCriticalEdges(Fn);
computeDFS(Fn);
for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
More information about the llvm-commits
mailing list