Skip to content

Commit 4aa8253

Browse files
jakobbotschgithub-actions
authored andcommitted
Disable poisoning for large structs
For very large structs (> 64K in size) poisoning could end up generating instructions requiring larger local var offsets than we can handle. This hits IMPL_LIMIT that throws InvalidProgramException. Turn off poisoning for larger structs that require more than 16 movs to also avoid the significant code bloat by the singular movs. This is a less risky version of #61521 for backporting to .NET 6. Fix #60852
1 parent 09e3dcb commit 4aa8253

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/coreclr/jit/codegencommon.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12551,6 +12551,17 @@ void CodeGen::genPoisonFrame(regMaskTP regLiveIn)
1255112551

1255212552
assert(varDsc->lvOnFrame);
1255312553

12554+
int size = (int)compiler->lvaLclSize(varNum);
12555+
12556+
if (size / TARGET_POINTER_SIZE > 16)
12557+
{
12558+
// For very large structs the offsets in the movs we emit below can
12559+
// grow too large to be handled properly by JIT. Furthermore, while
12560+
// this is only debug code, for very large structs this can bloat
12561+
// the code too much due to the singular movs used.
12562+
continue;
12563+
}
12564+
1255412565
if (!hasPoisonImm)
1255512566
{
1255612567
#ifdef TARGET_64BIT
@@ -12568,7 +12579,6 @@ void CodeGen::genPoisonFrame(regMaskTP regLiveIn)
1256812579
#else
1256912580
int addr = 0;
1257012581
#endif
12571-
int size = (int)compiler->lvaLclSize(varNum);
1257212582
int end = addr + size;
1257312583
for (int offs = addr; offs < end;)
1257412584
{

0 commit comments

Comments
 (0)