Skip to content

JIT: Assertion failed gtCostsInitialized during Determine first cold block #106484

@amanasifkhalid

Description

@amanasifkhalid
// Found by Antigen
// Reduced from 23.81 KB to 2.47 KB.


using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;
using System.Numerics;
public class TestClass
{
    public struct S2
    {
    }
    static float s_float_11 = 2f;
    static uint s_uint_14 = 2;
    double double_23 = 2.05;
    short short_24 = -5;
    int int_25 = 2;
    long long_26 = 1;
    string string_29 = "TAU4T";
    ushort ushort_30 = 32767;
    S2 s2_35 = new S2();
    private static List<string> toPrint = new List<string>();
    public string LeafMethod10()
    {
        unchecked
        {
            return string_29 = 15+4+ (string_29 = string_29)+ 15+4;
        }
    }
    [MethodImpl(MethodImplOptions.NoInlining)]
    public ushort LeafMethod11()
    {
        unchecked
        {
            return 15*4;
        }
    }
    [MethodImpl(MethodImplOptions.NoInlining)]
    public uint LeafMethod12()
    {
        unchecked
        {
            return s_uint_14;
        }
    }
    public ushort Method4(double p_double_112, S2 p_s2_113, double p_double_114, long p_long_115, ref short p_short_116, uint p_uint_117, uint p_uint_118, ref float p_float_119)
    {
        unchecked
        {
            ushort ushort_131 = 5;
            for (; int_25 < int_25; ushort_30 = LeafMethod11())
            {
                try
{}                catch (System.OperationCanceledException)
                {
                    switch (LeafMethod10())
                    {
                        case "":
                        {
                            break;
                        }
                        case "Q5K0MERLU":
                        {
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                }
                finally
                {
                }
            }
            return ushort_131;
        }
    }
    public void Method0()
    {
        unchecked
        {
            ushort ushort_148 = 5;
            ushort_148 = Method4(15%4, s2_35, double_23 = 15*4, long_26, ref short_24, 15*4, LeafMethod12(), ref s_float_11);
            return;
        }
    }
    public static void Main(string[] args)
    {
    }
    public static int Antigen()
    {
        new TestClass().Method0();
        return string.Join(Environment.NewLine, toPrint).GetHashCode();
    }
}
/*
Environment:

set DOTNET_JitFakeProcedureSplitting=1
set DOTNET_TC_PartialCompilation=1
set DOTNET_TC_QuickJitForLoops=1
set DOTNET_TieredCompilation=0
set DOTNET_JitStressRegs=1
set DOTNET_JitStress=0
set DOTNET_JitThrowOnAssertionFailure=1
set DOTNET_LegacyExceptionHandling=1

Debug: 0
JIT assert failed:
Assertion failed 'gtCostsInitialized' in 'TestClass:Method4(double,TestClass+S2,double,long,byref,uint,uint,byref):ushort:this' during 'Determine first cold block' (IL size 104; hash 0xb126af18; MinOpts)

    File: D:\a\_work\1\s\src\coreclr\jit\gentree.h Line: 773

Release: 2093367870
*/

This hits because it's currently possible to do hot/cold splitting when we aren't optimizing otherwise, which doesn't seem particularly useful. We can just move this phase under opts.OptimizationEnabled(). @AndyAyersMS does this seem reasonable? cc @dotnet/jit-contrib

Metadata

Metadata

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions