Fix address exposure + fsub (#66253)
authorEgor Bogatov <egorbo@gmail.com>
Mon, 7 Mar 2022 08:53:34 +0000 (11:53 +0300)
committerGitHub <noreply@github.com>
Mon, 7 Mar 2022 08:53:34 +0000 (11:53 +0300)
src/coreclr/jit/forwardsub.cpp
src/tests/JIT/Regression/JitBlue/Runtime_66242/Runtime_66242.cs [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_66242/Runtime_66242.csproj [new file with mode: 0644]

index c14cbf7..0492f0e 100644 (file)
@@ -636,7 +636,7 @@ bool Compiler::fgForwardSubStatement(Statement* stmt)
     // If fwdSubNode is an address-exposed local, forwarding it may lose optimizations.
     // (maybe similar for dner?)
     //
-    if (fwdSubNode->OperIs(GT_LCL_VAR))
+    if (fwdSubNode->IsLocal())
     {
         unsigned const   fwdLclNum = fwdSubNode->AsLclVarCommon()->GetLclNum();
         LclVarDsc* const fwdVarDsc = lvaGetDesc(fwdLclNum);
diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_66242/Runtime_66242.cs b/src/tests/JIT/Regression/JitBlue/Runtime_66242/Runtime_66242.cs
new file mode 100644 (file)
index 0000000..bec4dd0
--- /dev/null
@@ -0,0 +1,43 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+// Generated by Fuzzlyn v1.5 on 2022-02-27 18:35:07
+// Run on X86 Windows
+// Seed: 14567735315501116995
+// Reduced from 12.1 KiB to 0.5 KiB in 00:01:37
+// Debug: Outputs 2
+// Release: Outputs 1
+
+using System.Runtime.CompilerServices;
+
+public struct S0
+{
+    public ulong F1;
+}
+
+public struct S1
+{
+    public S0 F6;
+}
+
+public class Runtime_66242
+{
+    public static short s_3;
+    public static int Main()
+    {
+        var vr3 = new S1();
+        if (vr3.F6.F1 < M4(ref vr3))
+        {
+            int vr9 = s_3++;
+        }
+
+        return s_3 + 98;
+    }
+
+    public static uint M4(ref S1 arg1)
+    {
+        int var0 = s_3++;
+        arg1.F6.F1 = 16700531892663534200UL;
+        return 1;
+    }
+}
diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_66242/Runtime_66242.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_66242/Runtime_66242.csproj
new file mode 100644 (file)
index 0000000..f492aea
--- /dev/null
@@ -0,0 +1,9 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="$(MSBuildProjectName).cs" />
+  </ItemGroup>
+</Project>
\ No newline at end of file