Index: src/IceTargetLowering.cpp |
diff --git a/src/IceTargetLowering.cpp b/src/IceTargetLowering.cpp |
index 1b9ca23bfe49eb96b1bc0dcc5ad38d72965c9adf..a2203dc44b08960deee9eeafad74fa70e175717a 100644 |
--- a/src/IceTargetLowering.cpp |
+++ b/src/IceTargetLowering.cpp |
@@ -565,16 +565,6 @@ 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, |
@@ -594,30 +584,6 @@ 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 |
@@ -647,8 +613,13 @@ void TargetLowering::getVarStackSlotParams( |
} |
// An argument either does not need a stack slot (if passed in a register) |
// or already has one (if passed on the stack). |
- if (Var->getIsArg()) |
+ if (Var->getIsArg()) { |
+ if (!Var->hasReg()) { |
+ assert(!Var->hasStackOffset()); |
+ Var->setHasStackOffset(); |
+ } |
continue; |
+ } |
// An unreferenced variable doesn't need a stack slot. |
if (!IsVarReferenced[Var->getIndex()]) |
continue; |
@@ -656,6 +627,8 @@ void TargetLowering::getVarStackSlotParams( |
// not need accounting here. |
if (TargetVarHook(Var)) |
continue; |
+ assert(!Var->hasStackOffset()); |
+ Var->setHasStackOffset(); |
SpilledVariables.push_back(Var); |
} |