OLD | NEW |
1 //===- subzero/src/IceLiveness.cpp - Liveness analysis implementation -----===// | 1 //===- subzero/src/IceLiveness.cpp - Liveness analysis implementation -----===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 // Fix up RangeMask for variables before FirstVar. | 100 // Fix up RangeMask for variables before FirstVar. |
101 for (auto I = Func->getVariables().begin(); I != FirstVar; ++I) { | 101 for (auto I = Func->getVariables().begin(); I != FirstVar; ++I) { |
102 Variable *Var = *I; | 102 Variable *Var = *I; |
103 SizeT VarIndex = Var->getIndex(); | 103 SizeT VarIndex = Var->getIndex(); |
104 if (Var->getIgnoreLiveness() || | 104 if (Var->getIgnoreLiveness() || |
105 (!IsFullInit && !Var->hasReg() && !Var->mustHaveReg())) | 105 (!IsFullInit && !Var->hasReg() && !Var->mustHaveReg())) |
106 RangeMask[VarIndex] = false; | 106 RangeMask[VarIndex] = false; |
107 } | 107 } |
108 | 108 |
| 109 SizeT MaxLocals = 0; |
109 // Process each node. | 110 // Process each node. |
110 for (auto I = FirstNode, E = Func->getNodes().end(); I != E; ++I) { | 111 for (auto I = FirstNode, E = Func->getNodes().end(); I != E; ++I) { |
111 LivenessNode &Node = Nodes[(*I)->getIndex()]; | 112 LivenessNode &Node = Nodes[(*I)->getIndex()]; |
112 // NumLocals, LiveToVarMap already initialized | 113 // NumLocals, LiveToVarMap already initialized |
113 Node.LiveIn.resize(NumGlobals); | 114 Node.LiveIn.resize(NumGlobals); |
114 Node.LiveOut.resize(NumGlobals); | 115 Node.LiveOut.resize(NumGlobals); |
115 // LiveBegin and LiveEnd are reinitialized before each pass over the block. | 116 // LiveBegin and LiveEnd are reinitialized before each pass over the block. |
| 117 MaxLocals = std::max(MaxLocals, Node.NumLocals); |
116 } | 118 } |
| 119 ScratchBV.reserve(NumGlobals + MaxLocals); |
117 } | 120 } |
118 | 121 |
119 void Liveness::init() { | 122 void Liveness::init() { |
120 constexpr bool IsFullInit = true; | 123 constexpr bool IsFullInit = true; |
121 NodeList::const_iterator FirstNode = Func->getNodes().begin(); | 124 NodeList::const_iterator FirstNode = Func->getNodes().begin(); |
122 VarList::const_iterator FirstVar = Func->getVariables().begin(); | 125 VarList::const_iterator FirstVar = Func->getVariables().begin(); |
123 initInternal(FirstNode, FirstVar, IsFullInit); | 126 initInternal(FirstNode, FirstVar, IsFullInit); |
124 } | 127 } |
125 | 128 |
126 void Liveness::initPhiEdgeSplits(NodeList::const_iterator FirstNode, | 129 void Liveness::initPhiEdgeSplits(NodeList::const_iterator FirstNode, |
127 VarList::const_iterator FirstVar) { | 130 VarList::const_iterator FirstVar) { |
128 constexpr bool IsFullInit = false; | 131 constexpr bool IsFullInit = false; |
129 initInternal(FirstNode, FirstVar, IsFullInit); | 132 initInternal(FirstNode, FirstVar, IsFullInit); |
130 } | 133 } |
131 | 134 |
132 Variable *Liveness::getVariable(SizeT LiveIndex, const CfgNode *Node) const { | 135 Variable *Liveness::getVariable(SizeT LiveIndex, const CfgNode *Node) const { |
133 if (LiveIndex < NumGlobals) | 136 if (LiveIndex < NumGlobals) |
134 return LiveToVarMap[LiveIndex]; | 137 return LiveToVarMap[LiveIndex]; |
135 SizeT NodeIndex = Node->getIndex(); | 138 SizeT NodeIndex = Node->getIndex(); |
136 return Nodes[NodeIndex].LiveToVarMap[LiveIndex - NumGlobals]; | 139 return Nodes[NodeIndex].LiveToVarMap[LiveIndex - NumGlobals]; |
137 } | 140 } |
138 | 141 |
139 } // end of namespace Ice | 142 } // end of namespace Ice |
OLD | NEW |