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

Side by Side Diff: src/IceCfgNode.cpp

Issue 802003003: Subzero: Clean up live range construction. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « src/IceCfgNode.h ('k') | src/IceInst.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This file implements the CfgNode class, including the complexities 10 // This file implements the CfgNode class, including the complexities
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 // Check result, set LiveIn=Live 632 // Check result, set LiveIn=Live
633 SizeT &PrevNumNonDeadPhis = Liveness->getNumNonDeadPhis(this); 633 SizeT &PrevNumNonDeadPhis = Liveness->getNumNonDeadPhis(this);
634 bool LiveInChanged = (Live != LiveIn); 634 bool LiveInChanged = (Live != LiveIn);
635 Changed = (NumNonDeadPhis != PrevNumNonDeadPhis || LiveInChanged); 635 Changed = (NumNonDeadPhis != PrevNumNonDeadPhis || LiveInChanged);
636 if (LiveInChanged) 636 if (LiveInChanged)
637 LiveIn = Live; 637 LiveIn = Live;
638 PrevNumNonDeadPhis = NumNonDeadPhis; 638 PrevNumNonDeadPhis = NumNonDeadPhis;
639 return Changed; 639 return Changed;
640 } 640 }
641 641
642 // Now that basic liveness is complete, remove dead instructions that 642 // Once basic liveness is complete, compute actual live ranges. It is
643 // were tentatively marked as dead, and compute actual live ranges. 643 // assumed that within a single basic block, a live range begins at
644 // It is assumed that within a single basic block, a live range begins 644 // most once and ends at most once. This is certainly true for pure
645 // at most once and ends at most once. This is certainly true for 645 // SSA form. It is also true once phis are lowered, since each
646 // pure SSA form. It is also true once phis are lowered, since each
647 // assignment to the phi-based temporary is in a different basic 646 // assignment to the phi-based temporary is in a different basic
648 // block, and there is a single read that ends the live in the basic 647 // block, and there is a single read that ends the live in the basic
649 // block that contained the actual phi instruction. 648 // block that contained the actual phi instruction.
650 void CfgNode::livenessPostprocess(LivenessMode Mode, Liveness *Liveness) { 649 void CfgNode::livenessAddIntervals(Liveness *Liveness, InstNumberT FirstInstNum,
651 InstNumberT FirstInstNum = Inst::NumberSentinel; 650 InstNumberT LastInstNum) {
652 InstNumberT LastInstNum = Inst::NumberSentinel; 651 TimerMarker T1(TimerStack::TT_liveRange, Func);
653 // Process phis in any order. Process only Dest operands.
654 for (auto I = Phis.begin(), E = Phis.end(); I != E; ++I) {
655 I->deleteIfDead();
656 if (I->isDeleted())
657 continue;
658 if (FirstInstNum == Inst::NumberSentinel)
659 FirstInstNum = I->getNumber();
660 assert(I->getNumber() > LastInstNum);
661 LastInstNum = I->getNumber();
662 }
663 // Process instructions
664 for (auto I = Insts.begin(), E = Insts.end(); I != E; ++I) {
665 I->deleteIfDead();
666 if (I->isDeleted())
667 continue;
668 if (FirstInstNum == Inst::NumberSentinel)
669 FirstInstNum = I->getNumber();
670 assert(I->getNumber() > LastInstNum);
671 LastInstNum = I->getNumber();
672 }
673 if (Mode != Liveness_Intervals)
674 return;
675 TimerMarker T1(TimerStack::TT_liveRangeCtor, Func);
676 652
677 SizeT NumVars = Liveness->getNumVarsInNode(this); 653 SizeT NumVars = Liveness->getNumVarsInNode(this);
678 LivenessBV &LiveIn = Liveness->getLiveIn(this); 654 LivenessBV &LiveIn = Liveness->getLiveIn(this);
679 LivenessBV &LiveOut = Liveness->getLiveOut(this); 655 LivenessBV &LiveOut = Liveness->getLiveOut(this);
680 LiveBeginEndMap &MapBegin = *Liveness->getLiveBegin(this); 656 LiveBeginEndMap &MapBegin = *Liveness->getLiveBegin(this);
681 LiveBeginEndMap &MapEnd = *Liveness->getLiveEnd(this); 657 LiveBeginEndMap &MapEnd = *Liveness->getLiveEnd(this);
682 std::sort(MapBegin.begin(), MapBegin.end()); 658 std::sort(MapBegin.begin(), MapBegin.end());
683 std::sort(MapEnd.begin(), MapEnd.end()); 659 std::sort(MapEnd.begin(), MapEnd.end());
684 // Verify there are no duplicates. 660 // Verify there are no duplicates.
685 struct ComparePair { 661 struct ComparePair {
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 if (!First) 989 if (!First)
1014 Str << ", "; 990 Str << ", ";
1015 First = false; 991 First = false;
1016 Str << "%" << I->getName(); 992 Str << "%" << I->getName();
1017 } 993 }
1018 Str << "\n"; 994 Str << "\n";
1019 } 995 }
1020 } 996 }
1021 997
1022 } // end of namespace Ice 998 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfgNode.h ('k') | src/IceInst.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698