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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 691 InstNumberT LastInstNum) { | 691 InstNumberT LastInstNum) { |
| 692 TimerMarker T1(TimerStack::TT_liveRange, Func); | 692 TimerMarker T1(TimerStack::TT_liveRange, Func); |
| 693 | 693 |
| 694 SizeT NumVars = Liveness->getNumVarsInNode(this); | 694 SizeT NumVars = Liveness->getNumVarsInNode(this); |
| 695 LivenessBV &LiveIn = Liveness->getLiveIn(this); | 695 LivenessBV &LiveIn = Liveness->getLiveIn(this); |
| 696 LivenessBV &LiveOut = Liveness->getLiveOut(this); | 696 LivenessBV &LiveOut = Liveness->getLiveOut(this); |
| 697 LiveBeginEndMap &MapBegin = *Liveness->getLiveBegin(this); | 697 LiveBeginEndMap &MapBegin = *Liveness->getLiveBegin(this); |
| 698 LiveBeginEndMap &MapEnd = *Liveness->getLiveEnd(this); | 698 LiveBeginEndMap &MapEnd = *Liveness->getLiveEnd(this); |
| 699 std::sort(MapBegin.begin(), MapBegin.end()); | 699 std::sort(MapBegin.begin(), MapBegin.end()); |
| 700 std::sort(MapEnd.begin(), MapEnd.end()); | 700 std::sort(MapEnd.begin(), MapEnd.end()); |
| 701 // Verify there are no duplicates. | 701 if (BuildDefs::asserts()) { |
|
John
2015/09/25 23:02:16
this would be easier to read (I think) if written
Jim Stichnoth
2015/09/25 23:56:01
Done.
| |
| 702 auto ComparePair = | 702 // Verify there are no duplicates. |
| 703 [](const LiveBeginEndMapEntry &A, const LiveBeginEndMapEntry &B) { | 703 auto ComparePair = |
| 704 return A.first == B.first; | 704 [](const LiveBeginEndMapEntry &A, const LiveBeginEndMapEntry &B) { |
| 705 }; | 705 return A.first == B.first; |
| 706 (void)ComparePair; | 706 }; |
| 707 assert(std::adjacent_find(MapBegin.begin(), MapBegin.end(), ComparePair) == | 707 if (std::adjacent_find(MapBegin.begin(), MapBegin.end(), ComparePair) != |
| 708 MapBegin.end()); | 708 MapBegin.end() || |
| 709 assert(std::adjacent_find(MapEnd.begin(), MapEnd.end(), ComparePair) == | 709 std::adjacent_find(MapEnd.begin(), MapEnd.end(), ComparePair) != |
| 710 MapEnd.end()); | 710 MapEnd.end()) { |
| 711 // There is definitely a liveness error. Print all the errors. | |
| 712 if (BuildDefs::dump()) { | |
| 713 GlobalContext *Ctx = Func->getContext(); | |
| 714 OstreamLocker L(Ctx); | |
| 715 Ostream &Str = Ctx->getStrDump(); | |
| 716 if (Func->isVerbose()) { | |
| 717 Str << "Live range errors in the following block:\n"; | |
| 718 dump(Func); | |
| 719 } | |
| 720 for (auto Start = MapBegin.begin(); | |
| 721 (Start = std::adjacent_find(Start, MapBegin.end(), ComparePair)) != | |
| 722 MapBegin.end(); | |
| 723 ++Start) { | |
| 724 auto Next = Start + 1; | |
| 725 Str << "Duplicate LR begin, block " << getName() << ", instructions " | |
| 726 << Start->second << " & " << Next->second << ", variable " | |
| 727 << Liveness->getVariable(Start->first, this)->getName(Func) | |
| 728 << "\n"; | |
| 729 } | |
| 730 for (auto Start = MapEnd.begin(); | |
| 731 (Start = std::adjacent_find(Start, MapEnd.end(), ComparePair)) != | |
| 732 MapEnd.end(); | |
| 733 ++Start) { | |
| 734 auto Next = Start + 1; | |
| 735 Str << "Duplicate LR end, block " << getName() << ", instructions " | |
| 736 << Start->second << " & " << Next->second << ", variable " | |
| 737 << Liveness->getVariable(Start->first, this)->getName(Func) | |
| 738 << "\n"; | |
| 739 } | |
| 740 } | |
| 741 llvm::report_fatal_error("livenessAddIntervals: Liveness error"); | |
| 742 } | |
| 743 } | |
| 711 | 744 |
| 712 LivenessBV LiveInAndOut = LiveIn; | 745 LivenessBV LiveInAndOut = LiveIn; |
| 713 LiveInAndOut &= LiveOut; | 746 LiveInAndOut &= LiveOut; |
| 714 | 747 |
| 715 // Iterate in parallel across the sorted MapBegin[] and MapEnd[]. | 748 // Iterate in parallel across the sorted MapBegin[] and MapEnd[]. |
| 716 auto IBB = MapBegin.begin(), IEB = MapEnd.begin(); | 749 auto IBB = MapBegin.begin(), IEB = MapEnd.begin(); |
| 717 auto IBE = MapBegin.end(), IEE = MapEnd.end(); | 750 auto IBE = MapBegin.end(), IEE = MapEnd.end(); |
| 718 while (IBB != IBE || IEB != IEE) { | 751 while (IBB != IBE || IEB != IEE) { |
| 719 SizeT i1 = IBB == IBE ? NumVars : IBB->first; | 752 SizeT i1 = IBB == IBE ? NumVars : IBB->first; |
| 720 SizeT i2 = IEB == IEE ? NumVars : IEB->first; | 753 SizeT i2 = IEB == IEE ? NumVars : IEB->first; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 868 Str << "\n"; | 901 Str << "\n"; |
| 869 } | 902 } |
| 870 | 903 |
| 871 void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr, | 904 void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr, |
| 872 CfgVector<SizeT> &LiveRegCount) { | 905 CfgVector<SizeT> &LiveRegCount) { |
| 873 if (!BuildDefs::dump()) | 906 if (!BuildDefs::dump()) |
| 874 return; | 907 return; |
| 875 bool First = true; | 908 bool First = true; |
| 876 Variable *Dest = Instr->getDest(); | 909 Variable *Dest = Instr->getDest(); |
| 877 // Normally we increment the live count for the dest register. But we | 910 // Normally we increment the live count for the dest register. But we |
| 878 // shouldn't if the instruction's IsDestNonKillable flag is set, because this | 911 // shouldn't if the instruction's IsDestRedefined flag is set, because this |
| 879 // means that the target lowering created this instruction as a non-SSA | 912 // means that the target lowering created this instruction as a non-SSA |
| 880 // assignment; i.e., a different, previous instruction started the dest | 913 // assignment; i.e., a different, previous instruction started the dest |
| 881 // variable's live range. | 914 // variable's live range. |
| 882 if (!Instr->isDestNonKillable() && Dest && Dest->hasReg()) | 915 if (!Instr->isDestRedefined() && Dest && Dest->hasReg()) |
| 883 ++LiveRegCount[Dest->getRegNum()]; | 916 ++LiveRegCount[Dest->getRegNum()]; |
| 884 FOREACH_VAR_IN_INST(Var, *Instr) { | 917 FOREACH_VAR_IN_INST(Var, *Instr) { |
| 885 bool ShouldReport = Instr->isLastUse(Var); | 918 bool ShouldReport = Instr->isLastUse(Var); |
| 886 if (ShouldReport && Var->hasReg()) { | 919 if (ShouldReport && Var->hasReg()) { |
| 887 // Don't report end of live range until the live count reaches 0. | 920 // Don't report end of live range until the live count reaches 0. |
| 888 SizeT NewCount = --LiveRegCount[Var->getRegNum()]; | 921 SizeT NewCount = --LiveRegCount[Var->getRegNum()]; |
| 889 if (NewCount) | 922 if (NewCount) |
| 890 ShouldReport = false; | 923 ShouldReport = false; |
| 891 } | 924 } |
| 892 if (ShouldReport) { | 925 if (ShouldReport) { |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1303 InstIntrinsicCall *Inst = InstIntrinsicCall::create( | 1336 InstIntrinsicCall *Inst = InstIntrinsicCall::create( |
| 1304 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); | 1337 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); |
| 1305 Inst->addArg(AtomicRMWOp); | 1338 Inst->addArg(AtomicRMWOp); |
| 1306 Inst->addArg(Counter); | 1339 Inst->addArg(Counter); |
| 1307 Inst->addArg(One); | 1340 Inst->addArg(One); |
| 1308 Inst->addArg(OrderAcquireRelease); | 1341 Inst->addArg(OrderAcquireRelease); |
| 1309 Insts.push_front(Inst); | 1342 Insts.push_front(Inst); |
| 1310 } | 1343 } |
| 1311 | 1344 |
| 1312 } // end of namespace Ice | 1345 } // end of namespace Ice |
| OLD | NEW |