Skip to content

Assertion failed '!foundDiff' when an HFA local var is passed on stack #49780

@echesakov

Description

@echesakov

The following is a simple repro of an issue that a customer reported here - reproduces on both linux-arm64 and win-arm64 on 3.1, 5.0 and 6.0.

using System;
using System.Runtime.CompilerServices;
using System.Numerics;

namespace Runtime_49489
{
    public class Program
    {
        [MethodImpl(MethodImplOptions.NoInlining)]
        static void Callee(float fltReg0, float fltReg1, float fltReg2, float fltReg3, float fltReg4, float fltReg5, float fltReg6, float fltReg7, Vector2 simd8)
        {
        }

        [MethodImpl(MethodImplOptions.NoInlining)]
        static void Caller(int i)
        {
            Vector2 simd8 = new Vector2();

            if (i > 0)
            {
                Callee(0, 0, 0, 0, 0, 0, 0, 0, simd8);
            }
        }

        static void Main(string[] args)
        {
            Caller(1);
        }
    }
}

Running the program with checked runtime and COMPlus_TieredCompilation=0 would result in the following assertion

Assert failure(PID 4680 [0x00001248], Thread: 8804 [0x2264]): Assertion failed '!foundDiff' in 'Runtime_49489.Program:Caller(int)' during 'Linear scan register alloc' (IL size 59)

    File: F:\echesako\git\runtime4\src\coreclr\jit\lsra.cpp Line: 2260
    Image: F:\echesako\git\runtime4\artifacts\tests\coreclr\windows.arm64.Checked\Tests\Core_Root\CoreRun.exe

Note that if if (i > 0) is commented out or removed

            //if (i > 0)
            {
                Callee(0, 0, 0, 0, 0, 0, 0, 0, simd8);
            }

this will fail with a different assertion (on 5.0 and 6.0 but not 3.1)

Assert failure(PID 16692 [0x00004134], Thread: 18316 [0x478c]): Assertion failed '!fldVarDsc->lvIsInReg()' in 'Runtime_49489.Program:Caller(int)' during 'Generate code' (IL size 55)

    File: F:\echesako\git\runtime4\src\coreclr\jit\treelifeupdater.cpp Line: 337
    Image: F:\echesako\git\runtime4\artifacts\tests\coreclr\windows.arm64.Checked\Tests\Core_Root\CoreRun.exe

I attached two JIT dumps for the different failure modes.

jitDump.un-cond.txt
jitDump.if-cond.txt

cc @dotnet/jit-contrib

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions