| 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 // This file provides some of the support for the Liveness class. In | 10 // This file provides some of the support for the Liveness class. In |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 SizeT NodeIndex = VMetadata->getLocalUseNode(Var)->getIndex(); | 70 SizeT NodeIndex = VMetadata->getLocalUseNode(Var)->getIndex(); |
| 71 LiveIndex = Nodes[NodeIndex].NumLocals++; | 71 LiveIndex = Nodes[NodeIndex].NumLocals++; |
| 72 Nodes[NodeIndex].LiveToVarMap[LiveIndex] = Var; | 72 Nodes[NodeIndex].LiveToVarMap[LiveIndex] = Var; |
| 73 LiveIndex += NumGlobals; | 73 LiveIndex += NumGlobals; |
| 74 } | 74 } |
| 75 VarToLiveMap[VarIndex] = LiveIndex; | 75 VarToLiveMap[VarIndex] = LiveIndex; |
| 76 } | 76 } |
| 77 assert(NumGlobals == TmpNumGlobals); | 77 assert(NumGlobals == TmpNumGlobals); |
| 78 | 78 |
| 79 // Process each node. | 79 // Process each node. |
| 80 const NodeList &LNodes = Func->getNodes(); | 80 for (const CfgNode *LNode : Func->getNodes()) { |
| 81 SizeT NumLNodes = LNodes.size(); | 81 LivenessNode &Node = Nodes[LNode->getIndex()]; |
| 82 for (SizeT i = 0; i < NumLNodes; ++i) { | |
| 83 LivenessNode &Node = Nodes[LNodes[i]->getIndex()]; | |
| 84 // NumLocals, LiveToVarMap already initialized | 82 // NumLocals, LiveToVarMap already initialized |
| 85 Node.LiveIn.resize(NumGlobals); | 83 Node.LiveIn.resize(NumGlobals); |
| 86 Node.LiveOut.resize(NumGlobals); | 84 Node.LiveOut.resize(NumGlobals); |
| 87 // LiveBegin and LiveEnd are reinitialized before each pass over | 85 // LiveBegin and LiveEnd are reinitialized before each pass over |
| 88 // the block. | 86 // the block. |
| 89 } | 87 } |
| 90 } | 88 } |
| 91 | 89 |
| 92 Variable *Liveness::getVariable(SizeT LiveIndex, const CfgNode *Node) const { | 90 Variable *Liveness::getVariable(SizeT LiveIndex, const CfgNode *Node) const { |
| 93 if (LiveIndex < NumGlobals) | 91 if (LiveIndex < NumGlobals) |
| 94 return LiveToVarMap[LiveIndex]; | 92 return LiveToVarMap[LiveIndex]; |
| 95 SizeT NodeIndex = Node->getIndex(); | 93 SizeT NodeIndex = Node->getIndex(); |
| 96 return Nodes[NodeIndex].LiveToVarMap[LiveIndex - NumGlobals]; | 94 return Nodes[NodeIndex].LiveToVarMap[LiveIndex - NumGlobals]; |
| 97 } | 95 } |
| 98 | 96 |
| 99 } // end of namespace Ice | 97 } // end of namespace Ice |
| OLD | NEW |