From 3809a06b68ac70148a19a37cd3cec650ba4f27c7 Mon Sep 17 00:00:00 2001 From: Carol Eidt Date: Wed, 5 Jun 2019 14:51:04 -0700 Subject: Cleanup block stores and test for 24846 (#24950) * Cleanup block stores and test for 24846 Fix zero-length assert/bad codegen for initblk. Remove redundant assertions in codegen and those that don't directly relate to codegen requirements. Eliminate redundant LEA that was being generated by `genCodeForCpBlk`. Rename `genCodeFor[Cp|Init]Blk` to `genCodeFor[Cp|Init]BlkHelper` to parallel the other forms. Fix the test case for #24846. --- .../JitBlue/GitHub_24846/GitHub_24846.cs | 88 ++++++++++------------ 1 file changed, 39 insertions(+), 49 deletions(-) (limited to 'tests/src/JIT') diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_24846/GitHub_24846.cs b/tests/src/JIT/Regression/JitBlue/GitHub_24846/GitHub_24846.cs index dbd276f142..77aec9998b 100644 --- a/tests/src/JIT/Regression/JitBlue/GitHub_24846/GitHub_24846.cs +++ b/tests/src/JIT/Regression/JitBlue/GitHub_24846/GitHub_24846.cs @@ -5,11 +5,16 @@ using System; using System.Runtime.CompilerServices; -public class GitHub_24846 +unsafe public class GitHub_24846 { - public static void Test(byte[] destination, byte[] source) + public static void TestCopy(byte* destination, byte* source) { - Unsafe.CopyBlockUnaligned(ref destination[0], ref source[0], 0); + Unsafe.CopyBlockUnaligned(destination, source, 0); + } + + public static void TestInit(byte* destination) + { + Unsafe.InitBlockUnaligned(destination, 0xff, 0); } public static int Main(string[] args) @@ -17,52 +22,37 @@ public class GitHub_24846 int returnVal = 100; var destination = new byte[1]; var source = new byte[1]; - try - { - Test(destination, source); - } - catch (Exception e) - { - Console.WriteLine("FAILED: " + e.Message); - returnVal = -1; - } - bool caught = false; - try - { - Test(destination, null); - } - catch (NullReferenceException e) - { - caught = true; - } - catch (Exception e) - { - Console.WriteLine("FAILED: Wrong Exception " + e.Message); - returnVal = -1; - } - if (!caught) - { - Console.WriteLine("FAILED: null destination didn't throw"); - returnVal = -1; - } - caught = false; - try - { - Test(null, source); - } - catch (NullReferenceException e) - { - caught = true; - } - catch (Exception e) - { - Console.WriteLine("FAILED: Wrong Exception " + e.Message); - returnVal = -1; - } - if (!caught) - { - Console.WriteLine("FAILED: null source didn't throw"); - returnVal = -1; + fixed (byte* destPtr = &destination[0], srcPtr = &source[0]) + { + try + { + TestCopy(destPtr, srcPtr); + TestInit(destPtr); + } + catch (Exception e) + { + Console.WriteLine("FAILED: " + e.Message); + returnVal = -1; + } + try + { + TestCopy(destPtr, null); + } + catch (Exception e) + { + Console.WriteLine("FAILED: " + e.Message); + returnVal = -1; + } + try + { + TestCopy(null, srcPtr); + TestInit(null); + } + catch (Exception e) + { + Console.WriteLine("FAILED: " + e.Message); + returnVal = -1; + } } return returnVal; } -- cgit v1.2.3