Skip to content

Commit b2babe4

Browse files
authored
JIT: Fix purity of CORINFO_HELP_GETREFANY on win-x64 (#80292)
We mark this helper as pure, but on win-x64 the struct argument becomes an implicit byref and the JIT does not support purity through the "load".
1 parent cd5bbab commit b2babe4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/coreclr/jit/utils.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,12 +1384,19 @@ void HelperCallProperties::init()
13841384

13851385
// helpers returning addresses, these can also throw
13861386
case CORINFO_HELP_UNBOX:
1387-
case CORINFO_HELP_GETREFANY:
13881387
case CORINFO_HELP_LDELEMA_REF:
13891388

13901389
isPure = true;
13911390
break;
13921391

1392+
// GETREFANY is pure up to the value of the struct argument. We
1393+
// only support that when it is not an implicit byref.
1394+
case CORINFO_HELP_GETREFANY:
1395+
#ifndef WINDOWS_AMD64_ABI
1396+
isPure = true;
1397+
#endif
1398+
break;
1399+
13931400
// helpers that return internal handle
13941401
case CORINFO_HELP_GETCLASSFROMMETHODPARAM:
13951402
case CORINFO_HELP_GETSYNCFROMCLASSHANDLE:

src/coreclr/jit/valuenum.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10023,6 +10023,14 @@ void Compiler::fgValueNumberHelperCallFunc(GenTreeCall* call, VNFunc vnf, ValueN
1002310023
default:
1002410024
{
1002510025
assert(s_helperCallProperties.IsPure(eeGetHelperNum(call->gtCallMethHnd)));
10026+
10027+
#ifdef DEBUG
10028+
for (CallArg& arg : call->gtArgs.Args())
10029+
{
10030+
assert(!arg.AbiInfo.PassedByRef &&
10031+
"Helpers taking implicit byref arguments should not be marked as pure");
10032+
}
10033+
#endif
1002610034
}
1002710035
break;
1002810036
}

0 commit comments

Comments
 (0)