| 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 // This file implements the CfgNode class, including the complexities | 10 // This file implements the CfgNode class, including the complexities |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 for (Inst &I : Insts) | 62 for (Inst &I : Insts) |
| 63 I.renumber(Func); | 63 I.renumber(Func); |
| 64 InstCountEstimate = Func->getNextInstNumber() - FirstNumber; | 64 InstCountEstimate = Func->getNextInstNumber() - FirstNumber; |
| 65 } | 65 } |
| 66 | 66 |
| 67 // When a node is created, the OutEdges are immediately known, but the | 67 // When a node is created, the OutEdges are immediately known, but the |
| 68 // InEdges have to be built up incrementally. After the CFG has been | 68 // InEdges have to be built up incrementally. After the CFG has been |
| 69 // constructed, the computePredecessors() pass finalizes it by | 69 // constructed, the computePredecessors() pass finalizes it by |
| 70 // creating the InEdges list. | 70 // creating the InEdges list. |
| 71 void CfgNode::computePredecessors() { | 71 void CfgNode::computePredecessors() { |
| 72 OutEdges = Insts.rbegin()->getTerminatorEdges(); | |
| 73 for (CfgNode *Succ : OutEdges) | 72 for (CfgNode *Succ : OutEdges) |
| 74 Succ->InEdges.push_back(this); | 73 Succ->InEdges.push_back(this); |
| 75 } | 74 } |
| 76 | 75 |
| 76 void CfgNode::computeSuccessors() { |
| 77 OutEdges = Insts.rbegin()->getTerminatorEdges(); |
| 78 } |
| 79 |
| 77 // This does part 1 of Phi lowering, by creating a new dest variable | 80 // This does part 1 of Phi lowering, by creating a new dest variable |
| 78 // for each Phi instruction, replacing the Phi instruction's dest with | 81 // for each Phi instruction, replacing the Phi instruction's dest with |
| 79 // that variable, and adding an explicit assignment of the old dest to | 82 // that variable, and adding an explicit assignment of the old dest to |
| 80 // the new dest. For example, | 83 // the new dest. For example, |
| 81 // a=phi(...) | 84 // a=phi(...) |
| 82 // changes to | 85 // changes to |
| 83 // "a_phi=phi(...); a=a_phi". | 86 // "a_phi=phi(...); a=a_phi". |
| 84 // | 87 // |
| 85 // This is in preparation for part 2 which deletes the Phi | 88 // This is in preparation for part 2 which deletes the Phi |
| 86 // instructions and appends assignment instructions to predecessor | 89 // instructions and appends assignment instructions to predecessor |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 // set bits for global variables upon block entry. We validate this | 601 // set bits for global variables upon block entry. We validate this |
| 599 // by shrinking the Live vector and then testing it against the | 602 // by shrinking the Live vector and then testing it against the |
| 600 // pre-shrunk version. (The shrinking is required, but the | 603 // pre-shrunk version. (The shrinking is required, but the |
| 601 // validation is not.) | 604 // validation is not.) |
| 602 LivenessBV LiveOrig = Live; | 605 LivenessBV LiveOrig = Live; |
| 603 Live.resize(Liveness->getNumGlobalVars()); | 606 Live.resize(Liveness->getNumGlobalVars()); |
| 604 // Non-global arguments in the entry node are allowed to be live on | 607 // Non-global arguments in the entry node are allowed to be live on |
| 605 // entry. | 608 // entry. |
| 606 bool IsEntry = (Func->getEntryNode() == this); | 609 bool IsEntry = (Func->getEntryNode() == this); |
| 607 if (!(IsEntry || Live == LiveOrig)) { | 610 if (!(IsEntry || Live == LiveOrig)) { |
| 608 // This is a fatal liveness consistency error. Print some | 611 if (ALLOW_DUMP) { |
| 609 // diagnostics and abort. | 612 // This is a fatal liveness consistency error. Print some |
| 610 Ostream &Str = Func->getContext()->getStrDump(); | 613 // diagnostics and abort. |
| 611 Func->resetCurrentNode(); | 614 Ostream &Str = Func->getContext()->getStrDump(); |
| 612 Str << "LiveOrig-Live ="; | 615 Func->resetCurrentNode(); |
| 613 for (SizeT i = Live.size(); i < LiveOrig.size(); ++i) { | 616 Str << "LiveOrig-Live ="; |
| 614 if (LiveOrig.test(i)) { | 617 for (SizeT i = Live.size(); i < LiveOrig.size(); ++i) { |
| 615 Str << " "; | 618 if (LiveOrig.test(i)) { |
| 616 Liveness->getVariable(i, this)->dump(Func); | 619 Str << " "; |
| 620 Liveness->getVariable(i, this)->dump(Func); |
| 621 } |
| 617 } | 622 } |
| 623 Str << "\n"; |
| 618 } | 624 } |
| 619 Str << "\n"; | 625 llvm::report_fatal_error("Fatal inconsistency in liveness analysis"); |
| 620 llvm_unreachable("Fatal inconsistency in liveness analysis"); | |
| 621 } | 626 } |
| 622 | 627 |
| 623 bool Changed = false; | 628 bool Changed = false; |
| 624 LivenessBV &LiveIn = Liveness->getLiveIn(this); | 629 LivenessBV &LiveIn = Liveness->getLiveIn(this); |
| 625 // Add in current LiveIn | 630 // Add in current LiveIn |
| 626 Live |= LiveIn; | 631 Live |= LiveIn; |
| 627 // Check result, set LiveIn=Live | 632 // Check result, set LiveIn=Live |
| 628 SizeT &PrevNumNonDeadPhis = Liveness->getNumNonDeadPhis(this); | 633 SizeT &PrevNumNonDeadPhis = Liveness->getNumNonDeadPhis(this); |
| 629 bool LiveInChanged = (Live != LiveIn); | 634 bool LiveInChanged = (Live != LiveIn); |
| 630 Changed = (NumNonDeadPhis != PrevNumNonDeadPhis || LiveInChanged); | 635 Changed = (NumNonDeadPhis != PrevNumNonDeadPhis || LiveInChanged); |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 if (!First) | 1199 if (!First) |
| 1195 Str << ", "; | 1200 Str << ", "; |
| 1196 First = false; | 1201 First = false; |
| 1197 Str << "%" << I->getName(); | 1202 Str << "%" << I->getName(); |
| 1198 } | 1203 } |
| 1199 Str << "\n"; | 1204 Str << "\n"; |
| 1200 } | 1205 } |
| 1201 } | 1206 } |
| 1202 | 1207 |
| 1203 } // end of namespace Ice | 1208 } // end of namespace Ice |
| OLD | NEW |