| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 PhiDescList Desc; | 452 PhiDescList Desc; |
| 453 | 453 |
| 454 for (Inst &I : Phis) { | 454 for (Inst &I : Phis) { |
| 455 auto *Phi = llvm::dyn_cast<InstPhi>(&I); | 455 auto *Phi = llvm::dyn_cast<InstPhi>(&I); |
| 456 if (!Phi->isDeleted()) { | 456 if (!Phi->isDeleted()) { |
| 457 Variable *Dest = Phi->getDest(); | 457 Variable *Dest = Phi->getDest(); |
| 458 Desc.emplace_back(Phi, Dest); | 458 Desc.emplace_back(Phi, Dest); |
| 459 // Undo the effect of the phi instruction on this node's live-in set by | 459 // Undo the effect of the phi instruction on this node's live-in set by |
| 460 // marking the phi dest variable as live on entry. | 460 // marking the phi dest variable as live on entry. |
| 461 SizeT VarNum = Func->getLiveness()->getLiveIndex(Dest->getIndex()); | 461 SizeT VarNum = Func->getLiveness()->getLiveIndex(Dest->getIndex()); |
| 462 assert(!Func->getLiveness()->getLiveIn(this)[VarNum]); | 462 auto &LiveIn = Func->getLiveness()->getLiveIn(this); |
| 463 Func->getLiveness()->getLiveIn(this)[VarNum] = true; | 463 if (VarNum < LiveIn.size()) { |
| 464 assert(!LiveIn[VarNum]); |
| 465 LiveIn[VarNum] = true; |
| 466 } |
| 464 Phi->setDeleted(); | 467 Phi->setDeleted(); |
| 465 } | 468 } |
| 466 } | 469 } |
| 467 if (Desc.empty()) | 470 if (Desc.empty()) |
| 468 return; | 471 return; |
| 469 | 472 |
| 470 TargetLowering *Target = Func->getTarget(); | 473 TargetLowering *Target = Func->getTarget(); |
| 471 SizeT InEdgeIndex = 0; | 474 SizeT InEdgeIndex = 0; |
| 472 for (CfgNode *Pred : InEdges) { | 475 for (CfgNode *Pred : InEdges) { |
| 473 CfgNode *Split = splitIncomingEdge(Pred, InEdgeIndex++); | 476 CfgNode *Split = splitIncomingEdge(Pred, InEdgeIndex++); |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 // live range begins and ends in this block. If i1<i2, then i1's live range | 863 // live range begins and ends in this block. If i1<i2, then i1's live range |
| 861 // begins at instruction IBB->second and extends through the end of the | 864 // begins at instruction IBB->second and extends through the end of the |
| 862 // block. If i1>i2, then i2's live range begins at the first instruction of | 865 // block. If i1>i2, then i2's live range begins at the first instruction of |
| 863 // the block and ends at IEB->second. In any case, we choose the lesser of | 866 // the block and ends at IEB->second. In any case, we choose the lesser of |
| 864 // i1 and i2 and proceed accordingly. | 867 // i1 and i2 and proceed accordingly. |
| 865 InstNumberT LB = i == i1 ? IBB->second : FirstInstNum; | 868 InstNumberT LB = i == i1 ? IBB->second : FirstInstNum; |
| 866 InstNumberT LE = i == i2 ? IEB->second : LastInstNum + 1; | 869 InstNumberT LE = i == i2 ? IEB->second : LastInstNum + 1; |
| 867 | 870 |
| 868 Variable *Var = Liveness->getVariable(i, this); | 871 Variable *Var = Liveness->getVariable(i, this); |
| 869 if (LB > LE) { | 872 if (LB > LE) { |
| 870 Var->addLiveRange(FirstInstNum, LE); | 873 Var->addLiveRange(FirstInstNum, LE, this); |
| 871 Var->addLiveRange(LB, LastInstNum + 1); | 874 Var->addLiveRange(LB, LastInstNum + 1, this); |
| 872 // Assert that Var is a global variable by checking that its liveness | 875 // Assert that Var is a global variable by checking that its liveness |
| 873 // index is less than the number of globals. This ensures that the | 876 // index is less than the number of globals. This ensures that the |
| 874 // LiveInAndOut[] access is valid. | 877 // LiveInAndOut[] access is valid. |
| 875 assert(i < Liveness->getNumGlobalVars()); | 878 assert(i < Liveness->getNumGlobalVars()); |
| 876 LiveInAndOut[i] = false; | 879 LiveInAndOut[i] = false; |
| 877 } else { | 880 } else { |
| 878 Var->addLiveRange(LB, LE); | 881 Var->addLiveRange(LB, LE, this); |
| 879 } | 882 } |
| 880 if (i == i1) | 883 if (i == i1) |
| 881 ++IBB; | 884 ++IBB; |
| 882 if (i == i2) | 885 if (i == i2) |
| 883 ++IEB; | 886 ++IEB; |
| 884 } | 887 } |
| 885 // Process the variables that are live across the entire block. | 888 // Process the variables that are live across the entire block. |
| 886 for (int i = LiveInAndOut.find_first(); i != -1; | 889 for (int i = LiveInAndOut.find_first(); i != -1; |
| 887 i = LiveInAndOut.find_next(i)) { | 890 i = LiveInAndOut.find_next(i)) { |
| 888 Variable *Var = Liveness->getVariable(i, this); | 891 Variable *Var = Liveness->getVariable(i, this); |
| 889 if (Liveness->getRangeMask(Var->getIndex())) | 892 if (Liveness->getRangeMask(Var->getIndex())) |
| 890 Var->addLiveRange(FirstInstNum, LastInstNum + 1); | 893 Var->addLiveRange(FirstInstNum, LastInstNum + 1, this); |
| 891 } | 894 } |
| 892 } | 895 } |
| 893 | 896 |
| 894 // If this node contains only deleted instructions, and ends in an | 897 // If this node contains only deleted instructions, and ends in an |
| 895 // unconditional branch, contract the node by repointing all its in-edges to | 898 // unconditional branch, contract the node by repointing all its in-edges to |
| 896 // its successor. | 899 // its successor. |
| 897 void CfgNode::contractIfEmpty() { | 900 void CfgNode::contractIfEmpty() { |
| 898 if (InEdges.empty()) | 901 if (InEdges.empty()) |
| 899 return; | 902 return; |
| 900 Inst *Branch = nullptr; | 903 Inst *Branch = nullptr; |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 UnusedOperand = TopLevelBoolOp->getSrc(0); | 1637 UnusedOperand = TopLevelBoolOp->getSrc(0); |
| 1635 assert(UnusedOperand); | 1638 assert(UnusedOperand); |
| 1636 | 1639 |
| 1637 Br->replaceSource(0, UnusedOperand); // Index 0 has the condition of the Br | 1640 Br->replaceSource(0, UnusedOperand); // Index 0 has the condition of the Br |
| 1638 | 1641 |
| 1639 TopLevelBoolOp->setDeleted(); | 1642 TopLevelBoolOp->setDeleted(); |
| 1640 return NewNode; | 1643 return NewNode; |
| 1641 } | 1644 } |
| 1642 | 1645 |
| 1643 } // end of namespace Ice | 1646 } // end of namespace Ice |
| OLD | NEW |