[release/6.0] Fix VN incorrect optimizations with a new JitEEInterface function....
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Fri, 27 Aug 2021 20:34:52 +0000 (13:34 -0700)
committerGitHub <noreply@github.com>
Fri, 27 Aug 2021 20:34:52 +0000 (13:34 -0700)
commite209402ffa8817fcc8160d9e6e91c380a47b4a55
tree4c971f5a5c36f3b9ae1a24660a74c1d58f9188c5
parent30a3aa244041ebf074ace0052f323e7c4eb48219
[release/6.0] Fix VN incorrect optimizations with a new JitEEInterface function. (#58005)

* Add/return tests.

* improve the test naming.

* Add a new JitEE method.

with a naive implementation so far.

* Handle generically dissimilar type concerns as well as handle derived type case in the managed compiler

* Fix the field and Unsafe issues.

* fix some failures.

It appeared that we have many trees where we generate unique VN for rhs and don't inform `fgValueNumberBlockAssignment` about it.
For example, for
```
N005 ( 10,  8) [000033] -A--G---R---              *  ASG       struct (copy)
N004 (  3,  2) [000031] D------N----              +--*  LCL_VAR   struct<eightByteStruct, 8> V01 loc1         d:2
N003 (  6,  5) [000030] n---G-------              \--*  IND       struct
N002 (  3,  3) [000043] ------------                 \--*  ADDR      byref
N001 (  3,  2) [000044] -------N----                    \--*  LCL_VAR   struct<largeStruct, 32> V00 loc0         u:6 (last use)
```
we will generate unique rhs but then `fgValueNumberBlockAssignment` will still try to work it as with a non-unique one.

* Fix an oooold bug in VN.

For a tree like:
```
N005 ( 11, 10) [001400] -A------R----             *  ASG       long
N004 (  6,  5) [001401] *------N-----             +--*  IND       long
N003 (  3,  3) [001402] -------------             |  \--*  ADDR      byref  Zero Fseq[_00]
N002 (  3,  2) [001403] U------N-----             |     \--*  LCL_VAR   struct<System.Runtime.Intrinsics.Vector128`1[Byte], 16> V45 tmp38        ud:3->4
N001 (  1,  1) [001404] -------------             \--*  LCL_VAR   long   V69 tmp62        u:2 (last use)
```
SSA was working correctly and printing that `001403` is using SSA-3 and defining SSA-4. However, this code, for some reason, was writing result as a define for SSA-3.

* Add new test cases and a fix for them.

* correct a test copy paste

* response review.

Co-authored-by: Sergey <seandree@microsoft.com>
Co-authored-by: David Wrighton <davidwr@microsoft.com>
33 files changed:
src/coreclr/ToolBox/superpmi/superpmi-shared/lwmlist.h
src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.h
src/coreclr/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp
src/coreclr/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp
src/coreclr/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp
src/coreclr/ToolBox/superpmi/superpmi/icorjitinfo.cpp
src/coreclr/inc/corjit.h
src/coreclr/inc/icorjitinfoimpl_generated.h
src/coreclr/inc/jiteeversionguid.h
src/coreclr/jit/ICorJitInfo_API_names.h
src/coreclr/jit/ICorJitInfo_API_wrapper.hpp
src/coreclr/jit/compiler.h
src/coreclr/jit/importer.cpp
src/coreclr/jit/lclmorph.cpp
src/coreclr/jit/valuenum.cpp
src/coreclr/tools/Common/JitInterface/CorInfoBase.cs
src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt
src/coreclr/tools/aot/jitinterface/jitinterface.h
src/coreclr/vm/jitinterface.cpp
src/coreclr/vm/jitinterface.h
src/libraries/System.Memory/tests/ArrayBufferWriter/ArrayBufferWriterTests.T.cs
src/tests/JIT/Regression/JitBlue/Runtime_54102/Runtime_54102.cs [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_54102/Runtime_54102.csproj [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_56980/Runtime_56980.cs [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_56980/Runtime_56980.csproj [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_57282/Runtime_57282_1.cs [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_57282/Runtime_57282_1.csproj [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_57282/Runtime_57282_2.cs [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_57282/Runtime_57282_2.csproj [new file with mode: 0644]
src/tests/JIT/opt/Structs/structcopies.cs
src/tests/JIT/opt/Structs/structcopies.csproj