runtime: PMI diffs are failing due to assert

jit-diff.bat diff --diff --pmi --frameworks currently fails for the following methods:

  • PREPALL type# 1350 method# 20377 System.Text.Encoding::GetCharsWithFallback
  • PREPALL type# 1350 method# 20378 System.Text.Encoding::GetCharsWithFallback
  • PREPALL type# 1350 method# 20472 System.Text.Encoding::GetBytesWithFallback
  • PREPALL type# 1350 method# 20473 System.Text.Encoding::GetBytesWithFallback
  • PREPALL type# 1350 method# 20477 System.Text.Encoding::GetCharCountWithFallback
  • PREPALL type# 1350 method# 20478 System.Text.Encoding::GetCharCountWithFallback

In all cases, an assert in emitOutputRR is firing: https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/emitxarch.cpp#L11738-L11739

                    case INS_add:
                    case INS_sub:
                        assert(id->idGCref() == GCT_BYREF);

#ifdef DEBUG
                        regMaskTP regMask;
                        regMask = genRegMask(reg1) | genRegMask(reg2);

                        // r1/r2 could have been a GCREF as GCREF + int=BYREF
                        //                            or BYREF+/-int=BYREF
                        assert(((regMask & emitThisGCrefRegs) && (ins == INS_add)) ||
                               ((regMask & emitThisByrefRegs) && (ins == INS_add || ins == INS_sub)));
#endif
                        // Mark r1 as holding a byref
                        emitGCregLiveUpd(GCT_BYREF, reg1, dst);
                        break;

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 27 (26 by maintainers)

Commits related to this issue

Most upvoted comments

This assert is planned to be disabled in https://github.com/dotnet/runtime/pull/55861

GC tracking has an inherent idea that GC refs are not created out of thin air. So int + int -> byref is not ok, it means one of those int was really a byref, and the problem lies upstream somewhere.

IIRC the object allocator phase does the right sort of analysis to motivate potentially retyping the local, if the only defs/uses of the local are byrefs.