/** * Can this instruction be deleted? LVA will preserve instructions based on whether operands (variables) * are living but even if there are no living variables then the instruction itself may not be able to be removed * during DCE for other reasons (like if it unconditionally has a side-effect) */ public boolean isDeletable() { return !(hasSideEffects() || operation.isDebugOp() || canRaiseException() || transfersControl()); }
/** * Can this instruction be deleted? LVA will preserve instructions based on whether operands (variables) * are living but even if there are no living variables then the instruction itself may not be able to be removed * during DCE for other reasons (like if it unconditionally has a side-effect) */ public boolean isDeletable() { return !(hasSideEffects() || operation.isDebugOp() || canRaiseException() || transfersControl()); }
if (!instr.hasSideEffects()) { if (instr instanceof CopyInstr) { if (res.equals(val) && instr.canBeDeletedFromScope(s)) {
if (!instr.hasSideEffects()) { if (instr instanceof CopyInstr) { if (res.equals(val) && instr.canBeDeletedFromScope(s)) {
if (!res.equals(val)) { recordSimplification(res, val, valueMap, simplificationMap); } else if (!i.hasSideEffects()) { if (i instanceof CopyInstr) { if (i.canBeDeleted(s)) {
if (!res.equals(val)) { recordSimplification(res, val, valueMap, simplificationMap); } else if (!i.hasSideEffects()) { if (i instanceof CopyInstr) { if (i.canBeDeleted(s)) {
public boolean canBeDeleted(IRScope s) { if (hasSideEffects() || getOperation().isDebugOp() || getOperation().canRaiseException() || transfersControl()) { return false; } else if (this instanceof ResultInstr) { Variable r = ((ResultInstr)this).getResult(); if (s.bindingHasEscaped() && !r.getName().equals(Variable.BLOCK)) { // If the binding of this scope has escaped, then we have to preserve writes to // all local variables because anyone who uses the binding might query any of the // local variables from the binding. This is safe, but extremely conservative. return !(r instanceof LocalVariable); } else if (s.usesEval() && r.getName().equals(Variable.BLOCK)) { // If this scope (or any nested scope) has any evals, then the eval might have a yield which // would use %block. In that scenario, we cannot delete the '%block = recv_closure' instruction. // This is safe, but conservative. return false; } else if (s.usesZSuper() && getOperation().isArgReceive()) { // If this scope (or any nested scope) has a ZSuperInstr, then the arguments of this // scope could be used by any of those ZSuper instructions. If so, we cannot delete // the argument receive. return false; } else { return true; } } else { return true; } }
public boolean canBeDeleted(IRScope s) { if (hasSideEffects() || getOperation().isDebugOp() || getOperation().canRaiseException() || transfersControl()) { return false; } else if (this instanceof ResultInstr) { Variable r = ((ResultInstr)this).getResult(); if (s.bindingHasEscaped() && !r.getName().equals(Variable.BLOCK)) { // If the binding of this scope has escaped, then we have to preserve writes to // all local variables because anyone who uses the binding might query any of the // local variables from the binding. This is safe, but extremely conservative. return !(r instanceof LocalVariable); } else if (s.usesEval() && r.getName().equals(Variable.BLOCK)) { // If this scope (or any nested scope) has any evals, then the eval might have a yield which // would use %block. In that scenario, we cannot delete the '%block = recv_closure' instruction. // This is safe, but conservative. return false; } else if (s.usesZSuper() && getOperation().isArgReceive()) { // If this scope (or any nested scope) has a ZSuperInstr, then the arguments of this // scope could be used by any of those ZSuper instructions. If so, we cannot delete // the argument receive. return false; } else { return true; } } else { return true; } }