OLD | NEW |
---|---|
1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===// | 1 //===- subzero/src/IceCfg.cpp - Control flow graph 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 | 232 |
233 // The set of translation passes and their order are determined by the | 233 // The set of translation passes and their order are determined by the |
234 // target. | 234 // target. |
235 getTarget()->translate(); | 235 getTarget()->translate(); |
236 | 236 |
237 dump("Final output"); | 237 dump("Final output"); |
238 if (getFocusedTiming()) | 238 if (getFocusedTiming()) |
239 getContext()->dumpTimers(); | 239 getContext()->dumpTimers(); |
240 } | 240 } |
241 | 241 |
242 void Cfg::fixPhiNodes() { | |
243 for (auto *Node : Nodes) { | |
244 // Fix all the phi edges since WASM can't tell how to make them correctly at | |
245 // the beginning. | |
246 assert(Node); | |
247 const auto &InEdges = Node->getInEdges(); | |
248 for (auto &Inst : Node->getPhis()) { | |
Jim Stichnoth
2016/04/01 01:46:43
I would use "auto *Instr" here.
Eric Holk
2016/04/01 19:15:01
I changed it to `auto &Instr`. It seems the instru
| |
249 auto *Phi = llvm::cast<InstPhi>(&Inst); | |
250 assert(Phi); | |
251 for (SizeT i = 0; i < InEdges.size(); ++i) { | |
252 Phi->setLabel(i, InEdges[i]); | |
253 } | |
254 } | |
255 } | |
256 } | |
257 | |
242 void Cfg::computeInOutEdges() { | 258 void Cfg::computeInOutEdges() { |
243 // Compute the out-edges. | 259 // Compute the out-edges. |
244 for (CfgNode *Node : Nodes) | 260 for (CfgNode *Node : Nodes) |
245 Node->computeSuccessors(); | 261 Node->computeSuccessors(); |
246 | 262 |
247 // Prune any unreachable nodes before computing in-edges. | 263 // Prune any unreachable nodes before computing in-edges. |
248 SizeT NumNodes = getNumNodes(); | 264 SizeT NumNodes = getNumNodes(); |
249 BitVector Reachable(NumNodes); | 265 BitVector Reachable(NumNodes); |
250 BitVector Pending(NumNodes); | 266 BitVector Pending(NumNodes); |
251 Pending.set(getEntryNode()->getIndex()); | 267 Pending.set(getEntryNode()->getIndex()); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 Placed.push_back(Node); | 405 Placed.push_back(Node); |
390 PlaceIndex[Node->getIndex()] = Placed.end(); | 406 PlaceIndex[Node->getIndex()] = Placed.end(); |
391 continue; | 407 continue; |
392 } | 408 } |
393 Node->setNeedsPlacement(false); | 409 Node->setNeedsPlacement(false); |
394 // Assume for now that the unplaced node is from edge-splitting and | 410 // Assume for now that the unplaced node is from edge-splitting and |
395 // therefore has 1 in-edge and 1 out-edge (actually, possibly more than 1 | 411 // therefore has 1 in-edge and 1 out-edge (actually, possibly more than 1 |
396 // in-edge if the predecessor node was contracted). If this changes in | 412 // in-edge if the predecessor node was contracted). If this changes in |
397 // the future, rethink the strategy. | 413 // the future, rethink the strategy. |
398 assert(Node->getInEdges().size() >= 1); | 414 assert(Node->getInEdges().size() >= 1); |
399 assert(Node->getOutEdges().size() == 1); | 415 assert(Node->getOutEdges().size() == 1 || |
Jim Stichnoth
2016/04/01 01:46:43
This assert shows up at least a couple times, and
Eric Holk
2016/04/01 19:15:01
Done.
| |
416 Node->getOutEdges()[0] == Node->getOutEdges()[1]); | |
400 | 417 |
401 // If it's a (non-critical) edge where the successor has a single | 418 // If it's a (non-critical) edge where the successor has a single |
402 // in-edge, then place it before the successor. | 419 // in-edge, then place it before the successor. |
403 CfgNode *Succ = Node->getOutEdges().front(); | 420 CfgNode *Succ = Node->getOutEdges().front(); |
404 if (Succ->getInEdges().size() == 1 && | 421 if (Succ->getInEdges().size() == 1 && |
405 PlaceIndex[Succ->getIndex()] != NoPlace) { | 422 PlaceIndex[Succ->getIndex()] != NoPlace) { |
406 Placed.insert(PlaceIndex[Succ->getIndex()], Node); | 423 Placed.insert(PlaceIndex[Succ->getIndex()], Node); |
407 PlaceIndex[Node->getIndex()] = PlaceIndex[Succ->getIndex()]; | 424 PlaceIndex[Node->getIndex()] = PlaceIndex[Succ->getIndex()]; |
408 continue; | 425 continue; |
409 } | 426 } |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1147 } | 1164 } |
1148 } | 1165 } |
1149 // Print each basic block | 1166 // Print each basic block |
1150 for (CfgNode *Node : Nodes) | 1167 for (CfgNode *Node : Nodes) |
1151 Node->dump(this); | 1168 Node->dump(this); |
1152 if (isVerbose(IceV_Instructions)) | 1169 if (isVerbose(IceV_Instructions)) |
1153 Str << "}\n"; | 1170 Str << "}\n"; |
1154 } | 1171 } |
1155 | 1172 |
1156 } // end of namespace Ice | 1173 } // end of namespace Ice |
OLD | NEW |