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

Assertion failed 'alignInstr->idaIG->endsWithAlignInstr()' during 'Generate code' #65690

Closed
kunalspathak opened this issue Feb 22, 2022 · 5 comments
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone

Comments

@kunalspathak
Copy link
Member

// Found by Antigen
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
public class TestClass
{
    public struct S1
    {
        public struct S1_D1_F1
        {
            public decimal decimal_0;
            public bool bool_1;
            public sbyte sbyte_2;
        }
        public double double_3;
    }
    public struct S2
    {
        public S1.S1_D1_F1 s1_s1_d1_f1_5;
    }
    static byte s_byte_7 = 2;
    static decimal s_decimal_9 = -1.9647058823529411764705882353m;
    static int s_int_12 = 1;
    static long s_long_13 = -2147483647;
    static ulong s_ulong_19 = 1;
    static S1.S1_D1_F1 s_s1_s1_d1_f1_20 = new S1.S1_D1_F1();
    bool bool_23 = true;
    byte byte_24 = 5;
    int int_29 = 1;
    ushort ushort_34 = 5;
    uint uint_35 = 5;
    S1.S1_D1_F1 s1_s1_d1_f1_37 = new S1.S1_D1_F1();
    S1 s1_38 = new S1();
    S2 s2_39 = new S2();
    static int s_loopInvariant = 4;
    [MethodImpl(MethodImplOptions.NoInlining)]
    public byte LeafMethod1()
    {
        unchecked
        {
            return 15+4;
        }
    }
    public long LeafMethod7()
    {
        unchecked
        {
            return s_long_13 |= 15>>4;
        }
    }
    public double Method3(S1 p_s1_91, long p_long_92, out sbyte p_sbyte_93, out double p_double_94, uint p_uint_95, S1 p_s1_96, uint p_uint_97, out S1.S1_D1_F1 p_s1_s1_d1_f1_98)
    {
        unchecked
        {
            S1.S1_D1_F1 s1_s1_d1_f1_113 = new S1.S1_D1_F1();
            p_double_94 = 15+4;
            p_s1_s1_d1_f1_98 = s1_s1_d1_f1_113;
            p_sbyte_93 = 15%4;
            return 15+4;
        }
    }
    public ulong Method4(out decimal p_decimal_117, ulong p_ulong_118, out long p_long_119)
    {
        unchecked
        {
            long long_127 = -2147483647;
            p_decimal_117 = s_decimal_9 = 0.1052631578947368421052631579m;
            p_long_119 = long_127 <<= int_29 &= 15^4;
            return 15+4;
        }
    }
    public void Method0()
    {
        unchecked
        {
            int int_145 = -5;
            ulong ulong_152 = 5;
            S1.S1_D1_F1 s1_s1_d1_f1_153 = new S1.S1_D1_F1();
            S1 s1_154 = new S1();
            S2 s2_155 = new S2();
            if (15-4!= LeafMethod1())
            {
            }
            else
            {
                try
                {
                    ulong_152 >>= s_int_12 = int_145 -= 15+4;
                }
                catch (System.AccessViolationException)
                {
                }
                finally
                {
                    s2_39.s1_s1_d1_f1_5.decimal_0 = 15%4+ s1_s1_d1_f1_153.decimal_0 - 15+4+ 40;
                }
                int __loopvar25 = 15+4;
                do
                {
                    if (__loopvar25 < s_loopInvariant - 1)
                        break;
                }
                while (s1_s1_d1_f1_37.bool_1 = s1_s1_d1_f1_37.bool_1 = bool_23);
            }
            if (15/4% ulong_152+ 22+ 78- s_ulong_19> Method4(out s_s1_s1_d1_f1_20.decimal_0, 15&4, out s_long_13))
            {
                int __loopvar26 = 15-4;
                for (;;)
                {
                    if (__loopvar26 >= s_loopInvariant)
                        break;
                    if (s1_s1_d1_f1_37.bool_1)
                    {
                        double double_172 = Method3(s1_38, LeafMethod7(), out s2_155.s1_s1_d1_f1_5.sbyte_2, out s1_38.double_3, uint_35 = 15/4, s1_154, 15+4, out s1_s1_d1_f1_153);
                    }
                    else
                    {
                        ushort_34 *= 15%4;
                    }
                    if ((byte_24 = s_byte_7 ^= 15|4)>= (15|4))
                    {
                    }
                    else
                    {
                    }
                }
            }
            else
            {
            }
            return;
        }
    }
    public static void Main(string[] args)
    {
        new TestClass().Method0();
    }
}

/*
Environment:

set COMPlus_JitDoValueNumber=0
set COMPlus_JitStressRegs=3

Assert failure(PID 37244 [0x0000917c], Thread: 42444 [0xa5cc]): Assertion failed 'alignInstr->idaIG->endsWithAlignInstr()' in 'TestClass:Method0():this' during 'Generate code' (IL size 375)
    File: D:\git\dotnet-runtime\src\coreclr\jit\emit.cpp Line: 5265
    Image: d:\git\dotnet-runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\CoreRun.exe
*/
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Feb 22, 2022
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@kunalspathak kunalspathak added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed untriaged New issue has not been triaged by the area owner labels Feb 22, 2022
@ghost
Copy link

ghost commented Feb 22, 2022

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

