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

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: Cleanup 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') | src/IceClFlags.cpp » ('J')
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..272d5f4156ee2753f74d44594f408c96640739b1 100644
--- a/src/IceCfg.cpp
+++ b/src/IceCfg.cpp
@@ -251,8 +251,39 @@ void Cfg::advancedPhiLowering() {
// 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();
+
+ 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);
+ // 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') | src/IceClFlags.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698