| OLD | NEW |
| 1 //===- subzero/src/IceRegAlloc.cpp - Linear-scan implementation -----------===// | 1 //===- subzero/src/IceRegAlloc.cpp - Linear-scan 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 162 |
| 163 if (!BuildDefs::dump()) | 163 if (!BuildDefs::dump()) |
| 164 return false; | 164 return false; |
| 165 | 165 |
| 166 const VarList &Vars = Func->getVariables(); | 166 const VarList &Vars = Func->getVariables(); |
| 167 OstreamLocker L(Ctx); | 167 OstreamLocker L(Ctx); |
| 168 Ostream &Str = Ctx->getStrDump(); | 168 Ostream &Str = Ctx->getStrDump(); |
| 169 for (SizeT VarNum : DefsWithoutUses) { | 169 for (SizeT VarNum : DefsWithoutUses) { |
| 170 Variable *Var = Vars[VarNum]; | 170 Variable *Var = Vars[VarNum]; |
| 171 Str << "LR def without use, instruction " << LRBegin[VarNum] | 171 Str << "LR def without use, instruction " << LRBegin[VarNum] |
| 172 << ", variable " << Var->getName(Func) << "\n"; | 172 << ", variable " << Var->getName() << "\n"; |
| 173 } | 173 } |
| 174 for (SizeT VarNum : UsesBeforeDefs) { | 174 for (SizeT VarNum : UsesBeforeDefs) { |
| 175 Variable *Var = Vars[VarNum]; | 175 Variable *Var = Vars[VarNum]; |
| 176 Str << "LR use before def, instruction " << LREnd[VarNum] << ", variable " | 176 Str << "LR use before def, instruction " << LREnd[VarNum] << ", variable " |
| 177 << Var->getName(Func) << "\n"; | 177 << Var->getName() << "\n"; |
| 178 } | 178 } |
| 179 return false; | 179 return false; |
| 180 } | 180 } |
| 181 | 181 |
| 182 // Prepare for very simple register allocation of only infinite-weight Variables | 182 // Prepare for very simple register allocation of only infinite-weight Variables |
| 183 // while respecting pre-colored Variables. Some properties we take advantage of: | 183 // while respecting pre-colored Variables. Some properties we take advantage of: |
| 184 // | 184 // |
| 185 // * Live ranges of interest consist of a single segment. | 185 // * Live ranges of interest consist of a single segment. |
| 186 // | 186 // |
| 187 // * Live ranges of interest never span a call instruction. | 187 // * Live ranges of interest never span a call instruction. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 return; | 270 return; |
| 271 } | 271 } |
| 272 | 272 |
| 273 if (!DefsWithoutUses.empty() || !UsesBeforeDefs.empty()) { | 273 if (!DefsWithoutUses.empty() || !UsesBeforeDefs.empty()) { |
| 274 if (BuildDefs::dump()) { | 274 if (BuildDefs::dump()) { |
| 275 OstreamLocker L(Ctx); | 275 OstreamLocker L(Ctx); |
| 276 Ostream &Str = Ctx->getStrDump(); | 276 Ostream &Str = Ctx->getStrDump(); |
| 277 for (SizeT VarNum : DefsWithoutUses) { | 277 for (SizeT VarNum : DefsWithoutUses) { |
| 278 Variable *Var = Vars[VarNum]; | 278 Variable *Var = Vars[VarNum]; |
| 279 Str << "LR def without use, instruction " << LRBegin[VarNum] | 279 Str << "LR def without use, instruction " << LRBegin[VarNum] |
| 280 << ", variable " << Var->getName(Func) << "\n"; | 280 << ", variable " << Var->getName() << "\n"; |
| 281 } | 281 } |
| 282 for (SizeT VarNum : UsesBeforeDefs) { | 282 for (SizeT VarNum : UsesBeforeDefs) { |
| 283 Variable *Var = Vars[VarNum]; | 283 Variable *Var = Vars[VarNum]; |
| 284 Str << "LR use before def, instruction " << LREnd[VarNum] | 284 Str << "LR use before def, instruction " << LREnd[VarNum] |
| 285 << ", variable " << Var->getName(Func) << "\n"; | 285 << ", variable " << Var->getName() << "\n"; |
| 286 } | 286 } |
| 287 } | 287 } |
| 288 llvm::report_fatal_error("initForInfOnly: Liveness error"); | 288 llvm::report_fatal_error("initForInfOnly: Liveness error"); |
| 289 } | 289 } |
| 290 // This isn't actually a fatal condition, but it would be nice to know if we | 290 // This isn't actually a fatal condition, but it would be nice to know if we |
| 291 // somehow pre-calculated Unhandled's size wrong. | 291 // somehow pre-calculated Unhandled's size wrong. |
| 292 assert(NumVars == 0); | 292 assert(NumVars == 0); |
| 293 | 293 |
| 294 // Don't build up the list of Kills because we know that no infinite-weight | 294 // Don't build up the list of Kills because we know that no infinite-weight |
| 295 // Variable has a live range spanning a call. | 295 // Variable has a live range spanning a call. |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 // At this point, we need to find some reserve register that is already | 708 // At this point, we need to find some reserve register that is already |
| 709 // assigned to a non-infinite-weight variable. This could happen if some | 709 // assigned to a non-infinite-weight variable. This could happen if some |
| 710 // variable was previously assigned an alias of such a register. | 710 // variable was previously assigned an alias of such a register. |
| 711 MinWeightIndex = findMinWeightIndex(Iter.RegMaskUnfiltered, Iter.Weights); | 711 MinWeightIndex = findMinWeightIndex(Iter.RegMaskUnfiltered, Iter.Weights); |
| 712 } | 712 } |
| 713 if (Iter.Cur->getWeight(Func) <= Iter.Weights[MinWeightIndex]) { | 713 if (Iter.Cur->getWeight(Func) <= Iter.Weights[MinWeightIndex]) { |
| 714 dumpLiveRangeTrace("Failing ", Iter.Cur); | 714 dumpLiveRangeTrace("Failing ", Iter.Cur); |
| 715 Func->setError("Unable to find a physical register for an " | 715 Func->setError("Unable to find a physical register for an " |
| 716 "infinite-weight live range " | 716 "infinite-weight live range " |
| 717 "(consider using -reg-reserve): " + | 717 "(consider using -reg-reserve): " + |
| 718 Iter.Cur->getName(Func)); | 718 Iter.Cur->getName()); |
| 719 Handled.push_back(Iter.Cur); | 719 Handled.push_back(Iter.Cur); |
| 720 return; | 720 return; |
| 721 } | 721 } |
| 722 // At this point, MinWeightIndex points to a valid reserve register to | 722 // At this point, MinWeightIndex points to a valid reserve register to |
| 723 // reallocate to Iter.Cur, so drop into the eviction code. | 723 // reallocate to Iter.Cur, so drop into the eviction code. |
| 724 } | 724 } |
| 725 | 725 |
| 726 // Evict all live ranges in Active that register number MinWeightIndex is | 726 // Evict all live ranges in Active that register number MinWeightIndex is |
| 727 // assigned to. | 727 // assigned to. |
| 728 const auto &Aliases = *RegAliases[MinWeightIndex]; | 728 const auto &Aliases = *RegAliases[MinWeightIndex]; |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 Str << "\n"; | 1009 Str << "\n"; |
| 1010 } | 1010 } |
| 1011 Str << "++++++ Inactive:\n"; | 1011 Str << "++++++ Inactive:\n"; |
| 1012 for (const Variable *Item : Inactive) { | 1012 for (const Variable *Item : Inactive) { |
| 1013 dumpLiveRange(Item, Func); | 1013 dumpLiveRange(Item, Func); |
| 1014 Str << "\n"; | 1014 Str << "\n"; |
| 1015 } | 1015 } |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 } // end of namespace Ice | 1018 } // end of namespace Ice |
| OLD | NEW |