Chromium Code Reviews| Index: src/IceCfg.cpp |
| diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp |
| index e97eebfb8856037e04b3675d67dae4723ab975ec..a313a411d163de3c07e4ed8167cf7b4992ed7250 100644 |
| --- a/src/IceCfg.cpp |
| +++ b/src/IceCfg.cpp |
| @@ -227,6 +227,22 @@ void Cfg::translate() { |
| getContext()->dumpTimers(); |
| } |
| +void Cfg::fixPhiNodes() { |
| + for (auto *Node : Nodes) { |
| + // Fix all the phi edges since WASM can't tell how to make them correctly at |
| + // the beginning. |
| + assert(Node); |
| + const auto InEdges = Node->getInEdges(); |
|
Jim Stichnoth
2016/03/29 17:49:57
Should this be "const auto &" ? I don't know. ge
Eric Holk
2016/03/29 22:58:07
Done.
|
| + for (auto &Inst : Node->getPhis()) { |
| + auto Phi = llvm::cast<InstPhi>(&Inst); |
|
Jim Stichnoth
2016/03/29 17:49:57
auto *
Eric Holk
2016/03/29 22:58:07
Done.
|
| + assert(Phi); |
| + for (SizeT i = 0; i < InEdges.size(); ++i) { |
| + Phi->setLabel(i, InEdges[i]); |
| + } |
| + } |
| + } |
| +} |
| + |
| void Cfg::computeInOutEdges() { |
| // Compute the out-edges. |
| for (CfgNode *Node : Nodes) |
| @@ -384,7 +400,8 @@ void Cfg::reorderNodes() { |
| // in-edge if the predecessor node was contracted). If this changes in |
| // the future, rethink the strategy. |
| assert(Node->getInEdges().size() >= 1); |
| - assert(Node->getOutEdges().size() == 1); |
| + assert(Node->getOutEdges().size() == 1 || |
| + Node->getOutEdges()[0] == Node->getOutEdges()[1]); |
| // If it's a (non-critical) edge where the successor has a single |
| // in-edge, then place it before the successor. |