Chromium Code Reviews| Index: src/IceCfgNode.cpp |
| diff --git a/src/IceCfgNode.cpp b/src/IceCfgNode.cpp |
| index ca3897ee22d316e06467c5e6b1fa62125e61252c..26c5ed3d901142280d3656fd48db45047fc280d1 100644 |
| --- a/src/IceCfgNode.cpp |
| +++ b/src/IceCfgNode.cpp |
| @@ -37,10 +37,22 @@ CfgNode::CfgNode(Cfg *Func, SizeT Number) : Func(Func), Number(Number) { |
| // Adds an instruction to either the Phi list or the regular instruction list. |
| // Validates that all Phis are added before all regular instructions. |
| -void CfgNode::appendInst(Inst *Instr) { |
| +void CfgNode::appendInst(Inst *Instr, bool AllowPhisAnywhere) { |
| ++InstCountEstimate; |
| + |
| + if (auto *Br = llvm::dyn_cast<InstBr>(Instr)) { |
| + if (auto *N = Br->getTargetTrue()) { |
| + N->addInEdge(this); |
| + addOutEdge(N); |
| + } |
| + if (auto N = Br->getTargetFalse()) { |
|
Jim Stichnoth
2016/04/01 01:46:43
auto *N
Eric Holk
2016/04/01 19:15:01
Done.
|
| + N->addInEdge(this); |
| + addOutEdge(N); |
| + } |
| + } |
| + |
| if (auto *Phi = llvm::dyn_cast<InstPhi>(Instr)) { |
| - if (!Insts.empty()) { |
| + if (!AllowPhisAnywhere && !Insts.empty()) { |
| Func->setError("Phi instruction added to the middle of a block"); |
| return; |
| } |
| @@ -81,6 +93,8 @@ void CfgNode::computePredecessors() { |
| } |
| void CfgNode::computeSuccessors() { |
| + OutEdges.clear(); |
| + InEdges.clear(); |
| OutEdges = Insts.rbegin()->getTerminatorEdges(); |
| } |
| @@ -872,7 +886,7 @@ void CfgNode::contractIfEmpty() { |
| // Make sure there is actually a successor to repoint in-edges to. |
| if (OutEdges.empty()) |
| return; |
| - assert(OutEdges.size() == 1); |
| + assert(OutEdges.size() == 1 || OutEdges[0] == OutEdges[1]); |
| // Don't try to delete a self-loop. |
| if (OutEdges[0] == this) |
| return; |