{
assert(tree != nullptr);
+ GenTree* arrayLength = nullptr;
+
if (tree->OperGet() == GT_CALL)
{
GenTreeCall* call = tree->AsCall();
call->gtCallMethHnd == eeFindHelper(CORINFO_HELP_NEWARR_1_VC) ||
call->gtCallMethHnd == eeFindHelper(CORINFO_HELP_NEWARR_1_ALIGN8))
{
+ // This is an array allocation site. Grab the array length node.
+ arrayLength = gtArgEntryByArgNum(call, 1)->GetNode();
+ }
+ else if (call->gtCallMethHnd == eeFindHelper(CORINFO_HELP_READYTORUN_NEWARR_1))
+ {
+ // On arm when compiling on certain platforms for ready to run, a handle will be
+ // inserted before the length. To handle this case, we will grab the last argument
+ // as that's always the length. See fgInitArgInfo for where the handle is inserted.
+ int arrLenArgNum = call->fgArgInfo->ArgCount() - 1;
+ arrayLength = gtArgEntryByArgNum(call, arrLenArgNum)->GetNode();
+ }
#ifdef DEBUG
+ if (arrayLength != nullptr)
+ {
optCheckFlagsAreSet(OMF_HAS_NEWARRAY, "OMF_HAS_NEWARRAY", BBF_HAS_NEWARRAY, "BBF_HAS_NEWARRAY", tree,
block);
-#endif
- // This is an array allocation site. Grab the array length node.
- return gtArgEntryByArgNum(call, 1)->GetNode();
}
+#endif
}
}
- return nullptr;
+ return arrayLength;
}
//-----------------------------------------------------------------------------
if (actualVal != nullptr)
{
assert(propKind == optPropKind::OPK_ARRAYLEN);
- assert(actualVal->IsCnsIntOrI());
+ assert(actualVal->IsCnsIntOrI() && !actualVal->AsIntCon()->IsIconHandle());
assert(actualVal->GetNodeSize() == TREE_NODE_SZ_SMALL);
ssize_t actualConstVal = actualVal->AsIntCon()->IconValue();