OLD | NEW |
1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===// | 1 //===- subzero/src/IceCfg.cpp - Control flow graph 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 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 | 891 |
892 // Traverse every Variable of every Inst and verify that it appears within the | 892 // Traverse every Variable of every Inst and verify that it appears within the |
893 // Variable's computed live range. | 893 // Variable's computed live range. |
894 bool Cfg::validateLiveness() const { | 894 bool Cfg::validateLiveness() const { |
895 TimerMarker T(TimerStack::TT_validateLiveness, this); | 895 TimerMarker T(TimerStack::TT_validateLiveness, this); |
896 bool Valid = true; | 896 bool Valid = true; |
897 OstreamLocker L(Ctx); | 897 OstreamLocker L(Ctx); |
898 Ostream &Str = Ctx->getStrDump(); | 898 Ostream &Str = Ctx->getStrDump(); |
899 for (CfgNode *Node : Nodes) { | 899 for (CfgNode *Node : Nodes) { |
900 Inst *FirstInst = nullptr; | 900 Inst *FirstInst = nullptr; |
901 for (Inst &Inst : Node->getInsts()) { | 901 for (Inst &Instr : Node->getInsts()) { |
902 if (Inst.isDeleted()) | 902 if (Instr.isDeleted()) |
903 continue; | 903 continue; |
904 if (FirstInst == nullptr) | 904 if (FirstInst == nullptr) |
905 FirstInst = &Inst; | 905 FirstInst = &Instr; |
906 InstNumberT InstNumber = Inst.getNumber(); | 906 InstNumberT InstNumber = Instr.getNumber(); |
907 if (Variable *Dest = Inst.getDest()) { | 907 if (Variable *Dest = Instr.getDest()) { |
908 if (!Dest->getIgnoreLiveness()) { | 908 if (!Dest->getIgnoreLiveness()) { |
909 bool Invalid = false; | 909 bool Invalid = false; |
910 constexpr bool IsDest = true; | 910 constexpr bool IsDest = true; |
911 if (!Dest->getLiveRange().containsValue(InstNumber, IsDest)) | 911 if (!Dest->getLiveRange().containsValue(InstNumber, IsDest)) |
912 Invalid = true; | 912 Invalid = true; |
913 // Check that this instruction actually *begins* Dest's live range, | 913 // Check that this instruction actually *begins* Dest's live range, |
914 // by checking that Dest is not live in the previous instruction. As | 914 // by checking that Dest is not live in the previous instruction. As |
915 // a special exception, we don't check this for the first instruction | 915 // a special exception, we don't check this for the first instruction |
916 // of the block, because a Phi temporary may be live at the end of | 916 // of the block, because a Phi temporary may be live at the end of |
917 // the previous block, and if it is also assigned in the first | 917 // the previous block, and if it is also assigned in the first |
918 // instruction of this block, the adjacent live ranges get merged. | 918 // instruction of this block, the adjacent live ranges get merged. |
919 if (static_cast<class Inst *>(&Inst) != FirstInst && | 919 if (static_cast<class Inst *>(&Instr) != FirstInst && |
920 !Inst.isDestRedefined() && | 920 !Instr.isDestRedefined() && |
921 Dest->getLiveRange().containsValue(InstNumber - 1, IsDest)) | 921 Dest->getLiveRange().containsValue(InstNumber - 1, IsDest)) |
922 Invalid = true; | 922 Invalid = true; |
923 if (Invalid) { | 923 if (Invalid) { |
924 Valid = false; | 924 Valid = false; |
925 Str << "Liveness error: inst " << Inst.getNumber() << " dest "; | 925 Str << "Liveness error: inst " << Instr.getNumber() << " dest "; |
926 Dest->dump(this); | 926 Dest->dump(this); |
927 Str << " live range " << Dest->getLiveRange() << "\n"; | 927 Str << " live range " << Dest->getLiveRange() << "\n"; |
928 } | 928 } |
929 } | 929 } |
930 } | 930 } |
931 FOREACH_VAR_IN_INST(Var, Inst) { | 931 FOREACH_VAR_IN_INST(Var, Instr) { |
932 static constexpr bool IsDest = false; | 932 static constexpr bool IsDest = false; |
933 if (!Var->getIgnoreLiveness() && | 933 if (!Var->getIgnoreLiveness() && |
934 !Var->getLiveRange().containsValue(InstNumber, IsDest)) { | 934 !Var->getLiveRange().containsValue(InstNumber, IsDest)) { |
935 Valid = false; | 935 Valid = false; |
936 Str << "Liveness error: inst " << Inst.getNumber() << " var "; | 936 Str << "Liveness error: inst " << Instr.getNumber() << " var "; |
937 Var->dump(this); | 937 Var->dump(this); |
938 Str << " live range " << Var->getLiveRange() << "\n"; | 938 Str << " live range " << Var->getLiveRange() << "\n"; |
939 } | 939 } |
940 } | 940 } |
941 } | 941 } |
942 } | 942 } |
943 return Valid; | 943 return Valid; |
944 } | 944 } |
945 | 945 |
946 void Cfg::contractEmptyNodes() { | 946 void Cfg::contractEmptyNodes() { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 } | 1135 } |
1136 } | 1136 } |
1137 // Print each basic block | 1137 // Print each basic block |
1138 for (CfgNode *Node : Nodes) | 1138 for (CfgNode *Node : Nodes) |
1139 Node->dump(this); | 1139 Node->dump(this); |
1140 if (isVerbose(IceV_Instructions)) | 1140 if (isVerbose(IceV_Instructions)) |
1141 Str << "}\n"; | 1141 Str << "}\n"; |
1142 } | 1142 } |
1143 | 1143 |
1144 } // end of namespace Ice | 1144 } // end of namespace Ice |
OLD | NEW |