Fix to VectorCopyTo test that are failing with NullReferencException on an AVX2 machine.
Scenario: Vector2/3/4.CopyTo(array, idx) or Vector<T>.CopyTo(array, idx)
Expected: Here the second arg is out of range and an argument out of range exception is expected.
Observed: AV while generating helper call to throw range-check exception which gets propagated as NullReferenceException
Root cause: If repro program being run is debug version (i.e. JIT is asked to execute minopts/debuggable code)
genRangeCheck() ->genJumpToThrowHlpBlk(bndsChk->gtThrowKind) ->Compiler::acdHelper(codeKind)
Since Compiler::acdHelper() doesn't have mapping for SCK_ARG_EXCPN and SCK_ARG_RNG_EXCPN it return zero as helper number. On chk builds this further leads to asserts in VM when genEmitHelperCall()->compGetHelperFtn(helpernum) call is made. On retail builds, it will lead to AV, which gets propagated as NullReferenceException.
Why this doesn't repro on SSE2: SIMD intrinsics are disabled while generating minopts/debuggable code.
Why does this repro on AVX2: Since VM used size for Vector<T> doesn't match IL definition of Vector<T>, JIT has no way but to support SIMD intrinsics even while generating minopts/debuggable code.
On manual source examination found a couple of places where (in compiler.hpp) that are supposed to check for SCK_ARG_EXCPN and SCK_ARG_RNG_EXCPN and fixed those as well.
Fix dotnet/coreclr#3262
[tfs-changeset: 1527996]
Commit migrated from https://github.com/dotnet/coreclr/commit/
a4882f5ed09736946ad7871f933c0e726b10b956