Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: src/IceLiveness.cpp

Issue 1746613002: Subzero: Reduce copying of Liveness bitvectors. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix memory over-allocation Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceLiveness.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « src/IceLiveness.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698