Chromium Code Reviews| Index: src/IceCfg.cpp |
| diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp |
| index 85be8b9e46040b97dd0f0788bed327cfe888cfcc..da6cdf22886ab44c85761173eeb5fbc3a3394c29 100644 |
| --- a/src/IceCfg.cpp |
| +++ b/src/IceCfg.cpp |
| @@ -239,6 +239,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(); |
| + 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
|
| + auto *Phi = llvm::cast<InstPhi>(&Inst); |
| + 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) |
| @@ -396,7 +412,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 || |
|
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.
|
| + 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. |