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

Side by Side Diff: src/IceInst.cpp

Issue 1844713004: Subzero: Ignore variables with no actual uses. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Also ignore rematerializable variables Created 4 years, 8 months 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 | « no previous file | src/IceLiveness.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/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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 setLastUse(IndexOfVarInInst(Var)); 199 setLastUse(IndexOfVarInInst(Var));
200 } 200 }
201 } 201 }
202 202
203 bool Inst::liveness(InstNumberT InstNumber, LivenessBV &Live, 203 bool Inst::liveness(InstNumberT InstNumber, LivenessBV &Live,
204 Liveness *Liveness, LiveBeginEndMap *LiveBegin, 204 Liveness *Liveness, LiveBeginEndMap *LiveBegin,
205 LiveBeginEndMap *LiveEnd) { 205 LiveBeginEndMap *LiveEnd) {
206 assert(!isDeleted()); 206 assert(!isDeleted());
207 207
208 Dead = false; 208 Dead = false;
209 if (Dest) { 209 if (Dest && !Dest->isRematerializable()) {
210 SizeT VarNum = Liveness->getLiveIndex(Dest->getIndex()); 210 SizeT VarNum = Liveness->getLiveIndex(Dest->getIndex());
211 if (Live[VarNum]) { 211 if (Live[VarNum]) {
212 if (!isDestRedefined()) { 212 if (!isDestRedefined()) {
213 Live[VarNum] = false; 213 Live[VarNum] = false;
214 if (LiveBegin && Liveness->getRangeMask(Dest->getIndex())) { 214 if (LiveBegin && Liveness->getRangeMask(Dest->getIndex())) {
215 LiveBegin->push_back(std::make_pair(VarNum, InstNumber)); 215 LiveBegin->push_back(std::make_pair(VarNum, InstNumber));
216 } 216 }
217 } 217 }
218 } else { 218 } else {
219 if (!hasSideEffects()) 219 if (!hasSideEffects())
220 Dead = true; 220 Dead = true;
221 } 221 }
222 } 222 }
223 if (Dead) 223 if (Dead)
224 return false; 224 return false;
225 // Phi arguments only get added to Live in the predecessor node, but we still 225 // Phi arguments only get added to Live in the predecessor node, but we still
226 // need to update LiveRangesEnded. 226 // need to update LiveRangesEnded.
227 bool IsPhi = llvm::isa<InstPhi>(this); 227 bool IsPhi = llvm::isa<InstPhi>(this);
228 resetLastUses(); 228 resetLastUses();
229 FOREACH_VAR_IN_INST(Var, *this) { 229 FOREACH_VAR_IN_INST(Var, *this) {
230 if (Var->isRematerializable())
231 continue;
230 SizeT VarNum = Liveness->getLiveIndex(Var->getIndex()); 232 SizeT VarNum = Liveness->getLiveIndex(Var->getIndex());
231 if (!Live[VarNum]) { 233 if (!Live[VarNum]) {
232 setLastUse(IndexOfVarInInst(Var)); 234 setLastUse(IndexOfVarInInst(Var));
233 if (!IsPhi) { 235 if (!IsPhi) {
234 Live[VarNum] = true; 236 Live[VarNum] = true;
235 // For a variable in SSA form, its live range can end at most once in a 237 // For a variable in SSA form, its live range can end at most once in a
236 // basic block. However, after lowering to two-address instructions, we 238 // basic block. However, after lowering to two-address instructions, we
237 // end up with sequences like "t=b;t+=c;a=t" where t's live range 239 // end up with sequences like "t=b;t+=c;a=t" where t's live range
238 // begins and ends twice. ICE only allows a variable to have a single 240 // begins and ends twice. ICE only allows a variable to have a single
239 // liveness interval in a basic block (except for blocks where a 241 // liveness interval in a basic block (except for blocks where a
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 // Updates liveness for a particular operand based on the given predecessor 406 // Updates liveness for a particular operand based on the given predecessor
405 // edge. Doesn't mark the operand as live if the Phi instruction is dead or 407 // edge. Doesn't mark the operand as live if the Phi instruction is dead or
406 // deleted. 408 // deleted.
407 void InstPhi::livenessPhiOperand(LivenessBV &Live, CfgNode *Target, 409 void InstPhi::livenessPhiOperand(LivenessBV &Live, CfgNode *Target,
408 Liveness *Liveness) { 410 Liveness *Liveness) {
409 if (isDeleted() || Dead) 411 if (isDeleted() || Dead)
410 return; 412 return;
411 for (SizeT I = 0; I < getSrcSize(); ++I) { 413 for (SizeT I = 0; I < getSrcSize(); ++I) {
412 if (Labels[I] == Target) { 414 if (Labels[I] == Target) {
413 if (auto *Var = llvm::dyn_cast<Variable>(getSrc(I))) { 415 if (auto *Var = llvm::dyn_cast<Variable>(getSrc(I))) {
414 SizeT SrcIndex = Liveness->getLiveIndex(Var->getIndex()); 416 if (!Var->isRematerializable()) {
415 if (!Live[SrcIndex]) { 417 SizeT SrcIndex = Liveness->getLiveIndex(Var->getIndex());
416 setLastUse(I); 418 if (!Live[SrcIndex]) {
417 Live[SrcIndex] = true; 419 setLastUse(I);
420 Live[SrcIndex] = true;
421 }
418 } 422 }
419 } 423 }
420 return; 424 return;
421 } 425 }
422 } 426 }
423 llvm_unreachable("Phi operand not found for specified target node"); 427 llvm_unreachable("Phi operand not found for specified target node");
424 } 428 }
425 429
426 // Change "a=phi(...)" to "a_phi=phi(...)" and return a new instruction 430 // Change "a=phi(...)" to "a_phi=phi(...)" and return a new instruction
427 // "a=a_phi". 431 // "a=a_phi".
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 // upper 32 bits of rax. We need to recognize and preserve these. 1015 // upper 32 bits of rax. We need to recognize and preserve these.
1012 return true; 1016 return true;
1013 } 1017 }
1014 if (!Dest->hasReg() && !SrcVar->hasReg() && 1018 if (!Dest->hasReg() && !SrcVar->hasReg() &&
1015 Dest->getStackOffset() == SrcVar->getStackOffset()) 1019 Dest->getStackOffset() == SrcVar->getStackOffset())
1016 return true; 1020 return true;
1017 return false; 1021 return false;
1018 } 1022 }
1019 1023
1020 } // end of namespace Ice 1024 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | src/IceLiveness.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698