Commit f9df4523 by Jim Stichnoth

Subzero: Completely remove tracking of stack pointer live range.

Specifically, if a variable is marked with IgnoreLiveness=true, then: 1. Completely avoid adding any segments to its live range 2. Assert that no one tries to add segments to its live range This is done in part by incorporating Variable::IgnoreLiveness into Liveness::RangeMask. Also, change a functor into a lambda because C++11. BUG= none R=jvoung@chromium.org Review URL: https://codereview.chromium.org/1273823003.
parent 88ab5ca4
...@@ -667,15 +667,13 @@ void CfgNode::livenessAddIntervals(Liveness *Liveness, InstNumberT FirstInstNum, ...@@ -667,15 +667,13 @@ void CfgNode::livenessAddIntervals(Liveness *Liveness, InstNumberT FirstInstNum,
std::sort(MapBegin.begin(), MapBegin.end()); std::sort(MapBegin.begin(), MapBegin.end());
std::sort(MapEnd.begin(), MapEnd.end()); std::sort(MapEnd.begin(), MapEnd.end());
// Verify there are no duplicates. // Verify there are no duplicates.
struct ComparePair { auto ComparePair =
bool operator()(const LiveBeginEndMapEntry &A, [](const LiveBeginEndMapEntry &A, const LiveBeginEndMapEntry &B) {
const LiveBeginEndMapEntry &B) { return A.first == B.first;
return A.first == B.first; };
} assert(std::adjacent_find(MapBegin.begin(), MapBegin.end(), ComparePair) ==
};
assert(std::adjacent_find(MapBegin.begin(), MapBegin.end(), ComparePair()) ==
MapBegin.end()); MapBegin.end());
assert(std::adjacent_find(MapEnd.begin(), MapEnd.end(), ComparePair()) == assert(std::adjacent_find(MapEnd.begin(), MapEnd.end(), ComparePair) ==
MapEnd.end()); MapEnd.end());
LivenessBV LiveInAndOut = LiveIn; LivenessBV LiveInAndOut = LiveIn;
...@@ -700,21 +698,16 @@ void CfgNode::livenessAddIntervals(Liveness *Liveness, InstNumberT FirstInstNum, ...@@ -700,21 +698,16 @@ void CfgNode::livenessAddIntervals(Liveness *Liveness, InstNumberT FirstInstNum,
InstNumberT LE = i == i2 ? IEB->second : LastInstNum + 1; InstNumberT LE = i == i2 ? IEB->second : LastInstNum + 1;
Variable *Var = Liveness->getVariable(i, this); Variable *Var = Liveness->getVariable(i, this);
// TODO(stichnot): Push getIgnoreLiveness() into the initialization of if (LB > LE) {
// Liveness::RangeMask so that LiveBegin and LiveEnd never even reference Var->addLiveRange(FirstInstNum, LE, 1);
// such variables. Var->addLiveRange(LB, LastInstNum + 1, 1);
if (!Var->getIgnoreLiveness()) { // Assert that Var is a global variable by checking that its
if (LB > LE) { // liveness index is less than the number of globals. This
Var->addLiveRange(FirstInstNum, LE, 1); // ensures that the LiveInAndOut[] access is valid.
Var->addLiveRange(LB, LastInstNum + 1, 1); assert(i < Liveness->getNumGlobalVars());
// Assert that Var is a global variable by checking that its LiveInAndOut[i] = false;
// liveness index is less than the number of globals. This } else {
// ensures that the LiveInAndOut[] access is valid. Var->addLiveRange(LB, LE, 1);
assert(i < Liveness->getNumGlobalVars());
LiveInAndOut[i] = false;
} else {
Var->addLiveRange(LB, LE, 1);
}
} }
if (i == i1) if (i == i1)
++IBB; ++IBB;
......
...@@ -71,8 +71,12 @@ void Liveness::initInternal(NodeList::const_iterator FirstNode, ...@@ -71,8 +71,12 @@ void Liveness::initInternal(NodeList::const_iterator FirstNode,
if (IsFullInit) if (IsFullInit)
LiveToVarMap.assign(NumGlobals, nullptr); LiveToVarMap.assign(NumGlobals, nullptr);
// Sort each variable into the appropriate LiveToVarMap. Also set // Initialize the bitmask of which variables to track.
// VarToLiveMap. RangeMask.resize(NumVars);
RangeMask.set(0, NumVars); // Track all variables by default.
// Sort each variable into the appropriate LiveToVarMap. Set VarToLiveMap.
// Set RangeMask correctly for each variable.
TmpNumGlobals = 0; TmpNumGlobals = 0;
for (auto I = FirstVar, E = Func->getVariables().end(); I != E; ++I) { for (auto I = FirstVar, E = Func->getVariables().end(); I != E; ++I) {
Variable *Var = *I; Variable *Var = *I;
...@@ -88,9 +92,20 @@ void Liveness::initInternal(NodeList::const_iterator FirstNode, ...@@ -88,9 +92,20 @@ void Liveness::initInternal(NodeList::const_iterator FirstNode,
LiveIndex += NumGlobals; LiveIndex += NumGlobals;
} }
VarToLiveMap[VarIndex] = LiveIndex; VarToLiveMap[VarIndex] = LiveIndex;
if (Var->getIgnoreLiveness())
RangeMask[VarIndex] = false;
} }
assert(TmpNumGlobals == (IsFullInit ? NumGlobals : 0)); assert(TmpNumGlobals == (IsFullInit ? NumGlobals : 0));
// Fix up RangeMask for variables before FirstVar.
for (auto I = Func->getVariables().begin(); I != FirstVar; ++I) {
Variable *Var = *I;
SizeT VarIndex = Var->getIndex();
if (Var->getIgnoreLiveness() ||
(!IsFullInit && !Var->hasReg() && !Var->getWeight().isInf()))
RangeMask[VarIndex] = false;
}
// Process each node. // Process each node.
for (auto I = FirstNode, E = Func->getNodes().end(); I != E; ++I) { for (auto I = FirstNode, E = Func->getNodes().end(); I != E; ++I) {
LivenessNode &Node = Nodes[(*I)->getIndex()]; LivenessNode &Node = Nodes[(*I)->getIndex()];
...@@ -100,17 +115,6 @@ void Liveness::initInternal(NodeList::const_iterator FirstNode, ...@@ -100,17 +115,6 @@ void Liveness::initInternal(NodeList::const_iterator FirstNode,
// LiveBegin and LiveEnd are reinitialized before each pass over // LiveBegin and LiveEnd are reinitialized before each pass over
// the block. // the block.
} }
// Initialize the bitmask of which variables to track.
RangeMask.resize(NumVars);
RangeMask.set(0, NumVars);
if (!IsFullInit) {
// Reset initial variables that are not pre-colored or infinite-weight.
for (auto I = Func->getVariables().begin(); I != FirstVar; ++I) {
Variable *Var = *I;
RangeMask[Var->getIndex()] = (Var->hasReg() || Var->getWeight().isInf());
}
}
} }
void Liveness::init() { void Liveness::init() {
......
...@@ -463,6 +463,7 @@ public: ...@@ -463,6 +463,7 @@ public:
void setLiveRange(const LiveRange &Range) { Live = Range; } void setLiveRange(const LiveRange &Range) { Live = Range; }
void resetLiveRange() { Live.reset(); } void resetLiveRange() { Live.reset(); }
void addLiveRange(InstNumberT Start, InstNumberT End, uint32_t WeightDelta) { void addLiveRange(InstNumberT Start, InstNumberT End, uint32_t WeightDelta) {
assert(!getIgnoreLiveness());
assert(WeightDelta != RegWeight::Inf); assert(WeightDelta != RegWeight::Inf);
Live.addSegment(Start, End); Live.addSegment(Start, End);
if (Weight.isInf()) if (Weight.isInf())
......
...@@ -178,7 +178,8 @@ void LinearScan::initForInfOnly() { ...@@ -178,7 +178,8 @@ void LinearScan::initForInfOnly() {
if (Inst.isDeleted()) if (Inst.isDeleted())
continue; continue;
if (const Variable *Var = Inst.getDest()) { if (const Variable *Var = Inst.getDest()) {
if (Var->hasReg() || Var->getWeight().isInf()) { if (!Var->getIgnoreLiveness() &&
(Var->hasReg() || Var->getWeight().isInf())) {
if (LRBegin[Var->getIndex()] == Inst::NumberSentinel) { if (LRBegin[Var->getIndex()] == Inst::NumberSentinel) {
LRBegin[Var->getIndex()] = Inst.getNumber(); LRBegin[Var->getIndex()] = Inst.getNumber();
++NumVars; ++NumVars;
...@@ -190,6 +191,8 @@ void LinearScan::initForInfOnly() { ...@@ -190,6 +191,8 @@ void LinearScan::initForInfOnly() {
SizeT NumVars = Src->getNumVars(); SizeT NumVars = Src->getNumVars();
for (SizeT J = 0; J < NumVars; ++J) { for (SizeT J = 0; J < NumVars; ++J) {
const Variable *Var = Src->getVar(J); const Variable *Var = Src->getVar(J);
if (Var->getIgnoreLiveness())
continue;
if (Var->hasReg() || Var->getWeight().isInf()) if (Var->hasReg() || Var->getWeight().isInf())
LREnd[Var->getIndex()] = Inst.getNumber(); LREnd[Var->getIndex()] = Inst.getNumber();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment