Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: src/IceCfg.cpp

Issue 1253833002: Subzero: Cleanly implement register allocation after phi lowering. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Improve translation-time performance Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/IceCfgNode.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceCfg.cpp
diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp
index 7e915081700eec8a629c7d3f2fdbc61aba98a43c..99ed0bcd3b94762c9e36eb9d21ab29e8458d39a9 100644
--- a/src/IceCfg.cpp
+++ b/src/IceCfg.cpp
@@ -248,11 +248,50 @@ void Cfg::deletePhis() {
void Cfg::advancedPhiLowering() {
TimerMarker T(TimerStack::TT_advancedPhiLowering, this);
+ // Clear all previously computed live ranges (but not live-in/live-out bit
+ // vectors or last-use markers), because the follow-on register allocation is
+ // only concerned with live ranges across the newly created blocks.
+ for (Variable *Var : Variables) {
+ Var->getLiveRange().reset();
+ }
// This splits edges and appends new nodes to the end of the node
// list. This can invalidate iterators, so don't use an iterator.
SizeT NumNodes = getNumNodes();
+ SizeT NumVars = getNumVariables();
for (SizeT I = 0; I < NumNodes; ++I)
Nodes[I]->advancedPhiLowering();
+
+ TimerMarker TT(TimerStack::TT_lowerPhiAssignments, this);
+ if (true) {
+ // The following code does an in-place update of liveness and live ranges as
+ // a result of adding the new phi edge split nodes.
+ getLiveness()->initPhiEdgeSplits(Nodes.begin() + NumNodes,
+ Variables.begin() + NumVars);
+ TimerMarker TTT(TimerStack::TT_liveness, this);
+ // Iterate over the newly added nodes to add their liveness info.
+ for (auto I = Nodes.begin() + NumNodes, E = Nodes.end(); I != E; ++I) {
+ InstNumberT FirstInstNum = getNextInstNumber();
+ (*I)->renumberInstructions();
+ InstNumberT LastInstNum = getNextInstNumber() - 1;
+ // TODO(stichnot): May be able to speed up liveness and live range
+ // calculation by having it consider only pre-colored or infinite-weight
+ // variables. Could also simplify LinearScan::initForInfOnly() that way.
+ (*I)->liveness(getLiveness());
+ (*I)->livenessAddIntervals(getLiveness(), FirstInstNum, LastInstNum);
+ }
+ } else {
+ // The following code does a brute-force recalculation of live ranges as a
+ // result of adding the new phi edge split nodes. The liveness calculation
+ // is particularly expensive because the new nodes are not yet in a proper
+ // topological order and so convergence is slower.
+ //
+ // This code is kept here for reference and can be temporarily enabled in
+ // case the incremental code is under suspicion.
+ renumberInstructions();
+ liveness(Liveness_Intervals);
+ getVMetadata()->init(VMK_All);
+ }
+ Target->regAlloc(RAK_Phi);
}
// Find a reasonable placement for nodes that have not yet been
« no previous file with comments | « no previous file | src/IceCfgNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698