Chromium Code Reviews| Index: src/IceCfgNode.cpp |
| diff --git a/src/IceCfgNode.cpp b/src/IceCfgNode.cpp |
| index 212f742c53959789acaf5a036fd548303ea96eff..2b06ef80170f9680f3c06121a27a4fff67bff939 100644 |
| --- a/src/IceCfgNode.cpp |
| +++ b/src/IceCfgNode.cpp |
| @@ -39,17 +39,35 @@ IceString CfgNode::getName() const { |
| // 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 Dest = Instr->getDest()) { |
|
Jim Stichnoth
2016/03/29 17:49:57
auto *
here and below
Eric Holk
2016/03/29 22:58:07
Done.
|
| + Dest->setDefNode(this); |
| + } |
| + |
| + if (auto Br = llvm::dyn_cast<InstBr>(Instr)) { |
| + if (auto N = Br->getTargetTrue()) { |
| + N->addInEdge(this); |
| + addOutEdge(N); |
| + } |
| + if (auto N = Br->getTargetFalse()) { |
| + 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"); |
| + assert(false); |
|
JF
2016/03/28 18:17:13
llvm_unreachable
Jim Stichnoth
2016/03/29 17:49:57
actually just remove the assert.
Eric Holk
2016/03/29 19:54:08
Actually, I didn't mean to keep this assert here a
|
| return; |
| } |
| Phis.push_back(Phi); |
| } else { |
| Insts.push_back(Instr); |
| } |
| + Instr->setCfgNode(this); |
| } |
| namespace { |
| @@ -83,6 +101,8 @@ void CfgNode::computePredecessors() { |
| } |
| void CfgNode::computeSuccessors() { |
| + OutEdges.clear(); |
| + InEdges.clear(); |
| OutEdges = Insts.rbegin()->getTerminatorEdges(); |
| } |
| @@ -874,7 +894,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; |