From: Carol Eidt Date: Tue, 24 Jan 2017 00:23:29 +0000 (-0800) Subject: Add a test case for a test optimization X-Git-Tag: submit/tizen/20210909.063632~11030^2~8365^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f0ce5d30240e0cd9c8bc84fc92f4fb1ff3ce24cd;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Add a test case for a test optimization Commit migrated from https://github.com/dotnet/coreclr/commit/1a0e8a72f50905a564b4efcacd0785cd859c544d --- diff --git a/src/coreclr/tests/src/JIT/Regression/JitBlue/DevDiv_1206929/DevDiv_1206929.cs b/src/coreclr/tests/src/JIT/Regression/JitBlue/DevDiv_1206929/DevDiv_1206929.cs new file mode 100644 index 0000000..d363360 --- /dev/null +++ b/src/coreclr/tests/src/JIT/Regression/JitBlue/DevDiv_1206929/DevDiv_1206929.cs @@ -0,0 +1,50 @@ +using System; +using System.Runtime.CompilerServices; + +namespace ReadMemBytes +{ + class Program + { + static int Pass = 100; + static int Fail = -1; + + [MethodImpl(MethodImplOptions.NoInlining)] + static unsafe int TestMemBytesNotReadPastTheLimit(byte *p, int byteLength) + { + int count = 0; + for (int i= 0; i< byteLength; ++i) + { + // RyuJIT lowering has an optimization to recognize the condition in + // "If" stmnt and generate "test byte ptr [p+i], 0" instruction. Due + // to a bug that has been fixed it will end up generating "test dword ptr [p+i], 0" + // that will lead to reading 4 bytes instead of a single byte. + if ((p[i] & 0xffffff00) != 0) + { + ++count; + } + } + + return count; + } + static unsafe int Main(string[] args) + { + byte* buffer = stackalloc byte[4]; + buffer[0] = 0; + buffer[1] = buffer[2] = buffer[3] = 0xff; + + int result = TestMemBytesNotReadPastTheLimit(buffer, 1); + if (result != 0) + { + Console.WriteLine("Failed: Read past the end of buffer"); + return Fail; + } + else + { + Console.WriteLine("Pass"); + } + + return Pass; + + } + } +} diff --git a/src/coreclr/tests/src/JIT/Regression/JitBlue/DevDiv_1206929/DevDiv_1206929.csproj b/src/coreclr/tests/src/JIT/Regression/JitBlue/DevDiv_1206929/DevDiv_1206929.csproj new file mode 100644 index 0000000..a1f7eaa --- /dev/null +++ b/src/coreclr/tests/src/JIT/Regression/JitBlue/DevDiv_1206929/DevDiv_1206929.csproj @@ -0,0 +1,47 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + Properties + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + $(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages + ..\..\ + + 7a9bfb7d + + + + + + + + + False + + + + + True + True + + + + + + + + + $(JitPackagesConfigFileDirectory)minimal\project.json + $(JitPackagesConfigFileDirectory)minimal\project.lock.json + + + + +