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

Unified Diff: src/IceTargetLowering.cpp

Issue 2116213002: Subzero: Allow deeper levels of variable splitting. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 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 | « src/IceOperand.cpp ('k') | src/IceTargetLoweringMIPS32.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceTargetLowering.cpp
diff --git a/src/IceTargetLowering.cpp b/src/IceTargetLowering.cpp
index 207a76cbb0c1e060059bc7daed228c334a9ff6fb..f6c2a7810a2b48a7c47bcb63ed4969bb7f52af2b 100644
--- a/src/IceTargetLowering.cpp
+++ b/src/IceTargetLowering.cpp
@@ -564,6 +564,16 @@ void TargetLowering::sortVarsByAlignment(VarList &Dest,
});
}
+namespace {
+bool mightHaveStackSlot(const Variable *Var, const BitVector &IsVarReferenced) {
+ if (!IsVarReferenced[Var->getIndex()])
+ return false;
+ if (Var->hasReg())
+ return false;
+ return true;
+}
+} // end of anonymous namespace
+
void TargetLowering::getVarStackSlotParams(
VarList &SortedSpilledVariables, SmallBitVector &RegsUsed,
size_t *GlobalsSize, size_t *SpillAreaSizeBytes,
@@ -583,6 +593,30 @@ void TargetLowering::getVarStackSlotParams(
}
}
+ // Find each variable Var where:
+ // - Var is actively referenced
+ // - Var does not have a register
+ // - Var's furthest ancestor through LinkedTo: Root
+ // - Root has no active references, or has a register
+ //
+ // When any such Var is found, rotate the LinkedTo tree by swapping
+ // Var->LinkedTo and Root->LinkedTo. This ensures that when Var needs a stack
+ // slot, either its LinkedTo field is nullptr, or Var->getLinkedToRoot()
+ // returns a variable with a stack slot.
+ for (Variable *Var : Func->getVariables()) {
+ if (!mightHaveStackSlot(Var, IsVarReferenced))
+ continue;
+ if (Variable *Root = Var->getLinkedToRoot()) {
+ assert(Root->getLinkedTo() == nullptr);
+ if (mightHaveStackSlot(Root, IsVarReferenced)) {
+ // Found a "safe" root, no need to rotate the tree.
+ continue;
+ }
+ Var->setLinkedTo(nullptr);
+ Root->setLinkedTo(Var);
+ }
+ }
+
// If SimpleCoalescing is false, each variable without a register gets its
// own unique stack slot, which leads to large stack frames. If
// SimpleCoalescing is true, then each "global" variable without a register
« no previous file with comments | « src/IceOperand.cpp ('k') | src/IceTargetLoweringMIPS32.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698