Issue Details
// Found by Antigen
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
public class TestClass
{
    public struct S1
    {
        public struct S1_D1_F1
        {
            public decimal decimal_0;
            public bool bool_1;
            public sbyte sbyte_2;
        }
        public double double_3;
    }
    public struct S2
    {
        public S1.S1_D1_F1 s1_s1_d1_f1_5;
    }
    static byte s_byte_7 = 2;
    static decimal s_decimal_9 = -1.9647058823529411764705882353m;
    static int s_int_12 = 1;
    static long s_long_13 = -2147483647;
    static ulong s_ulong_19 = 1;
    static S1.S1_D1_F1 s_s1_s1_d1_f1_20 = new S1.S1_D1_F1();
    bool bool_23 = true;
    byte byte_24 = 5;
    int int_29 = 1;
    ushort ushort_34 = 5;
    uint uint_35 = 5;
    S1.S1_D1_F1 s1_s1_d1_f1_37 = new S1.S1_D1_F1();
    S1 s1_38 = new S1();
    S2 s2_39 = new S2();
    static int s_loopInvariant = 4;
    [MethodImpl(MethodImplOptions.NoInlining)]
    public byte LeafMethod1()
    {
        unchecked
        {
            return 15+4;
        }
    }
    public long LeafMethod7()
    {
        unchecked
        {
            return s_long_13 |= 15>>4;
        }
    }
    public double Method3(S1 p_s1_91, long p_long_92, out sbyte p_sbyte_93, out double p_double_94, uint p_uint_95, S1 p_s1_96, uint p_uint_97, out S1.S1_D1_F1 p_s1_s1_d1_f1_98)
    {
        unchecked
        {
            S1.S1_D1_F1 s1_s1_d1_f1_113 = new S1.S1_D1_F1();
            p_double_94 = 15+4;
            p_s1_s1_d1_f1_98 = s1_s1_d1_f1_113;
            p_sbyte_93 = 15%4;
            return 15+4;
        }
    }
    public ulong Method4(out decimal p_decimal_117, ulong p_ulong_118, out long p_long_119)
    {
        unchecked
        {
            long long_127 = -2147483647;
            p_decimal_117 = s_decimal_9 = 0.1052631578947368421052631579m;
            p_long_119 = long_127 <<= int_29 &= 15^4;
            return 15+4;
        }
    }
    public void Method0()
    {
        unchecked
        {
            int int_145 = -5;
            ulong ulong_152 = 5;
            S1.S1_D1_F1 s1_s1_d1_f1_153 = new S1.S1_D1_F1();
            S1 s1_154 = new S1();
            S2 s2_155 = new S2();
            if (15-4!= LeafMethod1())
            {
            }
            else
            {
                try
                {
                    ulong_152 >>= s_int_12 = int_145 -= 15+4;
                }
                catch (System.AccessViolationException)
                {
                }
                finally
                {
                    s2_39.s1_s1_d1_f1_5.decimal_0 = 15%4+ s1_s1_d1_f1_153.decimal_0 - 15+4+ 40;
                }
                int __loopvar25 = 15+4;
                do
                {
                    if (__loopvar25 < s_loopInvariant - 1)
                        break;
                }
                while (s1_s1_d1_f1_37.bool_1 = s1_s1_d1_f1_37.bool_1 = bool_23);
            }
            if (15/4% ulong_152+ 22+ 78- s_ulong_19> Method4(out s_s1_s1_d1_f1_20.decimal_0, 15&4, out s_long_13))
            {
                int __loopvar26 = 15-4;
                for (;;)
                {
                    if (__loopvar26 >= s_loopInvariant)
                        break;
                    if (s1_s1_d1_f1_37.bool_1)
                    {
                        double double_172 = Method3(s1_38, LeafMethod7(), out s2_155.s1_s1_d1_f1_5.sbyte_2, out s1_38.double_3, uint_35 = 15/4, s1_154, 15+4, out s1_s1_d1_f1_153);
                    }
                    else
                    {
                        ushort_34 *= 15%4;
                    }
                    if ((byte_24 = s_byte_7 ^= 15|4)>= (15|4))
                    {
                    }
                    else
                    {
                    }
                }
            }
            else
            {
            }
            return;
        }
    }
    public static void Main(string[] args)
    {
        new TestClass().Method0();
    }
}

/*
Environment:

set COMPlus_JitDoValueNumber=0
set COMPlus_JitStressRegs=3

Assert failure(PID 37244 [0x0000917c], Thread: 42444 [0xa5cc]): Assertion failed 'alignInstr->idaIG->endsWithAlignInstr()' in 'TestClass:Method0():this' during 'Generate code' (IL size 375)
    File: D:\git\dotnet-runtime\src\coreclr\jit\emit.cpp Line: 5265
    Image: d:\git\dotnet-runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\CoreRun.exe
*/
Author: kunalspathak
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@kunalspathak kunalspathak self-assigned this Feb 22, 2022
@kunalspathak
Copy link
Member Author

@dotnet/jit-contrib

@BruceForstall BruceForstall added this to the 7.0.0 milestone Feb 22, 2022
@kunalspathak
Copy link
Member Author

This one also has similar symptoms as mentioned in #68510 (comment)

kunalspathak added a commit to kunalspathak/runtime that referenced this issue May 5, 2022
kunalspathak added a commit that referenced this issue May 11, 2022
…re marked as not aligned (#68869)

* Flag to track IGs whose alignment was removed

* Update src/coreclr/jit/emit.cpp

Co-authored-by: Wraith <wraith2@gmail.com>

* Fix for 65988: Unmark the firstBB as not aligned

* Add test case for #65690

* Replace IGF_REMOVE_FLAG with different logic

* improve loops natvis

* Add back IGF_REMOVED_ALIGN

* review comments

Co-authored-by: Wraith <wraith2@gmail.com>
@kunalspathak
Copy link
Member Author

Closed by #68869

@ghost ghost locked as resolved and limited conversation to collaborators Jun 11, 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

No branches or pull requests

2 participants