Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) implementation -----===// | 1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 Succ->InEdges.push_back(this); | 80 Succ->InEdges.push_back(this); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void CfgNode::computeSuccessors() { | 83 void CfgNode::computeSuccessors() { |
| 84 OutEdges = Insts.rbegin()->getTerminatorEdges(); | 84 OutEdges = Insts.rbegin()->getTerminatorEdges(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Validate each Phi instruction in the node with respect to control flow. For | 87 // Validate each Phi instruction in the node with respect to control flow. For |
| 88 // every phi argument, its label must appear in the predecessor list. For each | 88 // every phi argument, its label must appear in the predecessor list. For each |
| 89 // predecessor, there must be a phi argument with that label. We don't check | 89 // predecessor, there must be a phi argument with that label. We don't check |
| 90 // that phi arguments with the same label have the same value. | 90 // that phi arguments with the same label have the same value. |
|
Jim Stichnoth
2016/04/02 01:19:52
Update this comment to mention the cleanup now bei
sehr
2016/04/04 15:38:51
Done.
| |
| 91 void CfgNode::validatePhis() { | 91 void CfgNode::validatePhis() { |
|
Jim Stichnoth
2016/04/02 01:19:52
I'm thinking that maybe this method name should be
sehr
2016/04/04 15:38:51
I changed it to enforcePhiConsistency. WDYT?
| |
| 92 for (Inst &Instr : Phis) { | 92 for (Inst &Instr : Phis) { |
| 93 auto *Phi = llvm::cast<InstPhi>(&Instr); | 93 auto *Phi = llvm::cast<InstPhi>(&Instr); |
| 94 // We do a simple O(N^2) algorithm to check for consistency. Even so, it | 94 // We do a simple O(N^2) algorithm to check for consistency. Even so, it |
| 95 // shows up as only about 0.2% of the total translation time. But if | 95 // shows up as only about 0.2% of the total translation time. But if |
| 96 // necessary, we could improve the complexity by using a hash table to | 96 // necessary, we could improve the complexity by using a hash table to |
| 97 // count how many times each node is referenced in the Phi instruction, and | 97 // count how many times each node is referenced in the Phi instruction, and |
| 98 // how many times each node is referenced in the incoming edge list, and | 98 // how many times each node is referenced in the incoming edge list, and |
| 99 // compare the two for equality. | 99 // compare the two for equality. |
| 100 for (SizeT i = 0; i < Phi->getSrcSize(); ++i) { | 100 for (SizeT i = 0; i < Phi->getSrcSize(); ++i) { |
| 101 CfgNode *Label = Phi->getLabel(i); | 101 CfgNode *Label = Phi->getLabel(i); |
| 102 bool Found = false; | 102 bool Found = false; |
| 103 for (CfgNode *InNode : getInEdges()) { | 103 for (CfgNode *InNode : getInEdges()) { |
| 104 if (InNode == Label) { | 104 if (InNode == Label) { |
| 105 Found = true; | 105 Found = true; |
| 106 break; | 106 break; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 if (!Found) | 109 if (!Found) { |
| 110 llvm::report_fatal_error("Phi error: label for bad incoming edge"); | 110 // Predecessor was unreachable, so if (impossibly) the control flow |
| 111 // enters from that predecessor, the value should be zero. | |
| 112 Phi->clearOperandForTarget(Label); | |
| 113 } | |
| 111 } | 114 } |
| 112 for (CfgNode *InNode : getInEdges()) { | 115 for (CfgNode *InNode : getInEdges()) { |
| 113 bool Found = false; | 116 bool Found = false; |
| 114 for (SizeT i = 0; i < Phi->getSrcSize(); ++i) { | 117 for (SizeT i = 0; i < Phi->getSrcSize(); ++i) { |
| 115 CfgNode *Label = Phi->getLabel(i); | 118 CfgNode *Label = Phi->getLabel(i); |
| 116 if (InNode == Label) { | 119 if (InNode == Label) { |
| 117 Found = true; | 120 Found = true; |
| 118 break; | 121 break; |
| 119 } | 122 } |
| 120 } | 123 } |
| (...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1456 auto *Instr = InstIntrinsicCall::create( | 1459 auto *Instr = InstIntrinsicCall::create( |
| 1457 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); | 1460 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); |
| 1458 Instr->addArg(AtomicRMWOp); | 1461 Instr->addArg(AtomicRMWOp); |
| 1459 Instr->addArg(Counter); | 1462 Instr->addArg(Counter); |
| 1460 Instr->addArg(One); | 1463 Instr->addArg(One); |
| 1461 Instr->addArg(OrderAcquireRelease); | 1464 Instr->addArg(OrderAcquireRelease); |
| 1462 Insts.push_front(Instr); | 1465 Insts.push_front(Instr); |
| 1463 } | 1466 } |
| 1464 | 1467 |
| 1465 } // end of namespace Ice | 1468 } // end of namespace Ice |
| OLD | NEW |