* Use `TransformUnusedIndirection` in LIR liveness.
* Use `TYP_INT` as `TransformUnusedIndirection` does.
* fix grammar.
// tree - the node to change;
// basicBlock - basic block of the node.
//
+// Notes:
+// the function should not be called after lowering for platforms that do not support
+// emitting NULLCHECK nodes, like arm32. Use `Lowering::TransformUnusedIndirection`
+// that handles it and calls this function when appropriate.
+//
void Compiler::gtChangeOperToNullCheck(GenTree* tree, BasicBlock* block)
{
assert(tree->OperIs(GT_FIELD, GT_IND, GT_OBJ, GT_BLK, GT_DYN_BLK));
tree->ChangeOper(GT_NULLCHECK);
- tree->ChangeType(TYP_BYTE);
+ tree->ChangeType(TYP_INT);
block->bbFlags |= BBF_HAS_NULLCHECK;
optMethodFlags |= OMF_HAS_NULLCHECK;
}
if (!removed && node->IsUnusedValue())
{
// IR doesn't expect dummy uses of `GT_OBJ/BLK/DYN_BLK`.
- JITDUMP("Replace an unused OBJ/BLK node [%06d] with a NULLCHECK\n", dspTreeID(node));
- gtChangeOperToNullCheck(node, block);
+ JITDUMP("Transform an unused OBJ/BLK node [%06d]\n", dspTreeID(node));
+ Lowering::TransformUnusedIndirection(node->AsIndir(), this, block);
}
}
break;
// - On XARCH, use GT_IND if we have a contained address, and GT_NULLCHECK otherwise.
// In all cases, change the type to TYP_INT.
//
- assert(ind->OperIs(GT_NULLCHECK, GT_IND));
+ assert(ind->OperIs(GT_NULLCHECK, GT_IND, GT_BLK, GT_OBJ));
ind->gtType = TYP_INT;
#ifdef TARGET_ARM64
bool useNullCheck = !ind->Addr()->isContained();
#endif // !TARGET_XARCH
- if (useNullCheck && ind->OperIs(GT_IND))
+ if (useNullCheck && !ind->OperIs(GT_NULLCHECK))
{
comp->gtChangeOperToNullCheck(ind, block);
ind->ClearUnusedValue();
}
- else if (!useNullCheck && ind->OperIs(GT_NULLCHECK))
+ else if (!useNullCheck && !ind->OperIs(GT_IND))
{
ind->ChangeOper(GT_IND);
ind->SetUnusedValue();