Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: src/IceCfgNode.cpp

Issue 2172313002: Subzero : Live Range Splitting after initial Register Allocation (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Cleanup Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 if (Func->getLiveness()->getLiveIn(this).size() >= VarNum) {
Jim Stichnoth 2016/07/29 17:04:06 Shouldn't the '>=' be '>' ? In any case, I think
manasijm 2016/08/01 22:20:03 Done.
463 Func->getLiveness()->getLiveIn(this)[VarNum] = true; 463 assert(!Func->getLiveness()->getLiveIn(this)[VarNum]);
464 Func->getLiveness()->getLiveIn(this)[VarNum] = true;
465 }
464 Phi->setDeleted(); 466 Phi->setDeleted();
465 } 467 }
466 } 468 }
467 if (Desc.empty()) 469 if (Desc.empty())
468 return; 470 return;
469 471
470 TargetLowering *Target = Func->getTarget(); 472 TargetLowering *Target = Func->getTarget();
471 SizeT InEdgeIndex = 0; 473 SizeT InEdgeIndex = 0;
472 for (CfgNode *Pred : InEdges) { 474 for (CfgNode *Pred : InEdges) {
473 CfgNode *Split = splitIncomingEdge(Pred, InEdgeIndex++); 475 CfgNode *Split = splitIncomingEdge(Pred, InEdgeIndex++);
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 // live range begins and ends in this block. If i1<i2, then i1's live range 862 // 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 863 // 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 864 // 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 865 // the block and ends at IEB->second. In any case, we choose the lesser of
864 // i1 and i2 and proceed accordingly. 866 // i1 and i2 and proceed accordingly.
865 InstNumberT LB = i == i1 ? IBB->second : FirstInstNum; 867 InstNumberT LB = i == i1 ? IBB->second : FirstInstNum;
866 InstNumberT LE = i == i2 ? IEB->second : LastInstNum + 1; 868 InstNumberT LE = i == i2 ? IEB->second : LastInstNum + 1;
867 869
868 Variable *Var = Liveness->getVariable(i, this); 870 Variable *Var = Liveness->getVariable(i, this);
869 if (LB > LE) { 871 if (LB > LE) {
870 Var->addLiveRange(FirstInstNum, LE); 872 Var->addLiveRange(FirstInstNum, LE, this);
871 Var->addLiveRange(LB, LastInstNum + 1); 873 Var->addLiveRange(LB, LastInstNum + 1, this);
872 // Assert that Var is a global variable by checking that its liveness 874 // 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 875 // index is less than the number of globals. This ensures that the
874 // LiveInAndOut[] access is valid. 876 // LiveInAndOut[] access is valid.
875 assert(i < Liveness->getNumGlobalVars()); 877 assert(i < Liveness->getNumGlobalVars());
876 LiveInAndOut[i] = false; 878 LiveInAndOut[i] = false;
877 } else { 879 } else {
878 Var->addLiveRange(LB, LE); 880 Var->addLiveRange(LB, LE, this);
879 } 881 }
880 if (i == i1) 882 if (i == i1)
881 ++IBB; 883 ++IBB;
882 if (i == i2) 884 if (i == i2)
883 ++IEB; 885 ++IEB;
884 } 886 }
885 // Process the variables that are live across the entire block. 887 // Process the variables that are live across the entire block.
886 for (int i = LiveInAndOut.find_first(); i != -1; 888 for (int i = LiveInAndOut.find_first(); i != -1;
887 i = LiveInAndOut.find_next(i)) { 889 i = LiveInAndOut.find_next(i)) {
888 Variable *Var = Liveness->getVariable(i, this); 890 Variable *Var = Liveness->getVariable(i, this);
889 if (Liveness->getRangeMask(Var->getIndex())) 891 if (Liveness->getRangeMask(Var->getIndex()))
890 Var->addLiveRange(FirstInstNum, LastInstNum + 1); 892 Var->addLiveRange(FirstInstNum, LastInstNum + 1, this);
891 } 893 }
892 } 894 }
893 895
894 // If this node contains only deleted instructions, and ends in an 896 // If this node contains only deleted instructions, and ends in an
895 // unconditional branch, contract the node by repointing all its in-edges to 897 // unconditional branch, contract the node by repointing all its in-edges to
896 // its successor. 898 // its successor.
897 void CfgNode::contractIfEmpty() { 899 void CfgNode::contractIfEmpty() {
898 if (InEdges.empty()) 900 if (InEdges.empty())
899 return; 901 return;
900 Inst *Branch = nullptr; 902 Inst *Branch = nullptr;
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 UnusedOperand = TopLevelBoolOp->getSrc(0); 1636 UnusedOperand = TopLevelBoolOp->getSrc(0);
1635 assert(UnusedOperand); 1637 assert(UnusedOperand);
1636 1638
1637 Br->replaceSource(0, UnusedOperand); // Index 0 has the condition of the Br 1639 Br->replaceSource(0, UnusedOperand); // Index 0 has the condition of the Br
1638 1640
1639 TopLevelBoolOp->setDeleted(); 1641 TopLevelBoolOp->setDeleted();
1640 return NewNode; 1642 return NewNode;
1641 } 1643 }
1642 1644
1643 } // end of namespace Ice 1645 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfg.cpp ('k') | src/IceClFlags.def » ('j') | src/IceClFlags.def » ('J')

Powered by Google App Engine
This is Rietveld 408576698