Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceInst.cpp - High-level instruction implementation ----===// | 1 //===- subzero/src/IceInst.cpp - High-level instruction 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 bool Inst::liveness(InstNumberT InstNumber, LivenessBV &Live, | 175 bool Inst::liveness(InstNumberT InstNumber, LivenessBV &Live, |
| 176 Liveness *Liveness, LiveBeginEndMap *LiveBegin, | 176 Liveness *Liveness, LiveBeginEndMap *LiveBegin, |
| 177 LiveBeginEndMap *LiveEnd) { | 177 LiveBeginEndMap *LiveEnd) { |
| 178 assert(!isDeleted()); | 178 assert(!isDeleted()); |
| 179 | 179 |
| 180 Dead = false; | 180 Dead = false; |
| 181 if (Dest) { | 181 if (Dest) { |
| 182 SizeT VarNum = Liveness->getLiveIndex(Dest->getIndex()); | 182 SizeT VarNum = Liveness->getLiveIndex(Dest->getIndex()); |
| 183 if (Live[VarNum]) { | 183 if (Live[VarNum]) { |
| 184 if (!isDestNonKillable()) { | 184 if (!isDestNonKillable()) { |
| 185 Live[VarNum] = false; | 185 Live[VarNum] = false; |
|
Jim Stichnoth
2015/08/27 05:03:06
I kind of expected Dest to be marked as having a u
jvoung (off chromium)
2015/08/27 18:34:27
I'm not against counting Dests too, but wanted to
ascull
2015/08/28 19:26:36
Dest counting will return.
| |
| 186 if (LiveBegin && Liveness->getRangeMask(Dest->getIndex())) { | 186 if (LiveBegin && Liveness->getRangeMask(Dest->getIndex())) { |
| 187 LiveBegin->push_back(std::make_pair(VarNum, InstNumber)); | 187 LiveBegin->push_back(std::make_pair(VarNum, InstNumber)); |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 } else { | 190 } else { |
| 191 if (!hasSideEffects()) | 191 if (!hasSideEffects()) |
| 192 Dead = true; | 192 Dead = true; |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 if (Dead) | 195 if (Dead) |
| 196 return false; | 196 return false; |
| 197 // Phi arguments only get added to Live in the predecessor node, but | 197 // Phi arguments only get added to Live in the predecessor node, but |
| 198 // we still need to update LiveRangesEnded. | 198 // we still need to update LiveRangesEnded. |
| 199 bool IsPhi = llvm::isa<InstPhi>(this); | 199 bool IsPhi = llvm::isa<InstPhi>(this); |
| 200 resetLastUses(); | 200 resetLastUses(); |
| 201 SizeT VarIndex = 0; | 201 SizeT VarIndex = 0; |
| 202 for (SizeT I = 0; I < getSrcSize(); ++I) { | 202 for (SizeT I = 0; I < getSrcSize(); ++I) { |
| 203 Operand *Src = getSrc(I); | 203 Operand *Src = getSrc(I); |
| 204 SizeT NumVars = Src->getNumVars(); | 204 SizeT NumVars = Src->getNumVars(); |
| 205 for (SizeT J = 0; J < NumVars; ++J, ++VarIndex) { | 205 for (SizeT J = 0; J < NumVars; ++J, ++VarIndex) { |
| 206 const Variable *Var = Src->getVar(J); | 206 Variable *Var = Src->getVar(J); |
| 207 // TODO(ascull): get the loop nest depth | |
| 208 Var->addUse(1); | |
|
Jim Stichnoth
2015/08/27 05:03:06
So there's kind of a maybe sort of big problem her
jvoung (off chromium)
2015/08/27 18:34:27
Good point =) So the TODO was almost done ;-)
Se
Jim Stichnoth
2015/08/27 20:04:21
Actually, incrementing the use count right at the
ascull
2015/08/28 19:26:36
Moved into VMetadata.
| |
| 207 SizeT VarNum = Liveness->getLiveIndex(Var->getIndex()); | 209 SizeT VarNum = Liveness->getLiveIndex(Var->getIndex()); |
| 208 if (!Live[VarNum]) { | 210 if (!Live[VarNum]) { |
| 209 setLastUse(VarIndex); | 211 setLastUse(VarIndex); |
| 210 if (!IsPhi) { | 212 if (!IsPhi) { |
| 211 Live[VarNum] = true; | 213 Live[VarNum] = true; |
| 212 // For a variable in SSA form, its live range can end at | 214 // For a variable in SSA form, its live range can end at |
| 213 // most once in a basic block. However, after lowering to | 215 // most once in a basic block. However, after lowering to |
| 214 // two-address instructions, we end up with sequences like | 216 // two-address instructions, we end up with sequences like |
| 215 // "t=b;t+=c;a=t" where t's live range begins and ends | 217 // "t=b;t+=c;a=t" where t's live range begins and ends |
| 216 // twice. ICE only allows a variable to have a single | 218 // twice. ICE only allows a variable to have a single |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 974 // preserve these. | 976 // preserve these. |
| 975 return true; | 977 return true; |
| 976 } | 978 } |
| 977 if (!Dest->hasReg() && !SrcVar->hasReg() && | 979 if (!Dest->hasReg() && !SrcVar->hasReg() && |
| 978 Dest->getStackOffset() == SrcVar->getStackOffset()) | 980 Dest->getStackOffset() == SrcVar->getStackOffset()) |
| 979 return true; | 981 return true; |
| 980 return false; | 982 return false; |
| 981 } | 983 } |
| 982 | 984 |
| 983 } // end of namespace Ice | 985 } // end of namespace Ice |
| OLD | NEW |