Lowering::TransformUnusedIndirection(data->AsIndir(), this, block);
}
- blockRange.Remove(store);
-
- assert(!opts.MinOpts());
- fgStmtRemoved = true;
+ fgRemoveDeadStoreLIR(store, block);
}
}
}
// Remove the store. DCE will iteratively clean up any ununsed operands.
lclVarNode->gtOp1->SetUnusedValue();
- // If the store is marked as a late argument, it is referenced by a call. Instead of removing
- // it, bash it to a NOP.
- if ((node->gtFlags & GTF_LATE_ARG) != 0)
- {
- JITDUMP("node is a late arg; replacing with NOP\n");
- node->gtBashToNOP();
-
- // NOTE: this is a bit of a hack. We need to keep these nodes around as they are
- // referenced by the call, but they're considered side-effect-free non-value-producing
- // nodes, so they will be removed if we don't do this.
- node->gtFlags |= GTF_ORDER_SIDEEFF;
- }
- else
- {
- blockRange.Remove(node);
- }
-
- assert(!opts.MinOpts());
- fgStmtRemoved = true;
+ fgRemoveDeadStoreLIR(node, block);
}
break;
return false;
}
+//---------------------------------------------------------------------
+// fgRemoveDeadStoreSimple - remove a dead store
+//
+// pTree - GenTree** to local, including store-form local or local addr (post-rationalize)
+// varDsc - var that is being stored to
+// life - current live tracked vars (maintained as we walk backwards)
+// doAgain - out parameter, true if we should restart the statement
+// pStmtInfoDirty - should defer the cost computation to the point after the reverse walk is completed?
+//
+void Compiler::fgRemoveDeadStoreLIR(GenTree* store, BasicBlock* block)
+{
+ LIR::Range& blockRange = LIR::AsRange(block);
+
+ // If the store is marked as a late argument, it is referenced by a call.
+ // Instead of removing it, bash it to a NOP.
+ if ((store->gtFlags & GTF_LATE_ARG) != 0)
+ {
+ JITDUMP("node is a late arg; replacing with NOP\n");
+ store->gtBashToNOP();
+
+ // NOTE: this is a bit of a hack. We need to keep these nodes around as they are
+ // referenced by the call, but they're considered side-effect-free non-value-producing
+ // nodes, so they will be removed if we don't do this.
+ store->gtFlags |= GTF_ORDER_SIDEEFF;
+ }
+ else
+ {
+ blockRange.Remove(store);
+ }
+
+ assert(!opts.MinOpts());
+ fgStmtRemoved = true;
+}
+
+//---------------------------------------------------------------------
// fgRemoveDeadStore - remove a store to a local which has no exposed uses.
//
// pTree - GenTree** to local, including store-form local or local addr (post-rationalize)