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

JIT: Bad codegen on win-x86 #75249

Closed
jakobbotsch opened this issue Sep 8, 2022 · 4 comments · Fixed by #75375
Closed

JIT: Bad codegen on win-x86 #75249

jakobbotsch opened this issue Sep 8, 2022 · 4 comments · Fixed by #75375
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone

Comments

@jakobbotsch
Copy link
Member

// Generated by Fuzzlyn v1.5 on 2022-09-04 15:54:25
// Run on X86 Windows
// Seed: 14105179845188319926
// Reduced from 33.3 KiB to 0.8 KiB in 00:01:22
// Debug: Outputs 0
// Release: Outputs 1
public struct S1
{
    public uint F0;
    public S2 M18(ref int arg0, ulong arg1)
    {
        S1 var6;
        try
        {
        }
        finally
        {
            var6.F0 = Program.s_13;
            this = var6;
        }

        return new S2(0);
    }
}

public struct S2
{
    public S1 F0;
    public short F1;
    public S2(short f1): this()
    {
        F1 = f1;
    }
}

public class Program
{
    public static byte s_4;
    public static int s_10;
    public static uint s_13 = 1;
    public static int s_19;
    public static void Main()
    {
        S2 vr1 = new S2(-1);
        M17(vr1, M17(vr1.F0.M18(ref s_19, 0), s_4));
    }

    public static byte M17(S2 arg0, int arg4)
    {
        System.Console.WriteLine(arg0.F0.F0);
        return (byte)s_10;
    }
}
@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 Sep 8, 2022
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Sep 8, 2022
@ghost
Copy link

ghost commented Sep 8, 2022

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

Issue Details
// Generated by Fuzzlyn v1.5 on 2022-09-04 15:54:25
// Run on X86 Windows
// Seed: 14105179845188319926
// Reduced from 33.3 KiB to 0.8 KiB in 00:01:22
// Debug: Outputs 0
// Release: Outputs 1
public struct S1
{
    public uint F0;
    public S2 M18(ref int arg0, ulong arg1)
    {
        S1 var6;
        try
        {
        }
        finally
        {
            var6.F0 = Program.s_13;
            this = var6;
        }

        return new S2(0);
    }
}

public struct S2
{
    public S1 F0;
    public short F1;
    public S2(short f1): this()
    {
        F1 = f1;
    }
}

public class Program
{
    public static byte s_4;
    public static int s_10;
    public static uint s_13 = 1;
    public static int s_19;
    public static void Main()
    {
        S2 vr1 = new S2(-1);
        M17(vr1, M17(vr1.F0.M18(ref s_19, 0), s_4));
    }

    public static byte M17(S2 arg0, int arg4)
    {
        System.Console.WriteLine(arg0.F0.F0);
        return (byte)s_10;
    }
}
Author: jakobbotsch
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@JulieLeeMSFT JulieLeeMSFT removed the untriaged New issue has not been triaged by the area owner label Sep 8, 2022
@JulieLeeMSFT JulieLeeMSFT added this to the 7.0.0 milestone Sep 8, 2022
@JulieLeeMSFT
Copy link
Member

@jakobbotsch PTAL. cc @dotnet/jit-contrib.

@jakobbotsch
Copy link
Member Author

This looks like fallout from #74384. From a cursory glance we do an illegal copy propagation: vr1 in the example is promoted, the local created for vr.F0 is address exposed, yet we remove the copy of vr1 to a temp. (We do not address expose the parent struct in this case).

Presumably the fix is simple and is to make copy propagation illegal if any field is address exposed.

I won't have time to look into a fix until next week, but this is not a 7.0 issue anyway. @AndyAyersMS feel free to pick it up if you want, otherwise I'll submit a fix next week.

@jakobbotsch jakobbotsch modified the milestones: 7.0.0, 8.0.0 Sep 9, 2022
@AndyAyersMS
Copy link
Member

AndyAyersMS commented Sep 9, 2022

Seems like we ought to block this at assertion gen, not assertion prop? We won't reason about struct kills properly if any part of a struct is exposed.

We already check for exposure during assertion gen, but we don't check for dependent field exposure.

AndyAyersMS added a commit to AndyAyersMS/runtime that referenced this issue Sep 9, 2022
…fields

If a struct has an exposed field, we can't safely reason about is value in
local assertion prop.

Closes dotnet#75249.
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Sep 9, 2022
AndyAyersMS added a commit that referenced this issue Sep 10, 2022
…fields (#75375)

If a struct has an exposed field, we can't safely reason about is value in
local assertion prop.

Closes #75249.
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Sep 10, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Oct 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants