Skip to content

Zero assignments are removed incorrectly #37666

Closed

Description

@erozenfeld

The following two tests are failing when jit is optimizing:

using System;
using System.Runtime.CompilerServices;

public struct TwoBools
{
    public bool b1;
    public bool b2;

    public TwoBools(bool b1, bool b2)
    {
        this.b1 = b1;
        this.b2 = b2;
    }
}

class Test
{
    public static int Main()
    {
        int result = 100;

        if (Test1().b2)
        {
            Console.WriteLine("Test1 failed");
            result = -1;
        }
        else
        {
            Console.WriteLine("Test1 passed");
        }

        if (Test2().b2)
        {
            Console.WriteLine("Test2 failed");
            result = -1;
        }
        else
        {
            Console.WriteLine("Test2 passed");
        }

        return result;
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    static TwoBools Test1()
    {
        TwoBools result = CreateTwoBools();
        result.b2 = false;
        return result;
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    static TwoBools Test2()
    {
        TwoBools result = default(TwoBools);
        result.b2 = true;
        result = default(TwoBools);
        return result;
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    static TwoBools CreateTwoBools()
    {
        TwoBools result = new TwoBools(true, true);
        return result;
    }
}

Activity

  1. added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Jun 9, 2020
  2. added this to the 5.0 milestone on Jun 9, 2020
  3. self-assigned this
    on Jun 9, 2020
  4. erozenfeld commented on Jun 9, 2020

    @erozenfeld
    ContributorAuthor

    optRemoveRedundantZeroInits is not dealing correctly with untracked fields represented by LCL_VAR's

  5. removed
    untriagedNew issue has not been triaged by the area owner
    on Jun 12, 2020
  6. added a commit that references this issue on Jun 12, 2020
    2671dec
  7. added a commit that references this issue on Jun 12, 2020
    d82b7be
  8. ghost locked as resolved and limited conversation to collaborators on Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIbug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions