summaryrefslogtreecommitdiff
path: root/tests/src/JIT/Regression/JitBlue/DevDiv_283795/DevDiv_283795.cs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/JIT/Regression/JitBlue/DevDiv_283795/DevDiv_283795.cs')
-rw-r--r--tests/src/JIT/Regression/JitBlue/DevDiv_283795/DevDiv_283795.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_283795/DevDiv_283795.cs b/tests/src/JIT/Regression/JitBlue/DevDiv_283795/DevDiv_283795.cs
new file mode 100644
index 0000000000..55da5ba1e9
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/DevDiv_283795/DevDiv_283795.cs
@@ -0,0 +1,55 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.CompilerServices;
+
+class C
+{
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static int[] M()
+ {
+ return null;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static bool Test(int i, int j, bool execute)
+ {
+ if (execute)
+ {
+ return M()[checked(i + j)] == 0;
+ }
+
+ return true;
+ }
+
+ static int Main()
+ {
+ // The original repro of the bug associated with this test involved an assert after re-morphing a tree modified
+ // by CSE: the original tree contained both a CSE def and a CSE use, and re-morphing eliminated the use, causing
+ // CSE to assert when attempting to replace the use with a reference to the CSE lclVar. This call to `Test` is
+ // intended to trigger that assert.
+ bool test1 = Test(0, 0, false);
+
+ // The associated code in morph involves folding `(x + null)` to `x`. During the investigation of the original
+ // issue, it was found that the folding code also failed to check for side effects in `x` resulting in SBCG if
+ // side effects were in fact present in `x`. This call to `Test` is intended to ensure that the fold is not
+ // performed in the face of a tree that contains side-effects: in particular, the overflowing add in the
+ // called method should occur before any other exception.
+ bool test2 = false;
+ try
+ {
+ Test(int.MaxValue, int.MaxValue, true);
+ }
+ catch (System.OverflowException)
+ {
+ test2 = true;
+ }
+ catch (System.Exception e)
+ {
+ System.Console.WriteLine(e);
+ }
+
+ return test1 && test2 ? 100 : 101;
+ }
+}