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,
std::sort(MapBegin.begin(), MapBegin.end());
std::sort(MapEnd.begin(), MapEnd.end());
// Verify there are no duplicates.
struct ComparePair {
bool operator()(const LiveBeginEndMapEntry &A,
const LiveBeginEndMapEntry &B) {
return A.first == B.first;
}
};
assert(std::adjacent_find(MapBegin.begin(), MapBegin.end(), ComparePair()) ==
auto ComparePair =
[](const LiveBeginEndMapEntry &A, const LiveBeginEndMapEntry &B) {
return A.first == B.first;
};
assert(std::adjacent_find(MapBegin.begin(), MapBegin.end(), ComparePair) ==
MapBegin.end());
assert(std::adjacent_find(MapEnd.begin(), MapEnd.end(), ComparePair()) ==
assert(std::adjacent_find(MapEnd.begin(), MapEnd.end(), ComparePair) ==
MapEnd.end());
LivenessBV LiveInAndOut = LiveIn;
......@@ -700,21 +698,16 @@ void CfgNode::livenessAddIntervals(Liveness *Liveness, InstNumberT FirstInstNum,
InstNumberT LE = i == i2 ? IEB->second : LastInstNum + 1;
Variable *Var = Liveness->getVariable(i, this);
// TODO(stichnot): Push getIgnoreLiveness() into the initialization of
// Liveness::RangeMask so that LiveBegin and LiveEnd never even reference
// such variables.
if (!Var->getIgnoreLiveness()) {
if (LB > LE) {
Var->addLiveRange(FirstInstNum, LE, 1);
Var->addLiveRange(LB, LastInstNum + 1, 1);
// Assert that Var is a global variable by checking that its
// liveness index is less than the number of globals. This
// ensures that the LiveInAndOut[] access is valid.
assert(i < Liveness->getNumGlobalVars());
LiveInAndOut[i] = false;
} else {
Var->addLiveRange(LB, LE, 1);
}
if (LB > LE) {
Var->addLiveRange(FirstInstNum, LE, 1);
Var->addLiveRange(LB, LastInstNum + 1, 1);
// Assert that Var is a global variable by checking that its
// liveness index is less than the number of globals. This
// ensures that the LiveInAndOut[] access is valid.
assert(i < Liveness->getNumGlobalVars());
LiveInAndOut[i] = false;
} else {
Var->addLiveRange(LB, LE, 1);
}
if (i == i1)
++IBB;
......
......@@ -71,8 +71,12 @@ void Liveness::initInternal(NodeList::const_iterator FirstNode,
if (IsFullInit)
LiveToVarMap.assign(NumGlobals, nullptr);
// Sort each variable into the appropriate LiveToVarMap. Also set
// VarToLiveMap.
// Initialize the bitmask of which variables to track.
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;
for (auto I = FirstVar, E = Func->getVariables().end(); I != E; ++I) {
Variable *Var = *I;
......@@ -88,9 +92,20 @@ void Liveness::initInternal(NodeList::const_iterator FirstNode,
LiveIndex += NumGlobals;
}
VarToLiveMap[VarIndex] = LiveIndex;
if (Var->getIgnoreLiveness())
RangeMask[VarIndex] = false;
}
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.
for (auto I = FirstNode, E = Func->getNodes().end(); I != E; ++I) {
LivenessNode &Node = Nodes[(*I)->getIndex()];
......@@ -100,17 +115,6 @@ void Liveness::initInternal(NodeList::const_iterator FirstNode,
// LiveBegin and LiveEnd are reinitialized before each pass over
// 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() {
......
......@@ -463,6 +463,7 @@ public:
void setLiveRange(const LiveRange &Range) { Live = Range; }
void resetLiveRange() { Live.reset(); }
void addLiveRange(InstNumberT Start, InstNumberT End, uint32_t WeightDelta) {
assert(!getIgnoreLiveness());
assert(WeightDelta != RegWeight::Inf);
Live.addSegment(Start, End);
if (Weight.isInf())
......
......@@ -178,7 +178,8 @@ void LinearScan::initForInfOnly() {
if (Inst.isDeleted())
continue;
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) {
LRBegin[Var->getIndex()] = Inst.getNumber();
++NumVars;
......@@ -190,6 +191,8 @@ void LinearScan::initForInfOnly() {
SizeT NumVars = Src->getNumVars();
for (SizeT J = 0; J < NumVars; ++J) {
const Variable *Var = Src->getVar(J);
if (Var->getIgnoreLiveness())
continue;
if (Var->hasReg() || Var->getWeight().isInf())
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