Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compareTypesForEquality #97062

Merged
merged 7 commits into from
Jan 18, 2024
Merged

Fix compareTypesForEquality #97062

merged 7 commits into from
Jan 18, 2024

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Jan 17, 2024

Fixes #96876

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jan 17, 2024
@ghost ghost assigned jkotas Jan 17, 2024
@ghost
Copy link

ghost commented Jan 17, 2024

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #96876

Author: jkotas
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

return true;
}

switch (et1)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This improves the original implementation in addition to make it correct. For example, this can prove that KeyValuePair<__Canon, int> and KeyValuePair<int, __Canon> are never equal that the original implementation was not able to.

@EgorBo
Copy link
Member

EgorBo commented Jan 17, 2024

@MihuBot

@JulieLeeMSFT JulieLeeMSFT added area-VM-coreclr and removed area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels Jan 17, 2024
@jkotas
Copy link
Member Author

jkotas commented Jan 17, 2024

/azp run runtime-nativeaot-outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jkotas
Copy link
Member Author

jkotas commented Jan 18, 2024

/azp run runtime-nativeaot-outerloop

@jkotas jkotas marked this pull request as ready for review January 18, 2024 00:00
@jkotas
Copy link
Member Author

jkotas commented Jan 18, 2024

@MichalStrehovsky PTLA

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jkotas
Copy link
Member Author

jkotas commented Jan 18, 2024

This bug is not a recent regression for AOT compilers. The test introduced by this change fails with PublishAot and PublishReadyToRun in .NET 8. Any thoughts about whether the backport meets the bar?

@EgorBo
Copy link
Member

EgorBo commented Jan 18, 2024

This bug is not a recent regression for AOT compilers. The test introduced by this change fails with PublishAot and PublishReadyToRun in .NET 8. Any thoughts about whether the backport meets the bar?

hm.. doesn't repro for me with R2R on net8.0, but does repro with NativeAOT

@jkotas
Copy link
Member Author

jkotas commented Jan 18, 2024

hm.. doesn't repro for me with R2R on net8.0, but does repro with NativeAOT

Good catch. The pattern matching of typeof(X) == t.GetType() checks seems to be broken in R2R (you can take a look why is that).

The pattern matching of typeof(X) == typeof(Y) works well and hits the bug in .NET 8:

C:\repro>type Program.cs
using System.Runtime.CompilerServices;

public class Test96876
{
    public static void Main()
    {
        Console.WriteLine(foo<string>());
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    static bool foo<T>() => typeof(T[]) == typeof(string[]);
}
C:\repro>dotnet run
True

C:\repro>dotnet publish /p:PublishReadyToRun=true
MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  Restored C:\repro\repro.csproj (in 174 ms).
  repro -> C:\repro\bin\Release\net8.0\win-x64\repro.dll
  repro -> C:\repro\bin\Release\net8.0\win-x64\publish\

C:\repro>C:\repro\bin\Release\net8.0\win-x64\publish\repro.exe
False

C:\repro>rmdir /s /q bin obj

C:\repro>dotnet publish /p:PublishAot=true
MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  Restored C:\repro\repro.csproj (in 288 ms).
  repro -> C:\repro\bin\Release\net8.0\win-x64\repro.dll
  Generating native code
  repro -> C:\repro\bin\Release\net8.0\win-x64\publish\

C:\repro>C:\repro\bin\Release\net8.0\win-x64\publish\repro.exe
False

@jkotas
Copy link
Member Author

jkotas commented Jan 18, 2024

The pattern matching of typeof(X) == t.GetType() checks seems to be broken in R2R

Opened #97134

@jkotas
Copy link
Member Author

jkotas commented Jan 18, 2024

/azp run runtime-nativeaot-outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MichalStrehovsky
Copy link
Member

This bug is not a recent regression for AOT compilers. The test introduced by this change fails with PublishAot and PublishReadyToRun in .NET 8. Any thoughts about whether the backport meets the bar?

We also shipped with it in .NET 7. Not a regression from previous release, no customer reports. Doesn't feel like we have a strong case for backport.

@jkotas jkotas merged commit 5415bd2 into dotnet:main Jan 18, 2024
8 of 14 checks passed
@jkotas jkotas deleted the issue-96876 branch January 18, 2024 18:41
tmds pushed a commit to tmds/runtime that referenced this pull request Jan 23, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CollectionsMarshal.AsSpan assertion failure in System.Text.Json tests
4 participants